私が試行錯誤しているアドバイザーの組み立て方 - ページ 47

削除済み  

ポジションの開閉と 混同しないように、全てのラインとインジケータを正しい方向に設定し、リバースは使用しない方が良い

そうしないと、混乱します。特に、設定にオプションがあるので(反転はすべてのラインとインジケータに適用されます)。

input string   t3="----- Indicators:        -----";              //
input string   short_name                   = "Examples\\MACD";  // Name Indicators
input bool     InpIndicators                = false;             // Indicators: Start (true)
input bool     InpCloseOpposite             = false;             // Close opposite
input ENUM_TRADE_COMMAND InpTradeCommandY   = open_buy;          // Trade command: (BuyBuffer Indicators)
input ENUM_TRADE_COMMAND InpTradeCommandU   = open_sell;         // Trade command: (SellBuffer Indicators)
input string   t4="----- Revers Buy><Sell   -----";              //
input bool     ObjRevers                    = false;             //  Revers

のように、コードそのもの
入力を 削除すればよいのです。

string   t4="----- Revers Buy><Sell   -----";              //
bool     ObjRevers                    = false;             //  Revers
削除済み  
Alexsandr San:

ポジションの開閉と 混同しないように、全てのラインとインジケータを正しい方向に設定し、リバースは使用しない方が良い

そうしないと、混乱します。特に、設定にオプションがあるので(反転はすべてのラインとインジケータに適用されます)。

のように、コードそのもの
入力を 削除すればよいのです。

いいえ、インジケータを反転させる必要があります。

削除済み  

インディケーターから新機能を出すために、いろいろ工夫しているんです。

input string   t3="----- Indicators: SELL   -----";              //
input string   short_name                   = "2";               // Name Indicators "SELL"
input bool     InpIndicators                = false;             // Indicators: Start (true)
input ENUM_TRADE_COMMAND InpTradeCommandY   = open_sell;         // Trade command: (BuyBuffer Indicators)
input ENUM_TRADE_COMMAND InpTradeCommandU   = close_sells;       // Trade command: (SellBuffer Indicators)
input string   t4="----- Indicators: BUY    -----";              //
input string   short_name1                  = "2";               // Name Indicators "BUY"
input bool     InpIndicators1               = false;             // Indicators: Start (true)
input ENUM_TRADE_COMMAND InpTradeCommandY1  = close_buys;        // Trade command: (BuyBuffer Indicators)
input ENUM_TRADE_COMMAND InpTradeCommandU1  = open_buy;          // Trade command: (SellBuffer Indicators)

1つでも2つでも指標があって、妄想ができる。

インディケーター、ピックアップするだけでいいんです。

https://www.mql5.com/ru/code/392

撮影者

というインジケータを作りました( 2 )

ファイル:
2.mq5  17 kb
削除済み  
Alexsandr San:

インディケーターから新機能を出すために、いろいろ工夫しているんです。

1つでも2つでも指標があって、妄想ができる。

選ぶだけでいいんです、Indicator - こんな感じで(写真)。

https://www.mql5.com/ru/code/392

というインジケータをごまかしました( 2 )

1分間動作を確認する - 問題なく動作する

スナップショット2

削除済み  
Alexsandr San:

1分間動作確認 - 問題なく動作


expertWWW_Trailing_Line.mq596 kb は問題なく動作し、エラーはありません。

マニュアル版のテスターで、情報用とテスト用のパネルを追加する必要があるのみ

パネル

削除済み  
Alexsandr San:

expert works wellWWWW_Trailing_Line.mq596 kb, no errors.

ただ、マニュアル版のテスターでは、情報用とテスト用のパネルを追加する必要があります

パネルを追加しました。これで、テスターで手動テストができるようになりました。

コマンド_トレイリングライン

設定内容

//+------------------------------------------------------------------+
input string   t="-----  Parameters         -----";              //
input string   Template                     = "ADX";             // Имя шаблона(without '.tpl')
input double   TargetProfit                 = 999999.99;         // Цель Баланса(Ваш Баланс + сумма)
input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots                      = 0.01;              // Lots
input int      InpTakeProfit                = 50;                // Take Profit ("0"-No. 5<100)
input string   t0="----- Trailing Line      -----";              //
input string   InpObjUpName                 = "TOP";             // Obj: TOP (Horizontal Line)
input ENUM_TRADE_COMMAND InpTradeCommand    = close_sells;       // Obj:  command:
input string   InpObjDownName               = "LOWER";           // Obj: LOWER (Horizontal Line)
input ENUM_TRADE_COMMAND InTradeCommand     = close_buys;        // Obj:  command:
input ushort   InpObjTrailingStop           = 30;                // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStep           = 5;                 // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
input string   t1="----- Line name: 1       -----";              //
input string   InpNameR                     = "LineR";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandR   = open_buy;          // Trade command:
input string   t2="----- Line name: 2       -----";              //
input string   InpNameS                     = "LineS";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandS   = open_sell;         // Trade command:
input string   t3="----- Indicators: SELL   -----";              //
input string   short_name                   = "2";               // Name Indicators "SELL"
input bool     InpIndicators                = false;             // Indicators: Start (true)
input ENUM_TRADE_COMMAND InpTradeCommandY   = open_sell;         // Trade command: (BuyBuffer Indicators)
input ENUM_TRADE_COMMAND InpTradeCommandU   = close_sells;       // Trade command: (SellBuffer Indicators)
input string   t4="----- Indicators: BUY    -----";              //
input string   short_name1                  = "2";               // Name Indicators "BUY"
input bool     InpIndicators1               = false;             // Indicators: Start (true)
input ENUM_TRADE_COMMAND InpTradeCommandY1  = close_buys;        // Trade command: (BuyBuffer Indicators)
input ENUM_TRADE_COMMAND InpTradeCommandU1  = open_buy;          // Trade command: (SellBuffer Indicators)
input string   t5="----- Button:            -----";              //
input ENUM_TRADE_COMMAND InpTradeCommandBut = open_buy;          // Obj(BUY):  command:Button: BUY
input ENUM_TRADE_COMMAND InTradeCommandBut  = open_sell;         // Obj(SELL):  command:Button: SELL
input int      TrailingStop_STOP_LEVEL      = 36;                // Button: Trailing Stop LEVEL
ファイル:
削除済み  
Alexsandr San:

パネルが追加されました - 今、あなたはまだテスターで、あなたの手を取得することができます。

どのような設定になっているのか

くそー!OnDeinitに挿入し損ねた。

Expert Advisor をチャートから削除すると、パネルが削除されなくなります。

コードが開かれているので、自分でコピー&ペーストすることができます。

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   for(int i=0; i<ArraySize(_name); i++)
     {
      ObjectDelete(0,Symbol()+_name[i]);
     };
   EventKillTimer();
//---
   Print(TimeCurrent(),": ",__FUNCTION__," reason code = ",reason);
   Comment("");
  }
//+------------------------------------------------------------------+
削除済み  
Alexsandr San:

パネルが追加されました - 今、あなたはまだテスターで、あなたの手を取得することができます。

どのような設定になっているか

もう一つ機能を追加したいのですが。

例えば、売りのシグナルが発生した場合、ポジションを建てるのではなく、Nポイント戻しの水平線を引き、この線から価格が戻るとポジションを建てるというものです。

EURUSDH1

削除済み  
Alexsandr San:

もうひとつ機能を追加する必要があります。

例えば、売りのシグナルが発生した場合、ポジションを建てるのではなく、Nポイント戻しの水平線を引き、この線から価格が戻るとポジションを建てることになります。


シンプルにまとめたつもりですが、もし興味を持たれた方がいらっしゃれば、一緒に考えてみましょう。

撮影者

スナップショット2

削除済み  
Alexsandr San:

わかったよ~、迷わないようにしたんだ、興味のある人がいたら聞いてね、一緒に考えよう。

まだ、うまく設定する方法を探しているところです。

//+------------------------------------------------------------------+
//| Enum Lor or Risk                                                 |
//+------------------------------------------------------------------+
enum ENUM_TRADE_COMMAND
  {
   Line_Line=0,      // Line
   Line_buy=1,       // Line+Open Buy
   Line_sell=2,      // Line+Open Sell
   close_buys=3,     // Close All Buy's
   close_sells=4,    // Close All Sell's
   close_all=5,      // Close All Buy's and Sell's
   open_buy=6,       // Open Buy
   open_sell=7,      // Open Sell
   open_buy_sell=8,  // Open Buy and Sell
  };
//+------------------------------------------------------------------+


ここで、アクションを行うのですが、その際にロジックを設定する必要があります。

   if(main[1]>signal[1])
     {
      switch(InpTradeCommandY)
        {
         case Line_Line:
            ExtNeedLine=true;
            if(Obj_line())
               break;
         case Line_buy:
            ExtNeedOpenBuy=true;
            if(LongObjOpened())
               ExtNeedLine=true;
            if(Obj_line())
               break;
         case Line_sell:
            ExtNeedOpenSell=true;
            if(ShortObjOpened())
               ExtNeedLine=true;
            if(Obj_line())
               break;
         case  close_buys:
            ExtNeedCloseBuy=true;
            if(LongObjClosed())
               break;
         case  close_sells:
            ExtNeedCloseSell=true;
            if(ShortObjClosed())
               break;
         case close_all:
            ExtNeedCloseAll=true;
            if(LongShortObjClosed())
               break;
         case open_buy:
            ExtNeedOpenBuy=true;
            if(LongObjOpened())
               break;
         case open_sell:
            ExtNeedOpenSell=true;
            if(ShortObjOpened())
               break;
         default:
            ExtNeedOpenBuySell=true;
            if(LongShortObjOpened())
               break;
        }
      PlaySound("ok.wav");
     }
   if(main[1]<signal[1])
     {
      switch(InpTradeCommandU)
        {
         case Line_Line:
            ExtNeedLine=true;
            if(Obj_line())
               break;
         case Line_buy:
            ExtNeedOpenBuy=true;
            if(LongObjOpened())
               ExtNeedLine=true;
            if(Obj_line())
               break;
         case Line_sell:
            ExtNeedOpenSell=true;
            if(ShortObjOpened())
               ExtNeedLine=true;
            if(Obj_line())
               break;
         case  close_buys:
            ExtNeedCloseBuy=true;
            if(LongObjClosed())
               break;
         case  close_sells:
            ExtNeedCloseSell=true;
            if(ShortObjClosed())
               break;
         case close_all:
            ExtNeedCloseAll=true;
            if(LongShortObjClosed())
               break;
         case open_buy:
            ExtNeedOpenBuy=true;
            if(LongObjOpened())
               break;
         case open_sell:
            ExtNeedOpenSell=true;
            if(ShortObjOpened())
               break;
         default:
            ExtNeedOpenBuySell=true;
            if(LongShortObjOpened())
               break;
        }
      PlaySound("ok.wav");
     }
//---