Any ideas on this guys?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi guys I need some help please I am having a hard time getting the grid to replace pending orders if they are turned into market orders...
have a look :
1: This is how I get it to place 6 pending buys and 6 pending sells above and below a set range size that is able to be changed externally :
extern int Interval = 8;
extern int Range = 12;
total=OrdersTotal();
if(total<1)
{
Temp=MarketInfo(Pair, MODE_BID);
for (int Cnt=1;Cnt<=NormalizeDouble((Range/2),0);Cnt++)
{
OrdSend(Pair, OP_BUYSTOP, Lot, Temp+(Cnt*Interval*point()), 0, Temp+(Cnt*Interval*point())-SL*point(),0, CommOrder, Cnt*Magic, 0, Blue);
OrdSend(Pair, OP_SELLSTOP, Lot, Temp-(Cnt*Interval*point()), 0, Temp-(Cnt*Interval*point())+SL*point(),0, CommOrder, (Cnt*Magic)+1, 0, Red);
Comment(Temp+"Cnt : "+Cnt+" interval: "+Interval);
}
}
//--------Keep the Grid by replacing orders if pending orders drop below 6 --------//
//Replace Pending buy orders and add a sell order if pending buy orders drop below 6
if(countbuystop()<6&&countsellstop()>0)
{
Temp=MarketInfo(Pair, MODE_BID);
for (Cnt=1;Cnt<=NormalizeDouble((Range/2),0);Cnt++)
{
OrdSend(Pair, OP_BUYSTOP, Lot, Temp+(6*Interval*point()), 0, Temp+(6*Interval*point())-SL*point(),0, CommOrder, Cnt*Magic, 0, Blue);
OrdSend(Pair, OP_SELLSTOP, Lot, Temp-(1*Interval*point()), 0, Temp-(1*Interval*point())+SL*point(),0, CommOrder, (Cnt*Magic)+1, 0, Red);
Comment(Temp+"Cnt : "+Cnt+" interval: "+Interval);
}
}
//Replace Pending sell orders and add a buy order if pending sell orders drop below 6
if(countsellstop()<6&&countbuystop()>0)
{
Temp=MarketInfo(Pair, MODE_BID);
for (Cnt=1;Cnt<=NormalizeDouble((Range/2),0);Cnt++)
{
OrdSend(Pair, OP_BUYSTOP, Lot, Temp+(1*Interval*point()), 0, Temp+(1*Interval*point())-SL*point(),0, CommOrder, Cnt*Magic, 0, Blue);
OrdSend(Pair, OP_SELLSTOP, Lot, Temp-(6*Interval*point()), 0, Temp-(6*Interval*point())+SL*point(),0, CommOrder, (Cnt*Magic)+1, 0, Red);
Comment(Temp+"Cnt : "+Cnt+" interval: "+Interval);
}
}
This works the first 2 times and replaces the pending orders as they are triggered but after the 2nd time it works...then it stops working.
any 1 know how to fix this??
Thanx in advance guys for any help