Hi, thank you in advance for helping me. I'm new to this. what i want to do is when my ma cross in the 15 minutes the ea will go to another condition
which is wait for my another ma cross in the 5 minutes chart then the trade will be closed. my code is working if i only have 1 ma cross but if i need to wait for two ma crosses it doesnt. thank you, i really appreciate if you will help me with this. this is only for closing order as i enter my trade manually. thanks.
You have already been informed not to call OnTick() from within OnTick() ... Ontick inside void ontick()-manual trade is alrrady open
If this code was indeed generated by ChatGPT, then please know that we can't help you.
ChatGPT ?
You have already been informed not to call OnTick() from within OnTick() ... Ontick inside void ontick()-manual trade is alrrady open
If this code was indeed generated by ChatGPT, then please know that we can't help you.
Hi, thank you in advance for helping me. I'm new to this. what i want to do is when my ma cross in the 15 minutes the ea will go to another condition
which is wait for my another ma cross in the 5 minutes chart then the trade will be closed. my code is working if i only have 1 ma cross but if i need to wait for two ma crosses it doesnt. thank you, i really appreciate if you will help me with this. this is only for closing order as i enter my trade manually. thanks.
You are defining a conditions of "If "statement what is
OnTick()
Doing there.? Just remove it ..
After defining a conditions of "
Or close conditions..
if ((LastFastMovingAverage15 > LastSlowMovingAverage15)
&&(FastMovingAverage15 < SlowMovingAverage15))
You are defining a conditions of "If "statement what is
Doing there.? Just remove it ..
After defining a conditions of "
Or close conditions..
Thank you for your reply. after the if statement is another condition which is another ma cross. should i put another if statement and indent it after the first condition so the second condition when it is met will run?.
my concern is after the first condition and then if the code check the second condition and the condition is not yet met, the code might end or not wait for the second condition to happen. Thank you for your help. hope you can help me further. thanks.
Thank you for your reply. after the if statement is another condition which is another ma cross. should i put another if statement and indent it after the first condition so the second condition when it is met will run?.
my concern is after the first condition and then if the code check the second condition and the condition is not yet met, the code might end or not wait for the second condition to happen. Thank you for your help. hope you can help me further. thanks.
void OnTick() { //curent chart, current period, 20 candles,no shift, simple, close price double SlowMovingAverage15 = iMA(NULL, 15,20,0,MODE_EMA,PRICE_CLOSE,0); //curent chart, current period, 20 candles,no shift, simple, close price double LastSlowMovingAverage15 = iMA(NULL, 15,20,0,MODE_EMA,PRICE_CLOSE,1); //curent chart, current period, 10 candles,no shift, simple, close price double FastMovingAverage15 = iMA(NULL, 15,10,0,MODE_EMA,PRICE_CLOSE,0); //curent chart, current period, 10 candles,no shift, simple, close price double LastFastMovingAverage15 = iMA(NULL, 15,10,0,MODE_EMA,PRICE_CLOSE,1); //curent chart, current period, 20 candles,no shift, simple, close price double SlowMovingAverage = iMA(NULL, 5,20,0,MODE_EMA,PRICE_CLOSE,0); //curent chart, current period, 20 candles,no shift, simple, close price double LastSlowMovingAverage = iMA(NULL, 5,20,0,MODE_EMA,PRICE_CLOSE,1); //curent chart, current period, 10 candles,no shift, simple, close price double FastMovingAverage = iMA(NULL, 5,10,0,MODE_EMA,PRICE_CLOSE,0); //curent chart, current period, 10 candles,no shift, simple, close price double LastFastMovingAverage = iMA(NULL, 5,10,0,MODE_EMA,PRICE_CLOSE,1); for (int i= OrdersTotal(); i>=0; i--) { if (OrderSelect(i = 0, SELECT_BY_POS)== true) //if (OrderSymbol() == Symbol())//if fastMovingAverage is above if ((LastFastMovingAverage15 < LastSlowMovingAverage15) &&(FastMovingAverage15 > SlowMovingAverage15)) { if ((LastFastMovingAverage > LastSlowMovingAverage) &&(FastMovingAverage < SlowMovingAverage))OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 0, Green ); } } //---------------------------------------------------------------------------------------------------------- for (int c= OrdersTotal(); c>=0; c--) { if (OrderSelect(c = 0, SELECT_BY_POS)== true) //if (OrderSymbol() == Symbol())//if FastMovingAverage is below if ((LastFastMovingAverage15 > LastSlowMovingAverage15) &&(FastMovingAverage15 < SlowMovingAverage15)) { if ((LastFastMovingAverage < LastSlowMovingAverage) &&(FastMovingAverage > SlowMovingAverage))OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 0, Red ); } } }
whatever you want to code you are right but your code is not properly organize...
1. state order type is your EA closing "buy order" or "sell order" cause with this your code the EA will closing anything it sees.
if(OrderType()==OP_BUY) or if(OrderType()==OP_SELL) 2. check your loops on order, and organize it well
I'm not sure "15" will be understood as the 15 minute timeframe, you should use "PERIOD_M15" constant
for (int i= OrdersTotal(); i>=0; i--) { if (OrderSelect(i = 0, SELECT_BY_POS)== true) //if (OrderSymbol() == Symbol())
whatever you want to code you are right but your code is not properly organize...
1. state order type is your EA closing "buy order" or "sell order" cause with this your code the EA will closing anything it sees.
- 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, thank you in advance for helping me. I'm new to this. what i want to do is when my ma cross in the 15 minutes the ea will go to another condition
which is wait for my another ma cross in the 5 minutes chart then the trade will be closed. my code is working if i only have 1 ma cross but if i need to wait for two ma crosses it doesnt. thank you, i really appreciate if you will help me with this. this is only for closing order as i enter my trade manually. thanks.