I'm still learning how to code an EA but I face a challenge while doing it. Here's what I'm trying to achieve...
I want the code to open a trade only if there is no open trade during that specific candle. I do not mind having a new trade opened on every candle (multiple trades running at the same time) but there should not be more than 1 new trade opened per new candle. I tried looking into magic number but a magic number only prevents a double entry so the code below does not solve my problem.
I also tried time based restriction but this code only allow the EA to execute the code once per candle so this code also does not solve my problem.
Can someone help me with this problem? Please.
I want the code to open a trade only if there is no open trade during that specific candle. I do not mind having a new trade opened on every candle (multiple trades running at the same time) but there should not be more than 1 new trade opened per new candle. I tried looking into magic number but a magic number only prevents a double entry so the code below does not solve my problem.
Inserted Code
{ int openOrders = OrdersTotal(); for(int i = 0; i < openOrders; i++) { if(OrderSelect(i,SELECT_BY_POS)==true) { if(OrderMagicNumber() == magicNBforbuy) { return true; } } } return false; }
I also tried time based restriction but this code only allow the EA to execute the code once per candle so this code also does not solve my problem.
Inserted Code
{ static datetime saved_candle_time; if(Time[0]==saved_candle_time) return false; else saved_candle_time=Time[0]; return true; }
Can someone help me with this problem? Please.
Different/opposing ideas will make us learn and understand many things.