- [ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4.
- EA opening multiple trades after a condition is met
- Need Help How to make the EA to filter Maximum allowed pair to trade based on Equity draw down
Hello, My code is opening and closing trades as long as indicator1 > indicator2. I want to make it trade only once, in the beggining, when the conditions are met. Then wait for the conditions to be different, and when they are met again, it should start trading again. Please help me with this.
I have already made a max order function. My point is different. It should trade only once per indication. Currently when the trade is closed it opens another trade, because the conditions are still met. This should not happen.
Here is what I tried:
int TradedSell = False; if ((TradedSell == False) && (indicator1 < indicator2)) { if (total < MaxOrders || MaxOrders == 0){ ticket_sell=OrderSend(Symbol(),OP_SELL,volume_weak,Bid,slippage,Bid+StopLoss*Point, Bid-TakeProfit*Point,comment,magic,0,arrow_colorSell); return (ticket_sell); TradedSell = True; } } if ((TradedSell == True) && (indicator1 > indicator2)) { TradedSell = False; }
I have already made a max order function. My point is different. It should trade only once per indication. Currently when the trade is closed it opens another trade, because the conditions are still met. This should not happen.
RaptorUK:
What should happen if the trading condition becomes unset and then shortly after the same condition become set again ? would that mean another trade should be opened ? if not why not ? what condition means that a trade should not be opened ? answer these questions and your code will be closer to being done.
What should happen if the trading condition becomes unset and then shortly after the same condition become set again ?
- Well, maybe, there has to be a few points difference in the indicators. Or some other way of getting around this. I have to think about it. If the condition is met again after a few bars, yes, it should open another trade.
what condition means that a trade should not be opened ?
- indicator1 > indicator2
What should happen if the trading condition becomes unset and then shortly after the same condition become set again ?
- Well, maybe, there has to be a few points difference in the indicators. Or some other way of getting around this. I have to think about it. If the condition is met again after a few bars, yes, it should open another trade.
what condition means that a trade should not be opened ?
- indicator1 > indicator2
:( Here is the code, and it`s not working. Maybe I`m doing something wrong. bool TradeBuy and bool TradeSell are before the init and start, so it`s not setting them true on every tick.
bool TradeBuy = True; bool TradeSell = True; if ((TradeBuy == True) && (Buy == True) && (TMA1 > ichiSpanA) && (TMA2 > ichiSpanA) && (TMA3 > ichiSpanA) && (TMA1 > ichiSpanB) && (TMA2 > ichiSpanB) && (TMA3 > ichiSpanB)) { if (total < MaxOrders || MaxOrders == 0) { ticket_buy=OrderSend(Symbol(),OP_BUY,volume_weak,Ask,slippage,Ask-StopLoss*Point, Ask+TakeProfit*Point,comment,magic,0,arrow_colorBuy); PlaySound("alert.wav"); return (ticket_buy); TradeBuy = False; return (TradeBuy); } } if ((TradeBuy == False) && (TMA2 < ichiSpanA) && (TMA2 < ichiSpanB)) { TradeBuy = True; return (TradeBuy); } if ((TradeSell == True) && (Sell == True) && (TMA1 < ichiSpanA) && (TMA2 < ichiSpanA) && (TMA3 < ichiSpanA) && (TMA1 < ichiSpanB) && (TMA2 < ichiSpanB) && (TMA3 < ichiSpanB)) { if (total < MaxOrders || MaxOrders == 0){ ticket_sell=OrderSend(Symbol(),OP_SELL,volume_weak,Bid,slippage,Bid+StopLoss*Point, Bid-TakeProfit*Point,comment,magic,0,arrow_colorSell); PlaySound("alert.wav"); return (ticket_sell); TradeSell = False; return (TradeSell); } } if ((TradeSell == False) && (TMA3 > ichiSpanA) && (TMA3 > ichiSpanB)) { TradeSell = True; return (TradeSell); }
:( Here is the code, and it`s not working. Maybe I`m doing something wrong. bool TradeBuy and bool TradeSell are before the init and start, so it`s not setting them true on every tick.
You return (ticket_buy) so the 2 lines of code after that will never run.
return (ticket_buy); TradeBuy = False; return (TradeBuy);
Hello, my code is opening and closing trades as long as indicator1 > indicator2. I want to make it trade only once, in the beggining, when the conditions are met. Then wait for the conditions to be different, and when they are met again, it should start trading again. Please help me with this.
You should to check the opening and closing condition of trade. It will help to You in business market.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use