The EA I wrote three months ago can not pass the strategy testing now, but it used working well two or three months ago!! - page 3

 

Forum on trading, automated trading systems and testing trading strategies


angevoyageur, 2014.02.11 17:59

Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


 
jitanic:

hi

send order work in demo account but in real account don't work(2014.11.30 18:21:00.062 55 (اخابر,D1) BuyA: error 4756, retcode = 10006)

 


Wh are you using such notation, it's hard to understand :

   request.action=5;
   request.type=6;
   request.type_filling=2;

using that instead :

   request.action=TRADE_ACTION_PENDING;
   request.type=ORDER_TYPE_BUY_STOP_LIMIT;
   request.type_filling=ORDER_FILLING_RETURN;  

By the way, in either case it works for me.


 

i'm sorry

 

please check this script and give me my wrong:

  

#property description "Expert Advisor for sending trade requests "
" using OrderSendAsync() function.\r\n"
#property description "Handling trading events using"
" OnTrade() and OnTradeTransaction() handler functions is displayed\r\n"
#property description "Expert Advisor parameters allow setting Magic Number"
" (unique ID) "
#property description "and the mode of displaying messages in Experts log. All details are displayed by default.\r\n"
input int  MagicNumber=1234567;      // Expert Advisor ID
input bool DescriptionModeFull=true; // Detailed output mode
input double  Price=2652;
input double  Volume=1000;
input double  stoplimit=2681;
input double  sl=1000;
input double  tp=2681;
//+------------------------------------------------------------------+
int OnInit()
  {
//--- check if autotrading is allowed
   if(!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))
     {
      Alert("Autotrading in the terminal is disabled, Expert Advisor will be removed.");
      ExpertRemove();
      //--     return(-1);
     }
   CreateBuySellButtons();
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectDelete(0,"Buy");
   ObjectDelete(0,"Sell");
   ObjectDelete(0,"HALL");
  }
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction &trans,
                        const MqlTradeRequest &request,
                        const MqlTradeResult &result)
  {

  }
//+------------------------------------------------------------------+
void OnTrade()
  {

  }
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//--- handling CHARTEVENT_CLICK event ("Clicking the chart")
   if(id==CHARTEVENT_OBJECT_CLICK)
     {
      //--- if "Buy" button is pressed, then buy
      if(sparam=="Buy")
        {
         BuyA(Volume);
         //--- unpress the button
         ObjectSetInteger(0,"Buy",OBJPROP_STATE,false);
        }
      //--- if "Sell" button is pressed, then sell
      if(sparam=="Sell")
        {
         SellA(Volume);
         //--- unpress the button
         ObjectSetInteger(0,"Sell",OBJPROP_STATE,false);
        }
      ChartRedraw();
     }
  }
//+------------------------------------------------------------------+
void CreateBuySellButtons()
  {
   ObjectCreate(0,"Buy",OBJ_BUTTON,0,0,0); // create "Buy" button
   ObjectSetInteger(0,"Buy",OBJPROP_CORNER,CORNER_RIGHT_UPPER);
   ObjectSetInteger(0,"Buy",OBJPROP_XDISTANCE,100);
   ObjectSetInteger(0,"Buy",OBJPROP_YDISTANCE,50);
   ObjectSetInteger(0,"Buy",OBJPROP_XSIZE,70);
   ObjectSetInteger(0,"Buy",OBJPROP_YSIZE,30);
   ObjectSetString(0,"Buy",OBJPROP_TEXT,"Buy");
   ObjectSetInteger(0,"Buy",OBJPROP_COLOR,clrRed);
   ObjectCreate(0,"Sell",OBJ_BUTTON,0,0,0); // create "Sell" button
   ObjectSetInteger(0,"Sell",OBJPROP_CORNER,CORNER_RIGHT_UPPER);
   ObjectSetInteger(0,"Sell",OBJPROP_XDISTANCE,100);
   ObjectSetInteger(0,"Sell",OBJPROP_YDISTANCE,100);
   ObjectSetInteger(0,"Sell",OBJPROP_XSIZE,70);
   ObjectSetInteger(0,"Sell",OBJPROP_YSIZE,30);
   ObjectSetString(0,"Sell",OBJPROP_TEXT,"Sell");
   ObjectSetInteger(0,"Sell",OBJPROP_COLOR,clrBlue);
   ObjectCreate(0,"HALL",OBJ_LABEL,0,0,0); // create LABEL
   ObjectSetInteger(0,"HALL",OBJPROP_CORNER,CORNER_RIGHT_UPPER);
   ObjectSetInteger(0,"HALL",OBJPROP_XDISTANCE,100);
   ObjectSetInteger(0,"HALL",OBJPROP_YDISTANCE,150);
   ObjectSetInteger(0,"HALL",OBJPROP_XSIZE,70);
   ObjectSetInteger(0,"HALL",OBJPROP_YSIZE,30);
   ObjectSetString(0,"HALL",OBJPROP_TEXT,_Symbol);
   ObjectSetInteger(0,"HALL",OBJPROP_COLOR,clrBlue);
   ChartRedraw();
  }
//+------------------------------------------------------------------+
void BuyA(double volume)
  {
//--- prepare the request
   MqlTradeRequest request;
   MqlTradeResult  result;
   MqlTradeCheckResult check;
   ZeroMemory(request);
   ZeroMemory(result);
   ZeroMemory(check);
   request.action=TRADE_ACTION_PENDING;
   request.symbol=_Symbol;
   request.volume=1000.00;
  request.price=2652.000;
   request.stoplimit=2652.000;
   request.sl=0;
   request.tp=0;
request.type=ORDER_TYPE_BUY_STOP_LIMIT;
request.type_filling=ORDER_FILLING_RETURN; 
   request.type_time=0;
   request.expiration=0;
  request.magic=0;
request.comment="";
   if(!OrderSend(request,result))
     {
      Print(__FUNCTION__,": error ",GetLastError(),", retcode = ",result.retcode);
     }
//---
  }
//+------------------------------------------------------------------+
void SellA(double volume)
  {
//--- prepare the request
   MqlTradeRequest request;
   request.action=TRADE_ACTION_DEAL;
   request.symbol=_Symbol;
   request.magic=0;
   request.volume=Volume;
   request.type=ORDER_TYPE_SELL;
   request.price=SymbolInfoDouble(request.symbol,SYMBOL_BID);
   request.deviation=10;
   request.comment="Sell using OrderSendAsync()";
   MqlTradeResult  result;
   if(!OrderSendAsync(request,result))
     {
      Print(__FUNCTION__,": error ",GetLastError(),", retcode = ",result.retcode);
     }
  }
//+------------------------------------------------------------------+
 
jitanic:

i'm sorry

 

please check this script and give me my wrong:

  

It works for me. I used TadbirTrader-Server to test it.
 
angevoyageur:
It works for me. I used TadbirTrader-Server to test it.
do you have real acount or check in demo account?!!
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Reference on algorithmic/automated trading language for MetaTrader 5
 
jitanic:
do you have real acount or check in demo account?!!

Demo account only.

P.S: Sorry I missed the point that it's working on demo account for you too.

What value is returned on your real account by :

   printf("expiration=%i",SymbolInfoInteger(_Symbol,SYMBOL_EXPIRATION_MODE));
   printf("filling=%i",SymbolInfoInteger(_Symbol,SYMBOL_FILLING_MODE));
 

it's working in demo for me,

may it restricted from server? 

 
jitanic:

it's working in demo for me,

may it restricted from server? 

There is obviously something that restrict you to place this pending order. Probably some different settings for this symbol on Real account (see my previous post).

Error 10006 : request rejected is not very useful message. How many times did you try to place this order ?

Current Bid/Ask/Last on demo account is 2638/2652/2640, is it the same on real account ?

 
angevoyageur:

There is obviously something that restrict you to place this pending order. Probably some different settings for this symbol on Real account (see my previous post).

Error 10006 : request rejected is not very useful message. How many times did you try to place this order ?

Current Bid/Ask/Last on demo account is 2638/2652/2640, is it the same on real account ?

hi thank for reply

i'm attach picture of symbol properties

if it doesn't help ,said me :where do insert print order in my code?

Files:
Untitled.png  47 kb
 
jitanic:

hi thank for reply

i'm attach picture of symbol properties

if it doesn't help ,said me :where do insert print order in my code?

I can't see why it doesn't work.

Can you try again, now ? It's still not working ?