- using time to remove orders?
- Searching for a missing order!
- Code to close all orders by GMT (time)
int i, N ; N = OrdersTotal ();
for ( i = 0 ; i < N ; i ++ )
{ OrderSelect ( i, SELECT_BY_POS, MODE_TRADES )
if (OrderMagicNo()==MagicNo)
{
if (OrderProfit() > what u want to do)
do something
}
}
int i, N ; N = OrdersTotal ();
for ( i = 0 ; i < N ; i ++ )
{ OrderSelect ( i, SELECT_BY_POS, MODE_TRADES )
if (OrderMagicNo()==MagicNo)
{
if (OrderProfit() > what u want to do)
do something
}
}
Thanks! That is real close to what I was looking for........how do I select the order that has that MagicNumber though? THAT would be perfectly what I need...thanks!!! Dan
Thanks! That is real close to what I was looking for........how do I select the order that has that MagicNumber though? THAT would be perfectly what I need...thanks!!! Dan
extern int MagicNo = 333;
void start()
{
//say you have set a certain condition to fire your orders
if (TimeHour(TimeCurrent())==1 && TimeMinute(TimeCurrent())==0)
{
double x = NormalizeDouble((iHigh(Symbol(),PERIOD_H1,1)+iLow(Symbol(),PERIOD_H1,1))/2.0,Digits);
OrderSend(Symbol(),OP_BUYSTOP,Lots,x+Step*Point,3,x+(Step-SL)*Point,x+(Step+TP)*Point,"",MagicNo,0,Green);
OrderSend(Symbol(),OP_SELLSTOP,Lots,x-Step*Point,3,x+(-Step+SL)*Point,x-(Step+TP)*Point,"",MagicNo,0,Red);
}
//then you want to look for an order that has already been fired and chk its profit/loss
int i, N ; N = OrdersTotal ();
for ( i = 0 ; i < N ; i ++ )
{ OrderSelect ( i, SELECT_BY_POS, MODE_TRADES )
if (OrderMagicNo()==MagicNo
&& ( OrderType()==OP_BUY || OrderType()==OP_SELL)) // if order is a buy or sell order that has MagicNo=333
{
if (OrderProfit() > what u want to do)
do something
}
}
}
}
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use