CTrade

 

Hello,

I wrote this code in Mql5:

CTrade Trade;

void OnTick()
  {

   double Bid=SymbolInfoDouble("USDCHF",SYMBOL_BID);
   if(PositionsTotal()==0)
     {
      Trade.Sell(lot,"USDCHF",Bid,Bid+sl*Point(),Bid-tp*Point(),"Divergence");
      Comment("Open= ");
     }

}

 In backtest, it writes Open=  but it doesn't trade, even a single trade. What should I do to make it trade?

 
resum seen:

Hello,

I wrote this code in Mql5:

CTrade Trade;

void OnTick()
  {

   double Bid=SymbolInfoDouble("USDCHF",SYMBOL_BID);
   if(PositionsTotal()==0)
     {
      Trade.Sell(lot,"USDCHF",Bid,Bid+sl*Point(),Bid-tp*Point(),"Divergence");
      Comment("Open= ");
     }

}

 In backtest, it writes Open=  but it doesn't trade, even a single trade. What should I do to make it trade?

If you search here (top right) for CTrade you'll find lots of examples how to use it - one is aready on your PC: ..\Experts\Examples\MACD\
 
The order was received but could not be finalized for a reason. In any casse the program should test the return code  to know what heppened.  There are different  levels or return,  checking and server processing .
 
Carl Schreiber #:
If you search here (top right) for CTrade you'll find lots of examples how to use it - one is aready on your PC: ..\Experts\Examples\MACD\
thanks, the example is about buy stop or pending order but I want to do a simple sell. my code is wrong?
Reason: