I am trying to write an EA to manage all my manually opened orders. Upon the appearance of a new bar an order needs to be closed if the close price of the bar just completed is less the EMA10 (in the case of buy orders), the opposite is true for sell orders. I was going to use the code below but will this work? Is the value in MODE_CLOSE the value I need? Since the new bar doesn't have a close yet I assumed the previous bar's value is stored?
Something I just realised as well - this doesn't specify a timeframe...I need to check H4 or D1 timeframe values depending on the order. Any help much appreciated!
This is wrong. In order to get previous bar close price use iClose() function, which accepts parameters pair, timeframe and shift (shift=1 in your case).
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to write an EA to manage all my manually opened orders. Upon the appearance of a new bar an order needs to be closed if the close price of the bar just completed is less the EMA10 (in the case of buy orders), the opposite is true for sell orders. I was going to use the code below but will this work? Is the value in MODE_CLOSE the value I need? Since the new bar doesn't have a close yet I assumed the previous bar's value is stored?
Something I just realised as well - this doesn't specify a timeframe...I need to check H4 or D1 timeframe values depending on the order. Any help much appreciated!