Hi all,
Since nobody has stepped into help me with my EA design without furnishing funds, I have decided to continue my own amazing coding!
Can someone help me figure out a riddle in mt4 on how to do a certain task?
The task is:
How can I change my code so that it will enter a stop order 'x' pips away from current price without entering it 10,000 times everytime it hits that price again and again.
If price moves 15 pips long, enter long stop 15 pips away (ONCE!).
Any help with logic is greatly appreciated!!!
Here is my code that enters 30,000 orders... Brokers would love this.
-----Please focus on the 'for existing trades' section.
Since nobody has stepped into help me with my EA design without furnishing funds, I have decided to continue my own amazing coding!
Can someone help me figure out a riddle in mt4 on how to do a certain task?
The task is:
How can I change my code so that it will enter a stop order 'x' pips away from current price without entering it 10,000 times everytime it hits that price again and again.
If price moves 15 pips long, enter long stop 15 pips away (ONCE!).
Any help with logic is greatly appreciated!!!
Here is my code that enters 30,000 orders... Brokers would love this.
-----Please focus on the 'for existing trades' section.
Inserted Code
if(int NoOrdersYet; NoOrdersYet < 1) { OrderSend(Symbol(), 4, LotSize, (Ask+(OrderDistance*Point)), Slippage, StopLoss ,TakeProfit ,"First Long", MagicNumber, 0, ArrowColor); //Sends first long OrderSend(Symbol(), 5, LotSize, (Bid-(OrderDistance*Point)), Slippage, StopLoss ,TakeProfit ,"First Short", MagicNumber, 0, ArrowColor); //Sends first short NoOrdersYet++; } //For existing trades for (int x = 0; x < OrdersTotal(); x++) { if (OrderSelect(x,SELECT_BY_POS,MODE_TRADES)) { if ((OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber)) { if (OrderType()==OP_BUY) { if(OrderOpenPrice() <= (Ask+(OrderDistance*Point))) { OrderSend(Symbol(), 4, LotSize, (Ask+OrderDistance*Point), Slippage, StopLoss , TakeProfit ,"Next Entry Long", MagicNumber, 0,ArrowColor); LastLongOpenPrice = OrderOpenPrice(); } if(OrderOpenPrice() > (Ask + ((OrderDistance*2)*Point))) { OrderSend(Symbol(), 4, LotSize, (Ask+OrderDistance*Point), Slippage, StopLoss , TakeProfit ,"Retrace Entry Short", MagicNumber, 0,ArrowColor); LastLongOpenPrice = OrderOpenPrice(); } //NumberLongPendingOrders++; } else if (OrderType()==OP_SELL) { if(OrderOpenPrice() == (Bid*(OrderDistance*Point))) { OrderSend(Symbol(), 4, LotSize, (Bid+OrderDistance*Point), Slippage, StopLoss , TakeProfit ,"Next Entry Long", MagicNumber, 0,ArrowColor); LastShortOpenPrice = OrderOpenPrice(); } if(OrderOpenPrice() < (Bid + ((OrderDistance*2)*Point))) { OrderSend(Symbol(), 4, LotSize, (Bid+OrderDistance*Point), Slippage, StopLoss , TakeProfit ,"Retrace Entry Short", MagicNumber, 0,ArrowColor); LastShortOpenPrice = OrderOpenPrice(); } } //Clearing out orders further than 100 pips ---DOESN'T SEEM TO WORK /*else if (OrderType() == 4 && OrderOpenPrice() >= (Ask + (MaximumPipsPending*Point))) { OrderDelete(OrderTicket()); } else if (OrderType() == 5 && OrderOpenPrice() <= (Bid + (MaximumPipsPending*Point))) { OrderDelete(OrderTicket()); }*/ } } }
We are our own best indicator.