- MQL4 Help moving stop loss
- Average daily journey in points by instrument.
- Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6.
If by ticks you mean the dots that get plotted at each bar, then I would look to take a time when the Psar signal swaps and then use https://docs.mql4.com/series/iBarShift to count the bars back to your reference time. There is only 1 dot per bar. so it's the same thing. If you do mean ticks as per volume... then that's a different ball game.
Anyway, hope that helps
V
Yes! That's exactly what I'm talking about (the number of dots). I'll give that a shot and will post back if I have trouble.
Thanks!
If by ticks you mean the dots that get plotted at each bar, then I would look to take a time when the Psar signal swaps and then use https://docs.mql4.com/series/iBarShift to count the bars back to your reference time. There is only 1 dot per bar. so it's the same thing. If you do mean ticks as per volume... then that's a different ball game.
Anyway, hope that helps
V
Ok, could you please provide a suggestion how I could incorporate the iBarShift function to count the 'dots'.. I'm not sure how to combine it with the other functions. Thanks
I haven't tested it, but something like this should do it. There may be a cleaner way and I'm sure if there are better methods, people will chime in.
Anyway, hope this helps
V
int uptrend_length,downtrend_length; static datetime uptrend_time,downtrend_time; double psar=iSAR(NULL,0,0.02,0.2,0); if (psar<Bid) // take the time that bid is above psar. Variable will stop updating when condition swaps { uptrend_time=Time[0]; } if (psar>Bid) // take the time that bid is below psar. Variable will stop updating when condition swaps { downtrend_time=Time[0]; } if (uptrend_time >downtrend_time) // we are on an up trend which started at the last downtrend time { uptrend_length=iBarShift(NULL,0,downtrend_time); } if (uptrend_time <downtrend_time) // we are on a down trend which started at the last uptrend time { downtrend_length=iBarShift(NULL,0,uptrend_time); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use