3ヶ月前に書いたEAが、今はストラテジーテストを通過できないが、2~3ヶ月前はうまく動作していた! - ページ 3

 

取引、自動取引システム、取引戦略のテストに関するフォーラム


アンジュボヤージュール 2014.02.11 17:59

こんにちは。

コード投稿の際は、SRCボタンを ご利用ください。ありがとうございます。


今回は、私が編集させていただきました。


 
jitanic:

ハイ

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


なんでこんな表記にしてるんだ、わかりにくいぞ.

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

を代わりに使っています。

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

ちなみに、どちらの場合でも、私の場合はうまくいきます。


 

アイム・ソーリー・ヒゲソーリー

このスクリプトをチェックして、私の間違いを指摘してください。

#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:

アイム・ソーリー・ヒゲソーリー

このスクリプトをチェックして、私の間違いを指摘してください。

このスクリプトは私のために動作します。TadbirTrader-Serverを使ってテストしました。
 
angevoyageur:
私の場合、動作します。私はそれをテストするためにTadbirTrader-Serverを使用しました。
あなたは本当のアカウントを持っているか、デモ口座 で確認してください!!!。
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:
リアル口座を持っているか、デモ口座 で確認していますか?

デモ口座のみです。

P.S.: デモ口座でも動作していることを見落としていて申し訳ありません。

によってあなたの本当のアカウントでどのような値が返されます。

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

デモでは動いているのですが。

サーバーから制限されているのでしょうか?

 
jitanic:

デモでは動いているのですが。

サーバーから制限されているのでしょうか?

明らかに、この保留中の順序を置くことを制限する何かがあります。おそらく、リアル口座でこのシンボルに対して異なる設定をしているのでしょう(私の前の投稿を参照してください)。

Error 10006 : request rejected は、あまり有用なメッセージではありません。この注文を何回出そうとしたのですか?

デモ 口座での現在のBid/Ask/Lastは2638/2652/2640ですが、リアル口座でも同じでしょうか?

 
angevoyageur:

明らかにこの保留中の順序を置くことを制限する何かがある。おそらく、リアル口座でこのシンボルに対して異なる設定をしているのでしょう(私の以前の投稿を参照してください)。

Error 10006 : request rejected は、あまり有用なメッセージではありません。この注文を何回出そうとしたのですか?

デモ 口座での現在のBid/Ask/Lastは2638/2652/2640ですが、リアル口座でも同じでしょうか?

こんにちは、ご返信ありがとうございます。

シンボルのプロパティの画像を添付します。

もしそれが役に立たなければ、私に言ってください:私のコードのどこに印刷注文を挿入するのですか?

ファイル:
Untitled.png  47 kb
 
jitanic:

こんにちは、ご返信ありがとうございます。

シンボルのプロパティの画像を添付します。

もしそれが助けにならないなら、私に言ってください:私のコードのどこに印刷順序を挿入しますか?

私はそれが動作しない理由を見ることができません。

今、もう一度試してもらえますか?それはまだ働いていないのですか?

理由: