ASK: Work on Strategy Tester, but not on Live

 

Hi all,

i have a problem just with my very simple script int ticket = OrderSend(..); that i put it in OnTick() function

This script works well when i run it on Strategy Tester, and that int ticket int ticket returns the ticket number when i print it (this means it works right?), but

This script doesn't work when i run it on Live demo account, and that int ticket int ticket returns -1 when i print it (this means doesn't work right?)

any idea for this case ?

did i miss something here ? 

 

Many Great thanks in advance

 

Here is my simple script on OnTick() event

input int   MaHiPer=5;
input int   MaLoPer=5;
input double volume=1.00;

double cur_ma_hi;
double cur_ma_lo; 

double Buy_TakeProfit;
double Buy_StopLoss;

double Sell_TakeProfit;
double Sell_StopLoss;

bool order_on = false;
string symbol = Symbol();
int ticket;

double cur_can_op = iOpen(NULL,0,0);
double space;
   
string comment;

bool order;
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick(){
   cur_ma_hi = iMA(NULL,0,MaHiPer,0,MODE_SMA,PRICE_HIGH,0);
   cur_ma_lo = iMA(NULL,0,MaLoPer,0,MODE_SMA,PRICE_LOW,0); 
   Buy_TakeProfit = Bid + 0.0060;
   Buy_StopLoss   = Bid - 0.0030;
   Sell_TakeProfit = Bid - 0.0060;
   Sell_StopLoss   = Bid + 0.0030;
   cur_can_op = iOpen(NULL,0,0);
   
   if(cur_can_op>cur_ma_hi){
      space = cur_can_op - cur_ma_hi;
      if(space>0.0003){
         comment = "SELL !!";
         if(order_on==false){
            //take SELL - TP - SL
            ticket = OrderSend(symbol,OP_SELL,volume,Ask,10,Sell_StopLoss,Sell_TakeProfit,"SELL order",0,0,clrRed);
            //order_on = true;
         } 
      }
   }else if(cur_can_op<cur_ma_lo){
      space = cur_ma_lo - cur_can_op;
      if(space>0.0003){
         comment = "BUY !!";
         if(order_on==false){
            //take BUY - TP - SL
            ticket = OrderSend(symbol,OP_BUY,volume,Ask,10,Buy_StopLoss,Buy_TakeProfit,"BUY order",0,0,clrGreen);
            //order_on = true;
         }
      } 
   }
   
   Comment("Ask:"+Ask+"     Bid:"+Bid
           +"\ncurrent_ma_hi:"+cur_ma_hi+"    current_ma_lo:"+cur_ma_lo
           +"\nOpenCandle:"+cur_can_op
           +"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
           +"Ticket : "+ticket
           +"\nspace  : "+space+"\n"
           +comment);
           
   
   
   
}
 
eagleeyes0618:

Hi all,

i have a problem just with my very simple script int ticket = OrderSend(..); that i put it in OnTick() function

This script works well when i run it on Strategy Tester, and that int ticket int ticket returns the ticket number when i print it (this means it works right?), but

This script doesn't work when i run it on Live demo account, and that int ticket int ticket returns -1 when i print it (this means doesn't work right?)

any idea for this case ?

did i miss something here ? 

 

Many Great thanks in advance

 

Here is my simple script on OnTick() event

Sell Opens at the Bid and closes at the Ask
Buy Opens at the Ask and closes at the Bid
 
Lorentzos Roussos:
Sell Opens at the Bid and closes at the Ask
Buy Opens at the Ask and closes at the Bid

Hi Lorentzos Roussos,

it works.

Many thanks.

Reason: