Hi, I'm new in this industrial. I have one error regrading the close order.
My EA is using indicator crossover to open an order, and my condition to close an order is when iClose is greater then indicator it will automatic close and order after the specific bar of candlestick closed.
But I having the error is the specific candlestick haven't close above (which still floating) the indicator it close automatically.
The picture attached below, the last candlestick didn't close above the the red line and it automatically close the order. my condition is the order will close after the candlestick close above the line and form a green-line instead red-line.
Or I need to place a RefreshRate(); in the code?
I think the problem comes from the fact that if shift is 0 in earlier condition or loop it will check Close[0] which is the current price while candle not closed. So I think you should check with that to start from candle [1] - Close[1] iCustom(....,1) which will not change while candle is still not closed.
topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.
I think the problem comes from the fact that if shift is 0 in earlier condition or loop it will check Close[0] which is the current price while candle not closed. So I think you should check with that to start from candle [1] - Close[1] iCustom(....,1) which will not change while candle is still not closed.
Yes, I have checked the Moving Average EA in the MetaTrader and I manage to solve the problem. Much appreciate your reply.
topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.
Sorry for any inconvenience because I when I registered it pop out the MQL5 community only. Where should I post could you kindly advice me on this?
Sorry for any inconvenience because I when I registered it pop out the MQL5 community only. Where should I post could you kindly advice me on this?
Click on Forum at the top of the page then click on the section that you want to read/post.
-
you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time post in the correct place. The moderators will likely move this thread there soon. -
double close_price_Main_Sub = iClose(NULL,0,shift); double Main_Trend = iCustom(NULL,0,…,shift); double Sub_Trend = iCustom(NULL,0,…
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum 2020.07.25
-
you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time post in the correct place. The moderators will likely move this thread there soon. -
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum 2020.07.25
Many thx on your reply and explanation and I manage to solve the problem.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I'm new in this industrial. I have one error regrading the close order.
My EA is using indicator crossover to open an order, and my condition to close an order is when iClose is greater then indicator it will automatic close and order after the specific bar of candlestick closed.
But I having the error is the specific candlestick haven't close above (which still floating) the indicator it close automatically.
The picture attached below, the last candlestick didn't close above the the red line and it automatically close the order. my condition is the order will close after the candlestick close above the line and form a green-line instead red-line.
Or I need to place a RefreshRate(); in the code?