Can someone just look over this and see if it is ok it complied ok but not exp so maybe there is something i have missed
It is supposed to:
1) Place buystop or sell stop with predifined stoploss (StopLoss) and take profit (TakeProfit)
2)use the magic number set at HighPrice (buy order) or LowPrice (sell order)
3) Siganl buy and sell based on signal stored in position variable. 1 buy and -1 sell.
4)It should also only open one order and not open an order if there are orders open or pending.
5) Lot size is set in global variable with StopLoss & TakeProfit
The magic number is to allow me to close all orders in the future by magic number.
thank you
void pendingorders()
{
double HighPrice , LowPrice;
total = OrdersTotal();
if(total < 1)
{
if(position == 1)
{
ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,HighPrice,3,HighPrice-(StopLoss*Point),HighPrice+(TakeProfit*Point),"Rags to Riches",MagicNumber,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUYSTOP order opened : ", HighPrice);
}
else Print("Error opening Pending BUY order : ",GetLastError());
return(0);
}
if(position == -1)
{
ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,LowPrice,3,LowPrice-(StopLoss*Point),LowPrice-(TakeProfit*Point),"Rags to Riches",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELLSTOP order opened : ",LowPrice);
}
else Print("Error opening pending SELL order : ",GetLastError());
return(0);
}
return(0);
}
}
It is supposed to:
1) Place buystop or sell stop with predifined stoploss (StopLoss) and take profit (TakeProfit)
2)use the magic number set at HighPrice (buy order) or LowPrice (sell order)
3) Siganl buy and sell based on signal stored in position variable. 1 buy and -1 sell.
4)It should also only open one order and not open an order if there are orders open or pending.
5) Lot size is set in global variable with StopLoss & TakeProfit
The magic number is to allow me to close all orders in the future by magic number.
thank you
void pendingorders()
{
double HighPrice , LowPrice;
total = OrdersTotal();
if(total < 1)
{
if(position == 1)
{
ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,HighPrice,3,HighPrice-(StopLoss*Point),HighPrice+(TakeProfit*Point),"Rags to Riches",MagicNumber,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUYSTOP order opened : ", HighPrice);
}
else Print("Error opening Pending BUY order : ",GetLastError());
return(0);
}
if(position == -1)
{
ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,LowPrice,3,LowPrice-(StopLoss*Point),LowPrice-(TakeProfit*Point),"Rags to Riches",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELLSTOP order opened : ",LowPrice);
}
else Print("Error opening pending SELL order : ",GetLastError());
return(0);
}
return(0);
}
}