MQ4 Code Works

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
Hayseed, finally got that video made. Just with some very specific questions about your last two Youtube videos!

The questions may seem redundant, but I promise they have purpose. Because I work about 50hrs a week, I need to code signals that can work in a programmatically similar way to how you look at the charts... think "Okay, weekend signal down, no add alert indicator on the 240".

 

hayseed

Master Trader
Jul 27, 2010
1,013
258
149
usa
Hayseed, finally got that video made. Just with some very specific questions about your last two Youtube videos!

The questions may seem redundant, but I promise they have purpose. Because I work about 50hrs a week, I need to code signals that can work in a programmatically similar way to how you look at the charts... think "Okay, weekend signal down, no add alert indicator on the 240".

//------

question 1....... yes on both...... the peyton component was just specific to our prior question and yes absolutely the psar and such signals would have been better...... taking it further, now that the daily signals are lining up as sell , of which peytons is just one, will strengthen my resolve to sell the lower time frames or just to 'blast sell' the daily with limits and stops.......

question 2...... the sell limits are anticipating the next countertrend move up for that down leg..... not know how much the retrace will be, i often just cover the entire leg...... if it does not retrace, the limit orders were in vain..... yes those would have missed the prior move but the prior move probably had the same type orders placed on it...... they have just closed.....

question 3...... yes, its when the above timeframes signals are saying sell, and still young, i will sell the lower timeframes....... yes again, the 30 minute zigzag up would have been better...... that would involve placing stop orders below, again better...... so the zigzag up leg would be doubly better......

question 4...... yes...... you can calculate the average leg in both time and pips...... if you used that average, you would rarely be accurate unless you threw out the outliers in the data set...... i just use the average excepting that it might be a best guess......

so, i try to cover 100% of that best guess length with orders....... if you took those 240 legs and using the fibonaccia retracement tool, you see as a rule it retraces between the 25 and 75 % of the previous leg..... when placing the orders, if i feel in the next 5 hours it might move 100 pips, there is little point in placing more orders than that.....

i have a very large % of orders that never activate......

question 5.... there are some times i might add small amounts when it goes against me....... usually i just sit and wait it out...... unless it becomes clear i was wrong initially or due to some new event...... i have no problem taking a loss if i feel there will be a much better entry next week...... other than that, it's just a trade that took it's own sweet time......

question 5..... alma cross...... that was just a poor choice of words on my part...... alma color change is what i meant..... however, yes, i use the alma crossing the tsr as a signal, but that was not what was in my mind...... the alma tsr cross is the 4th in line in that chart i post often...... will post below...... its often black because i only count to 10...... over a 10 count its black and unseen.....

question 6..... this hard one because other factors are involved..... somewhere, i have a indicator that plots the current buy/sell status of probably 50 different indicators bar by bar in a single chart with each indicator in it's own row.......... there were 3 reasons for this.....

first, to see which indicators reacted first and which reacted last......

second, to visually see the chart swing from red to lime.....

third to sum all and apply a moving average..... a super macd of sorts......

out of the best 10, peytons indicator would probably be a 5...... just a guess.....

so yes, i will sell or buy 'preempting' peyton's signal....... if the jjma, jfatl, alma and the like say to.......

question 7...... the zigzag on million dollar account...... when i said that it was specifically talking about placing trades 5, 10 or 20 pips apart to cover the daily zigzags fully retrace..... the potential drawdown would be immense..... the reward could be equal...... but it's not me......

i can afford to cover the 15 and 30 minute zigzag legs, and occasionally the daily atr with maybe 10 orders....... and keep in mind my orders are small......

question 8..... yes, i would have enter above also and probably 5 more times in between..... those trades have closed..... all you see is the latest batch......

question 9...... yes, if i understand you correctly...... no timeframe scares me, even the yearly....... but when it comes to entry resolution, meaning filling a period of time with trades, my size orders and accounts must use the lower timeframes to fine tune the worst entry...... the use of the grid type placement just allows me to cover what i feel could be the maximum retrace movement before it resumes prior direction...... in a best guess method......

does it matter much, maybe not....... you might just as well place 0.01 orders spaced 5 pips apart up and down..... several pairs are game for that right now...... i've done that many times before.....


good questions btw,,,,,,h
 

hayseed

Master Trader
Jul 27, 2010
1,013
258
149
usa
here is an experiment preferably with a demo account.......

starting right now, find a pair using the monthly chart where you would feel comfortable placing 0.01 lot limits and stops across 800 pips spaced 10 pips apart......

with an initial 2 mini lot order at market...... total maximum combined lots, 1 standard lot.......

what pair would you choose....... and why......

calculate total maximum margin required,...... maximum loss and maximum gain between now and next friday....

i have mine....... orders are placed......

my max margin required is 1386...... max loss is 500...... max gain is 500......

last item...... can you hold for 1 month.......h
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
here is an experiment preferably with a demo account.......

starting right now, find a pair using the monthly chart where you would feel comfortable placing 0.01 lot limits and stops across 800 pips spaced 10 pips apart......

with an initial 2 mini lot order at market...... total maximum combined lots, 1 standard lot.......

what pair would you choose....... and why......

calculate total maximum margin required,...... maximum loss and maximum gain between now and next friday....

i have mine....... orders are placed......

my max margin required is 1386...... max loss is 500...... max gain is 500......

last item...... can you hold for 1 month.......h
One question:

Would that be spread 800 pips, evenly split in limits and stops?
 

hayseed

Master Trader
Jul 27, 2010
1,013
258
149
usa
One question:

Would that be spread 800 pips, evenly split in limits and stops?
//-----

your choice..... but there is a point to this.....
//------

when looking back at orders and the zigzag, it's hard to know just where the zigzag stood when you placed the orders back then...... the macd, ao, alma and such never change but the zigzag seldom sits still......

there was a time when the last thing done by most of my buy/sell scripts was to take a screenshot..... this way the zigzag was correctly seen as to that exact time..... where days later the zigzag might pass through that point in it's ever repainting journey...... metatraders screenshot pictures are saved in the metatrader files folder.....

so, when looking at the picture below, just try to imagine the zigzag being at the batch of potential retrace orders being sent.....

the script used here is the history script which places the lines start to finish for each order and totals the results on right side.......

historical things like this were used in an attempt to fine tune entrys......

doesn't take long to see the real problem...... and i had the red face to prove it.....h
//-----
euraud-m30-oanda-division1-history.png
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
Note: just realize this didn’t post yesterday evening. Did ups also mean to put profit targets?

I did of 50 pips but not I don’t know if that was in your plan.

Hayseed... Two top candidates... no clue which is best or if I am even close... AUDNZD and GBPAUD seem to have the freshest Monthly signals... the latter with the largest ATR...

1652678289030.png

Looking at my WPR indicator, It looks like the Aussie has increased in strength and maintained a stronger presence over the last 26 weeks than the NZD and GBP both. the GBP has maintained its position as weakest currency. This would give me confidence in selling GBPAUD

1652678729819.png

When I look at the ZZ, AUDNZD looks less appetizing. ZZ is longer (candles wise), and an obvious range has presented itself. the GBPAUD however... the ZZ is only 3 bars in duration... and not very long as far as pip difference either. This give me the idea that this is the best play overall...
1652678887484.png


was I even close? I don't know if my stepthrough was the proper analysis to answer exactly what you mentioned. As far as profit next week, I am not sure. I know GBPAUD has 434 pip weekly atr average, so that would get me close to that $500 mark including the .2 lot
 

hayseed

Master Trader
Jul 27, 2010
1,013
258
149
usa
Did ups also mean to put profit targets?
//-----

there really is not a right or wrong choice...... the margin required for gbp pairs is high...... but the gbpaud is a good choice most likely.... it can have some really wild weeks so hold onto your boot straps......

my choice was selling the audusd...... reasons were, 1$ a pip, low margin required, low monthly counts, usd cross, and positioned for a multi day retrace against me.... and some other contributing factors....

my profit target is 1000$......h
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
Does this mean that you have no official PT, and you simply plan to close the trade when you’ve earned $1000?
 

hayseed

Master Trader
Jul 27, 2010
1,013
258
149
usa
Does this mean that you have no official PT, and you simply plan to close the trade when you’ve earned $1000?
//----

well we can leave it at that...... true target is considerably more...... prefer to aim low......

below is an example of covering a potential 30 minute zigzag retrace.... they just closed..... about 100$ because there was a 0.15 order in the group.... like normal, the top orders did not activate and will be deleted.....

if you did a quick check using the fib tool you'll see the logic here...... at some point in time i possibly will reenter in the same fashion....

i'm getting leery of the eurcad because of it's length...... at some point the 240 will retrace..... the drawdown potential would be in the 100's...... that in no way would concern me, but it's not a wise practice normally......

i said normally because that other account with only audusd has a drawdown potential of maybe 1000$...... that is a good thing...... i want that.......

the larger drawdown there, the more the audusd only account will make in a shorter period of time with less risk of giving it all back......

drawdown in this case is a positive..... subject to change......h

//------

eurcad-m30-oanda-division1-covered-30.png
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
More questions (if you can imagine that):

First, I don’t get the last point you made.

I’ll assume you put your 800 pip order at an even spread, 400 limits and 400 stops. If it goes against you immediately, that will activate your limit orders, which enhances profit potential IF IT MAKES IT ALL THE WAY BACK. so why exactly do you say it will make more in less time?

If price goes against you for all 400 limits, doesn’t that double the time needed to hit 1:1, and even more so increase the time to close all orders?

2) and I apologize for beating this up, but I think I’m confused by the mentality behind the order you depicted on the above 30min ZZ and the min-wage.

Do you use the single PT (end of ZZ) when you decide to make every trade the same lot size? And use distinct Profit Levels when you use distinct lot sizes?
 

hayseed

Master Trader
Jul 27, 2010
1,013
258
149
usa
More questions (if you can imagine that):

First, I don’t get the last point you made.

I’ll assume you put your 800 pip order at an even spread, 400 limits and 400 stops. If it goes against you immediately, that will activate your limit orders, which enhances profit potential IF IT MAKES IT ALL THE WAY BACK. so why exactly do you say it will make more in less time?

If price goes against you for all 400 limits, doesn’t that double the time needed to hit 1:1, and even more so increase the time to close all orders?

2) and I apologize for beating this up, but I think I’m confused by the mentality behind the order you depicted on the above 30min ZZ and the min-wage.

Do you use the single PT (end of ZZ) when you decide to make every trade the same lot size? And use distinct Profit Levels when you use distinct lot sizes?
//-----

i usually put 2 limits for every stop, so my 800 split would not be even.....

part of your assumption is correct...... the rough average audusd 43200 atr is about 300 pips...... so we can plod along the downtrend line for a month and might make 300 with 1 minilot..... that would be a fantastic trade....... here we would only benefit from the part of the atr that favored our initial trades direction......

or, the audusd might spike against 400 pips tonite then fall back and we will have made much more...... in a single night..... with the rest of the months ramblin down the trend line.... so i'm making money on the full atr, not just the part of the atr which favors my initial trades direction......

i never think in terms of 1:1, ..... i can not see the value in them......

i don't know how to explain using the fibonaccia retracement levels any clearer.....

sometimes i will use different sized orders for a single reason only, that being oanda's refusal to allow targets on same sized orders...... so my choices are , no targets or different sized orders with targets.....

if oanda would cancel that rule, 99% of my orders would be 0.02 or less...... my preference is 0.01.......

we now have a 240 audusd zigzag up leg......h
//------

audusd-h4-oanda-division1-240-fib.png
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
i don't know how to explain using the fibonaccia retracement levels any clearer.....
I hope I’ve not struck offense! I do see the wave like entry method. You win until you don’t, and if you’re watching the charts closely enough, you’ll certainly make more than enough with the meat of a move such that the few times you don’t win won’t kill ya.

The crux of my question I suppose is do you think there’s a better way one way or the other.

In the US, due to FIFO, if you place a dozen .01 lot orders, the have to close in order, or simply all at once.

If you stagger the sizes, you get to select your own target.

I get this.

I am simply curious if there is a particular method you prefer to run with.

Your comment about staying under .02 certainly does answer that in a big way.

As I mentioned a while ago, I will be coding my triggers so I can know when to check the charts.

Once I do, it will have to be one of two methods:

Cast a net of pending orders.

Or (like with the 240zz up), once a new leg prints, set an EA to open on the next Alma change, JJMA change, etc. in other words, the ZZ is primed, the signal is the trigger.

Because I will likely go hours without checking, I just want to have peace of mind that the trade exit method (fixed targets with different lots or one profit target with .01 lots) is the best choice.

I am overly analytical, so I certainly do get tripped up in the details.

I suppose when I see your trade explorers, I see what thousands say will never happen become a reality - to beat the market. I’ve never get closer to simply being consistent…. And I haven’t even started demo trading yet due to so heavily analyzing what steps I follow.

If I can double an account with .01, I’ll have beaten your first test.

I just ask so many questions because since trading is part time, and my mind is on my work, I want to see my positive results (or negative) and know WHY.

In the past I find myself simply saying “yea that ZZ is longer than average, here’s a bunch of pending orders. Then a day goes by and I am $100 up on a $10k demo. In real life, I wouldn’t want $100 to slip away. In the demo it’s 1%. But because I didn’t (don’t) have a set system, I have to scope for that $100. So I can’t tell if that’s good bad or otherwise.

That’s what I am trying to break and make sure I actually have a system before I go to demo.

Believe it or not, I’ve actually lost less then 3 digits on FX, purely for the fact that I am a fully believer that if you cannot win in Demo good luck with real money.
 

hayseed

Master Trader
Jul 27, 2010
1,013
258
149
usa
If I can double an account with .01, I’ll have beaten your first test.
//-----

twice...... once might be just luck..... so do it twice.....

of course no offense..... it's simply i have no better way to explain it...... with the exception of the 800 trades...... which might take a couple months......

i have no true preferences other than trading with the trend and 0.01 lots..... the stop and limit orders are nothing more than my way of placing trades in advance...... i'm far to busy to trade otherwise.....

just small orders placed in advance....h.
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
Hayseed - off the wall question for you…

Do you/did you code at all for work? Or did you exclusively pick it up for Forex trading?
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
hayseed,

another coding question, if you will. My dashboards seem to freeze up my PC or run VERY slowly. They are similar in form and function to yours. They consist of rows iterated one after the other, with OBJ_PROP's and color's determined based on a series of bool tests (if [0] >[1], color = clrAqua)...

If the program all out freezes, I find it is usually an error in the code. But we are still talking a few minutes before the dashboard finalizes.

Just curious if there are any keys to keeping these dashboards running a lot more smoothly then mine are.
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
Well, turns out I can speed up a lot if every single indicator doesn't pull data from EVERY BAR when it is only necessary to capture the largest "period" or indicator length to have a quality reading... lol
 

hayseed

Master Trader
Jul 27, 2010
1,013
258
149
usa
Well, turns out I can speed up a lot if every single indicator doesn't pull data from EVERY BAR when it is only necessary to capture the largest "period" or indicator length to have a quality reading... lol
//----

most of mine are scripts so they just run once.... the pair or timeframe doesn't matter.... some do load slow but the math requires it....

if yours are multitime frame and not scripts, it's sometime best to run each timeframe once on it's new bar..... such as if your ea/indicator dashboard is attached to the 15 minute chart , only run the daily at the new daily bar.... no point in loading down the computer on every tick when the weekly value won't change anytime soon.....

exceptions would be like psar or pivots.....

you can use the function GetTickCount() to track down which particular indicator causing stress...... the 2 and 3 pole butterworth filters are terrible on load...... as is schaff trend sometimes.....h
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
//----

well we can leave it at that...... true target is considerably more...... prefer to aim low......

below is an example of covering a potential 30 minute zigzag retrace.... they just closed..... about 100$ because there was a 0.15 order in the group.... like normal, the top orders did not activate and will be deleted.....

if you did a quick check using the fib tool you'll see the logic here...... at some point in time i possibly will reenter in the same fashion....

i'm getting leery of the eurcad because of it's length...... at some point the 240 will retrace..... the drawdown potential would be in the 100's...... that in no way would concern me, but it's not a wise practice normally......

i said normally because that other account with only audusd has a drawdown potential of maybe 1000$...... that is a good thing...... i want that.......

the larger drawdown there, the more the audusd only account will make in a shorter period of time with less risk of giving it all back......

drawdown in this case is a positive..... subject to change......h

//------

eurcad-m30-oanda-division1-covered-30.png
Hayseed,

I hate to harp on this message. But I really want to get it. The process, I do get. Your limits are captured in the retracement.

Because of my lack of experience, my gut reaction says “what if it just shoots up”. Well, I think I know your answer… who cares when it’s only .01 lots. That’s the joy of small trades. So I would have to, in my system, be okay with that, or create another exit criteria I can live with. This leads me to some more questions:

1) in the trade pictured above, did you just set a PT at the bottom of the ZZ leg? Or was there a trigger? I know this isn’t the most pressing consideration, but I’m curious.

2) do you have a preference between set PT’s for each trade vs a common PT for a series of trades? For example, “Next Weeks Trades” I believe you mentioned setting 50 pips PT per trade. However, the trade above show a common target that closed all trades. Do you choose one over the other, and do you see one as more superior? Also, I do understand the US FIFO rules. I understand that may be a factor, but I still would love to know.

3) grids vs plotting a trade - have you always set grids? Do you ever set a trade if a single lot to play out?

4) how do you analyze and asses the different zz lengths between 75,12, and 5? I’ve seen you use and mention all, but I’d love to know what’s going through your kind when you’re looking at them. When you are going to risk capital with a grid of limits, are hedging your bets on any of the three, or, for example, is it the 12 that you prefer? I’ve made an indicator that forecasts the next leg once the current leg has exceeded its average length. It’s pretty neat actually, but like with any indicator, to many graphics and you have a lot of noise.

Again, apologies for the interrogation. I am going to make my goal for the back half of this year to double a $3000 acct with .01 lots.

Even though I have to use FIFO, it seems demo accounts don’t make me abide by it. So, I am going to have to adjust my system accordingly to ensure my results are realistic.

Just trying to sort out all of the factors other than the system itself that will lend itself to my success.

I know not many can consistently pull profits from the market as you do. However, when I see your results, it’s definitely inspiring. I desire more than anything to replicate your successes.
 
Last edited:

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
On another note, to the indicator I mentioned....

What do you think? I am sure you will quickly get the gist of what this is meant to do. I am sure the code could be cleaner, of that I have no doubt. However, I would love your feedback on functionality, and whether you see this as a value add? If not, I am curious as to what you would add to make this something useful to your style of trading.

Once the ZZ exceeds expected length, it will project estimated leg in the opposite direction. The width is based on average duration of the given leg. One bug is if the zz never exceeds length, but greatly exceeds duration, the box will remain in the past until there is a new leg. I personally don't mind this, as it helps me see the leg is stale. Don't even know if that matters, but a thought.
 

Attachments

  • Pairs_TFsetup.mqh
    1.6 KB · Views: 9
  • zigzags.mqh
    19.3 KB · Views: 10
  • ZZDrawZones.mq4
    16.9 KB · Views: 11
  • ZZDrawZones.ex4
    56 KB · Views: 7