This EA closes both buystop and sellstop orders, it should only close sellstop orders.
What should be corrected in the code?
Best regards
Dale
#property copyright "Copyright 09, Coder."
#property link "http://www.coder.net"
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
#include <stdlib.mqh>
int start()
{
int iOrders=OrdersTotal()-1, i;
if((0==0) && Symbol() == Symbol())
{
for(i=iOrders; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderType()==OP_SELLSTOP) && !OrderDelete(OrderTicket())) Print(OrderError());
}
RefreshRates();
}
return(0);
}
//+------------------------------------------------------------------+
string OrderError()
{
int iError=GetLastError();
return(StringConcatenate("Order:",OrderTicket()," GetLastError()=",iError," ",ErrorDescription(iError)));
}
What should be corrected in the code?
Best regards
Dale
#property copyright "Copyright 09, Coder."
#property link "http://www.coder.net"
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
#include <stdlib.mqh>
int start()
{
int iOrders=OrdersTotal()-1, i;
if((0==0) && Symbol() == Symbol())
{
for(i=iOrders; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderType()==OP_SELLSTOP) && !OrderDelete(OrderTicket())) Print(OrderError());
}
RefreshRates();
}
return(0);
}
//+------------------------------------------------------------------+
string OrderError()
{
int iError=GetLastError();
return(StringConcatenate("Order:",OrderTicket()," GetLastError()=",iError," ",ErrorDescription(iError)));
}
Attached File(s)