Enums are not booleans, they have integers behind, so when you write:
if (Nb_positions<1 && BUY_OPEN)
MQL just checks if BUY_OPEN is zero or non-zero. Zero is false, any other value is true.
Your comparison should be something like this:
if (Nb_positions<1 && BUY_OPEN == LONG_KUMO_BREAKOUT) // or any other value depending on your strategy
Enums are not booleans, they have integers behind, so when you write:
MQL just checks if BUY_OPEN is zero or non-zero. Zero is false, any other value is true.
Your comparison should be something like this:
Ok, this is probably the reason why I don't the result I was expecting.
The problem with your suggestion is that I can't change the condition in the "Input" tab of the strategy tester , right ?
If so, how can I proceed to be able to change the opening condition in the strategy tester ?
Ok, this is probably the reason why I don't the result I was expecting.
The problem with your suggestion is that I can't change the condition in the "Input" tab of the strategy tester , right ?
If so, how can I proceed to be able to change the opening condition in the strategy tester ?
My suggestion has nothing to do with input parameters, it's about a way you do comparison in your program.
I have no idea why do you have problems with changing input parameters, but it is definitely not because of the change in code.
Here's a dummy EA where I copied your enums and input variables:
enum Open_buy_position { LONG_KUMO_BREAKOUT, // Kumo Breakout (buy) LONG_KIJUN_BREAKOUT, // Kijun Breakout (buy) LONG_TENKAN_KIJUN_CO, // Tenkan & Kijun crossover (buy) OP_LONG1, OP_LONG2 }; enum Open_sell_position { SHORT_KUMO_BREAKOUT, // Kumo Breakout (sell) SHORT_KIJUN_BREAKOUT, // Kijun Breakout (sell) SHORT_TENKAN_KIJUN_CO, // Tenkan & Kijun crossover (sell) OP_SHORT1, OP_SHORT2 }; enum Close_buy_position { CL_LONG1, CL_LONG2, CL_LONG3 }; enum Close_sell_position { CL_SHORT1, CL_SHORT2, CL_SHORT3 }; //--------------------------------- input Open_buy_position BUY_OPEN=OP_LONG2; input Open_sell_position SELL_OPEN=OP_SHORT2; input Close_buy_position BUY_CLOSE=CL_LONG2; input Close_sell_position SELL_CLOSE=CL_SHORT2; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+
I can change values in the tester:
- 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,
I'm currently working on a Ichimoku EA and I'm struggling with the possible conditions for opening a position.
I would like to know WHY when the EA is checking for the condition "BUY_OPEN" or "SELL_OPEN"
It does NOT take into account the "Open_buy_position" input to know which condition needs to be checked:
input Open_buy_position BUY_OPEN=OP_LONG2;
It works only if it's hard coded like below but it isn't what I'm looking for...
Here is a part of EA code: