How are you doing? Hope you are doing well.
I have coded an EA to trade in H4 periods. I'm having an issue and I can't solve it, even if I've been trying it since a lot of time.
This is the issue:
The EA is NOT opening or closing the orders when the H4 bar is closed. I need the EA to open or close the orders when the opening or closing conditions are true, and the H4 bar is closed.
I have been truying by using the "iClose" function, but is not functioning.
Your help will be appreciated.
There are many reasons of this issue !.
You need to show your code to understand what is going on, otherwise, no one can help you.
Thanks for advising me this.
I'll erase all the commented code so it can be more understandable, and I'll be showing it.
iClose() is returning the close price, not closing an order
Returns Close price value for
the bar of specified symbol with timeframe and shift.
double iClose( string symbol, // symbol int timeframe, // timeframe int shift // shift
name. NULL means the current
Timeframe. It can be any of ENUM_TIMEFRAMES enumeration values. 0 means the
current chart timeframe.
of the value taken from the indicator buffer (shift relative to the current bar
the given amount of periods ago).
Close price value for the
bar of specified symbol with timeframe and shift. If local history is empty (not
loaded), function returns 0. To check errors, one has to call the GetLastError() function.
For the current chart,
the information about close prices is in the Close predefined array.
Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,0),", ", iOpen("USDCHF",PERIOD_H1,0),", ", iHigh("USDCHF",PERIOD_H1,0),", ", iLow("USDCHF",PERIOD_H1,0),", ", iClose("USDCHF",PERIOD_H1,0),", ", iVolume("USDCHF",PERIOD_H1,0));
1) create global variable
2) in init write
3) in OnTick() where you need code once a bar write
Thanks for your response.
I know that iClose returns the close price. I use it to verify if the long entry conditions are true.
As I said before, below you can see the EA's code and how the iClose is being used to set the conditions when an order is opened.
I hope that this can clarify the issue.
Thanks in advance for your opinions!
Forum on trading, automated trading systems and testing trading strategies
Please use the SRC button when you post code. Thank you.
This time, I edited it for you.