We have no information about your
allow_buy
and
ConditionsMetForBuyTrade
Very probably, in one of them there is a condition that cannot be true together with price below the MA.
sorry nevermind, I realized that the boolean conditions were going false too soon, and true for only a split second, so I have it working now and to get it working I made the boolean variables static and applied state management this way:
static bool ConditionsMetForBuyTrade = false; static bool ConditionsMetForSellTrade = false; if(bullTrend[0] == 1 && bullTrend[1] == 1 && bullTrend[2] == 0 && bullTrend[3] == 0){ ConditionsMetForBuyTrade = true; ConditionsMetForSellTrade = false; } if(bearTrend[0] == 1 && bearTrend[1] == 1 && bearTrend[2] == 0 && bearTrend[3] == 0){ ConditionsMetForBuyTrade = false; ConditionsMetForSellTrade = true; }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I wanted to see if it was possible to make the EA enter a buy position only when the ask price is less than or equal to the moving average price.
Full snippet:
I set the MA buffer as series so that index 0 should reference the MA price at the current bar:
But the result is that no trades are being placed when I apply this logic to the condition:
If I simply take this line out of the condition...the EA will successfully place the buy trade, but it will do it at the random available ask price