If the indicator has 5 digits after the comma, use normalize double and reduce it to 4 digits. It can even be reduced to 3 or 2 digits. It will reduce the thinness. The choice is up to you. and compare it with the previous value. to do this you will need to increase the shift value in the icustom call. NormalizeDouble( iCustom( **HullMA Parameter vs . , 1 //Shift ) , 4) > NormalizeDouble( iCustom(**HullMA Parameter , 2 //Shift ) , 4) . If the data type open is to be used, the shift values will be 0 and 1, respectively. That way it doesn't repaint . You can do it this way in the simplest way. Please check !!!
Sorry,
But that is not working.
Is there a way that the code can remember that one trade was open and not to open another trade until the next trend change?
Yes, you write your code to do that. You save that state in a variable and refer to it before placing the order. And reset the variable when the signal direction changes. Use either a globally scoped variable or a static variable to keep track of that.
Alternatively, only react to the signal when it is in a different direction to the previous signal, or it has been reset in accordance with your strategy rules.
You are looking at a signal. Act on a change of signal.
Too many orders - MQL4 programming forum #1 (2017)
MQL4 (in Strategy Tester) - double testing of entry conditions - MQL4 programming forum #1 (2017)
Yes, you write your code to do that. You save that state in a variable and refer to it before placing the order. And reset the variable when the signal direction changes. Use either a globally scoped variable or a static variable to keep track of that.
Alternatively, only react to the signal when it is in a different direction to the previous signal, or it has been reset in accordance with your strategy rules.
Thank you Fernando,
I know the theory, but what is the best practice (code wise...)?
I can do :
if HMA_candle(1) > HMA_Candle(2) so it indicate that trend changed but also it show the trend continue...
I need to single out that one point where the trend has changed open a position and after the position closed not to open a new one until the trend will change again
You are looking at a signal. Act on a change of signal.
Too many orders - MQL4 programming forum #1 (2017)
MQL4 (in Strategy Tester) - double testing of entry conditions - MQL4 programming forum #1 (2017)
Hey William,
I will definitely check these out...
Thank you.
Hello all,
Need help in my EA.
I'm trying to take only one trade if hull indicator change the trend slope.
I've manage to make position open but when a position close another one immediately opens and I don't want that.
I don't know how or what is best practice to do so.
If anyone know any reference article/code sample it will be much helpful.
Any advice will be much appreciated.
Thanks all.
Thank you Fernando,
I know the theory, but what is the best practice (code wise...)?
I can do :
if HMA_candle(1) > HMA_Candle(2) so it indicate that trend changed but also it show the trend continue...
I need to single out that one point where the trend has changed open a position and after the position closed not to open a new one until the trend will change again
Computers can't read minds, right? You need to tell the computer what the trend change is. I am posting a very short picture and a very simple example for you to understand the logic. also if you have an open order, you should tell the computer that you have an open order and not to place a new order.
Hull_Shift_1 = İcustom( , 1) Hull_Shift_2 = icustom( , 2) Hull_Shift_3 = icustom( , 3) if ( Hull_Shift_1 < Hull_Shift_2 && Hull_Shift_2 > Hull_Shift_3 ) { TrendDown = true ; }
Thank you Fernando,
I know the theory, but what is the best practice (code wise...)?
I can do :
if HMA_candle(1) > HMA_Candle(2) so it indicate that trend changed but also it show the trend continue...
I need to single out that one point where the trend has changed open a position and after the position closed not to open a new one until the trend will change again
int OrdersCounterBuy() { int result=0; for(int i=0;i<OrdersTotal();i++) { OrderSelect(i,SELECT_BY_POS ,MODE_TRADES); if (OrderType()== OP_BUY && OrderSymbol()== Symbol()) result++; } return (result); } int OrdersCounterSell() { int result=0; for(int i=0;i<OrdersTotal();i++) { OrderSelect(i,SELECT_BY_POS ,MODE_TRADES); if (OrderType()== OP_SELL && OrderSymbol()== Symbol()) result++; } return (result); } if(OrderCountSell == 0 && TrendDown == True ) { .........; }An old and simple code to check if there is an open order. Returns 0 if there are no open orders.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello all,
Need help in my EA.
I'm trying to take only one trade if hull indicator change the trend slope.
I've manage to make position open but when a position close another one immediately opens and I don't want that.
I don't know how or what is best practice to do so.
If anyone know any reference article/code sample it will be much helpful.
Any advice will be much appreciated.
Thanks all.