# Exact crossing code

2737

Hey community,

i have a small problem during EA generating. Its about crossing.

For example with moving average 5 and 10:

So a buy order would be if ma 5 crosses ma 10. (ma5>ma10=Open buy order)

BUT it also opens a buy order if the trend is running. It means that if i change for example lotsizes or something my ea opens a new order at next candle. (i had no open orders before). I have an function for "waiting till an opposite signal appears". And it works. But if i change lotsize or sl or something else, it opens a trade during the trend.

BUT i wanna programme the EA JUST to open an order IF CROSSING. So i can change lotsizes if there is no opened trend, and dont need to be afraid that the ea opens the next trade on next candle :/

Is there somebody who knows how to code it on the above mentioned example? I tried something like ma5>ma10 AND ma5<ma10=Open buy order.

But it doesnt work :D:D hahahaha

Moderator
32077

wienerschinken:

Hey community,

i have a small problem during EA generating. Its about crossing.

For example with moving average 5 and 10:

So a buy order would be if ma 5 crosses ma 10. (ma5>ma10=Open buy order)

BUT it also opens a buy order if the trend is running. It means that if i change for example lotsizes or something my ea opens a new order at next candle. (i had no open orders before). I have an function for "waiting till an opposite signal appears". And it works. But if i change lotsize or sl or something else, it opens a trade during the trend.

BUT i wanna programme the EA JUST to open an order IF CROSSING. So i can change lotsizes if there is no opened trend, and dont need to be afraid that the ea opens the next trade on next candle :/

Is there somebody who knows how to code it on the above mentioned example? I tried something like ma5>ma10 AND ma5<ma10=Open buy order.

But it doesnt work :D:D hahahaha

You need to check ma5 and ma10 values of 2 candles (say 1 and 2) : ma5[1]>ma10[1] and ma5[2]<ma10[2].
2737

angevoyageur:
You need to check ma5 and ma10 values of 2 candles (say 1 and 2) : ma5[1]>ma10[1] and ma5[2]<ma10[2].

damn it! It seems so logical :D haha. I will try it :)

many Thanks;)))

2737

Okay it works:) Thanks again :)
Moderator
32077

wienerschinken:
Okay it works:) Thanks again :)
You are welcome.