Download MetaTrader 5
To add comments, please log in or register
Enable MQL5 Storage to store your source codes. It is free!
PieroNetto
189
PieroNetto 2014.10.17 22:30 
bool clbuy,clsell;
//+------------------------------------------------------------------+
//| Close Signal                                                     |
//+------------------------------------------------------------------+
void start() //CloseSignal()
{
      if(OrdersTotal()>0)
      clsell =false;
      clbuy =false;
      double CC1 = iClose(NULL, 0,1);
      double CO2 = iOpen  (NULL, 0,2);
      if(CC1<CO2)clbuy=true;
      if(CC1>CO2)clsell=true;
}
//+------------------------------------------------------------------+
//| Close Condition                                                  |
//+------------------------------------------------------------------+
void CloseCondition()
{
     int res;
     if(clbuy)
     {
     res = CloseOrder(OP_BUY);
     }
     if(clsell)
     {
     res = CloseOrder(OP_SELL);
     }
}
//+------------------------------------------------------------------+
//| Close Short Or Long Order                                        |
//+------------------------------------------------------------------+
int CloseOrder(int price)
{
      bool resOS,resOC;
      resOS=OrderSelect(0,SELECT_BY_POS,MODE_BASE);
      if(OrderProfit()>0)
      resOC=OrderClose(OrderTicket(),OrderLots(),price, 3,clrDarkBlue)&&PlaySound("alert2.wav");
return(0);
}

0=errors 0=warnings

 implemented in the code not working please help.

thanks 

Keith Watford
Moderator
7876
Keith Watford 2014.10.18 01:15  

First of all

You do not call the function CloseCondition(), so how do you expect it to be implemented?

Other than that, in CloseCondition() you call the function  CloseOrder() and you send parameters OP_BUY or OP_SELL, but the function is expecting a price. Please note that price should be a double, not an integer

PieroNetto
189
PieroNetto 2014.10.18 13:13  
GumRai:

First of all

You do not call the function CloseCondition(), so how do you expect it to be implemented?

Other than that, in CloseCondition() you call the function  CloseOrder() and you send parameters OP_BUY or OP_SELL, but the function is expecting a price. Please note that price should be a double, not an integer

Thanks got it!
PieroNetto
189
PieroNetto 2014.10.18 13:15  

if(OrderProfit()>0)     Function only execute when Profit is bigger then 0.00$ not Points in this case.

It works for now, but I would to put instead the same amount of Points/pips like my sl is set.

My sl is set by the Lowest[3] or Highest[3].

I know I have to OrderSelect()  and then OrderOpenPrice()+Point from StopLoss.

I’m asking for samples to look at them or please point me where it may have been discussed

or more info then one line reference

Thank you very much

/
To add comments, please log in or register