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

 
Alexsandr San:

実際の口座で試したところ、2つのオープンポジション からわずかな利益が欲しかった。 設定で160と入力したので、一番大きなマイナスポジションを決済してくれるのかと思ったら、そうではなく、決済されてしまった。

一番大きく負けているポジションを決済するのかと思ったらそうではなく、160の利益が出た方を決済し、両方のポジションを決済してしまい、カモにされてしまいました。最初のオープンポジションから、マイナスを足して計算しなければならないことがわかりました。


#property version "1.017"

この機能の正しい使い方がわかったのは、5日目です。今、それはすべての買いまたは売りの1つのペアの総利益に閉じます。

//+------------------------------------------------------------------+
//| Check for long position closing                                  |
//+------------------------------------------------------------------+
bool ProfitOnTick(void)
  {
   bool res=false;
   double PROFIT_BUY=0.00;
   double PROFIT_SELL=0.00;

   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of open positions
     {
      string   position_GetSymbol=PositionGetSymbol(i); // GetSymbol позиции
      if(position_GetSymbol==m_symbol.Name())
        {
         if(m_position.PositionType()==POSITION_TYPE_BUY)
           {
            PROFIT_BUY=PROFIT_BUY+PositionGetDouble(POSITION_PROFIT);
           }
         else
           {
            PROFIT_SELL=PROFIT_SELL+PositionGetDouble(POSITION_PROFIT);
           }
        }
     }
   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of current positions
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name())
           {
            if(m_position.PositionType()==POSITION_TYPE_BUY)
              {
               if(PROFIT_BUY<-TargetStopLoss || PROFIT_BUY>=TargetTakeProfit) // if the profit
                  ClosePosition(m_position.Symbol()); // close a position by the specified symbo
              }
            res=true;
           }
   for(int u=PositionsTotal()-1; u>=0; u--) // returns the number of current positions
      if(m_position.SelectByIndex(u)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name())
           {
            if(m_position.PositionType()==POSITION_TYPE_SELL)
              {
               if(PROFIT_SELL<-TargetStopLoss || PROFIT_SELL>=TargetTakeProfit) // if the profit
                  ClosePosition(m_position.Symbol()); // close a position by the specified symbo
              }
            res=true;
           }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+
ファイル:
 
Alexsandr San:

悪くない機能だと思います。あちこちで、利益を取って、どうでもよくなっている

私は解決するためにコードを持っている - すべてがそのようにうまく動作するように見える

この機能を1つの端末で動作させるためのコードが作成できない。4端子で試してみたい、何が出てくるかわからないけど

4 nthvbyfkf

4 nthvbyfkf2

 
Alexsandr San:

この機能を実現するためのコードが作れない 1つの端末で。4端子で試してみたい、何が出てくるかわからないけど

これら4つの端子はすべて、何の結果も得られなかった。そして、一般的には、ロスからこの機能 - コードは書けません。

しかし、私はとっくの昔に、このようなロジックを、ホリゾンタルラインだけで作っています。あとは、何をもってしてロットを倍増させるかを考えるだけです。

撮影者 写真1

上部に水平線を設定しました

input string   t3="----- Trailing Line: 1   -----";              //
input string   InpObjUpName                 = "ZTOP";            // Obj: TOP (Horizontal Line)
input int      InpStep1                     = 25;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InpTradeCommand    = Line2_sells;       // Obj:  command:

下部に水平線を設定する

input string   t3="----- Trailing Line: 1   -----";              //
input string   InpObjDownName               = "ZLOWER";          // Obj: LOWER (Horizontal Line)
input int      InpStep2                     = 25;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InTradeCommand     = Line1_buys;        // Obj:  command:

価格がこれらの線に触れると同時にポジションがオープンされ、水平線が設定されます。

これら

input string   t4="----- Trailing Line: 2   -----";              //
input string   InpObjUpNameG                = "POT";             // Obj: TOP (Horizontal Line)
input int      InpStep3                     = 25;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InpTradeCommandG   = Line2_sells;       // Obj:  command:
input string   InpObjDownNameG              = "REWOL";           // Obj: LOWER (Horizontal Line)
input int      InpStep4                     = 25;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InTradeCommandG    = Line1_buys;        // Obj:  command:
input ushort   InpObjTrailingStopG          = 0;                 // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStepG          = 5;                 // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)

そして、これらの水平線から位置を開き、最初の水平線を置くでしょう - 価格はそれらに到達することができるまで、それは繰り返されます。
GBPUSDM5図2

ここで閉じている - 設定で設定、利益

GBPUSDM52図3

---------------------------------------------

ペアで200の利益に達したとき、それはポジションを閉じます。

GBPUSDM53図4

200に達し、買いまたは売りのすべての位置を閉じた - あなたは両方向に開くことができ、それぞれの側は、独自の、利益または損失を持っているので。

- 水平線に到達すると、ポジションが開かれますが、手動で移動できます。

GBPUSDM54図5

 

この機能は、損失から、ロットを増加させる。

この人に感謝https://www.mql5.com/ru/forum/107406#comment_3018721

2732

イゴール・キム

//+------------------------------------------------------------------+
//| Check for long position closing                                  |
//+------------------------------------------------------------------+
bool OpenLotBuy(void)
  {
   bool res=false;
//---
   double PROFIT_BUY=0.00;
   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of open positions
     {
      string   position_GetSymbol=PositionGetSymbol(i); // GetSymbol позиции
      if(position_GetSymbol==m_symbol.Name())
        {
         if(m_position.PositionType()==POSITION_TYPE_BUY)
           {
            PROFIT_BUY=PROFIT_BUY+PositionGetDouble(POSITION_PROFIT);
           }
        }
     }
   double Lots=InpLots;
   double ab=PROFIT_BUY;
   if(ab<-200 && ab>=-400)
      Lots=0.01;
   if(ab<-400 && ab>=-800)
      Lots=0.02;
   if(ab<-800 && ab>=-1600)
      Lots=0.04;
   if(ab<-1600)
      Lots=0.08;
   double price=m_symbol.Ask();
   for(uint y=0; y<maxLimits; y++)
     {
      //--- open position
      if(m_trade.PositionOpen(m_symbol.Name(),ORDER_TYPE_BUY,Lots,price,0.0,0.0))
         printf("Position by %s to be opened",m_symbol.Name());
      else
        {
         printf("Error opening BUY position by %s : '%s'",m_symbol.Name(),m_trade.ResultComment());
         printf("Open parameters : price=%f,TP=%f",price,0.0);
        }
      res=true;
     }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+
//| Check for long position closing                                  |
//+------------------------------------------------------------------+
bool OpenLotSell(void)
  {
   bool res=false;
//---
   double PROFIT_SELL=0.00;
   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of open positions
     {
      string   position_GetSymbol=PositionGetSymbol(i); // GetSymbol позиции
      if(position_GetSymbol==m_symbol.Name())
        {
         if(m_position.PositionType()==POSITION_TYPE_BUY)
           {
            PROFIT_SELL=PROFIT_SELL+PositionGetDouble(POSITION_PROFIT);
           }
        }
     }
   double Lots=InpLots;
   double ab=PROFIT_SELL;
   if(ab<-200 && ab>=-400)
      Lots=0.01;
   if(ab<-400 && ab>=-800)
      Lots=0.02;
   if(ab<-800 && ab>=-1600)
      Lots=0.04;
   if(ab<-1600)
      Lots=0.08;
   double price0=m_symbol.Bid();
   for(uint y=0; y<maxLimits; y++)
     {
      if(m_trade.PositionOpen(m_symbol.Name(),ORDER_TYPE_SELL,Lots,price0,0.0,0.0))
         printf("Position by %s to be opened",m_symbol.Name());
      else
        {
         printf("Error opening SELL position by %s : '%s'",m_symbol.Name(),m_trade.ResultComment());
         printf("Open parameters : price=%f,TP=%f",price0,0.0);
        }
      res=true;
     }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+
Увеличение размера ЛОТА. ПОМОГИТЕ!!!
Увеличение размера ЛОТА. ПОМОГИТЕ!!!
  • 2008.03.07
  • www.mql5.com
Скажите, можно ли как то увеличить размер лота с каждой сделки....??? К примеру, у меня депозит 100, торгую с лотом 0.50. депозит 200, торую 1...
 

#property version "1.018"

通貨単位での損失のロットサイズを大きくする可能性を追加しました。

input string   tL="----  Lots Parameters    -----";              //
input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots1                     = 0.01;              // Lots 1
input int      InpLots_01                   = 500;               // До убытка валюте Lots 0.01
input double   InpLots2                     = 0.02;              // Lots 2
input int      InpLots_02                   = 1000;              // До убытка валюте Lots 0.02
input double   InpLots3                     = 0.04;              // Lots 3
input int      InpLots_03                   = 2000;              // До убытка валюте Lots 0.04
input double   InpLots4                     = 0.08;              // Lots 4

--------------------------------

アクションのロットアップ。設定で金額を拾うだけで、4段階 - 最後の金額、2000以上はロット0.08を 開きます。

GBPUSDM5h

これらの行から画像では、オープンポジション、また、これらの行をトロールの設定で設定することができます

input string   t3="----- Trailing Line: 1   -----";              //
input string   InpObjUpName                 = "ZTOP";            // Obj: TOP (Horizontal Line)
input int      InpStep1                     = 20;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InpTradeCommand    = Line2_sells;       // Obj:  command:
input string   InpObjDownName               = "ZLOWER";          // Obj: LOWER (Horizontal Line)
input int      InpStep2                     = 20;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InTradeCommand     = Line1_buys;        // Obj:  command:
input ushort   InpObjTrailingStop           = 0;                 // 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   t4="----- Trailing Line: 2   -----";              //
input string   InpObjUpNameG                = "POT";             // Obj: TOP (Horizontal Line)
input int      InpStep3                     = 20;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InpTradeCommandG   = Line2_sells;       // Obj:  command:
input string   InpObjDownNameG              = "REWOL";           // Obj: LOWER (Horizontal Line)
input int      InpStep4                     = 20;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InTradeCommandG    = Line1_buys;        // Obj:  command:
input ushort   InpObjTrailingStopG          = 0;                 // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStepG          = 5;                 // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)

0 の代わりに set distance= 0;// Obj:トレーリングストップ(価格から対象までの距離、単位:ピップス)

----------------------------ВАЖНО!

シグナルが発生したら、バーからさらにバウンドするようにラインを設定しないと、何度もシグナルが発生することになります。

以下は、ホリゾンタルラインをトローリングして、コマンドをトリガーしたときに同じバーにバウンスバックするときの状況です。

XAUUSDM5

----------------------------------

水平線が繰り返されないように、0 = 20 する// Obj: グリッドのステップ、points("0" -> false)

がゼロの場合、コマンドを実行して削除されます。

ファイル:
 
Alexsandr San:

この機能は、損失から、ロットを増加させる。

この人に感謝https://www.mql5.com/ru/forum/107406#comment_3018721

2732

今日、この機能を損切り用の水平線でテストしました(価格が間違った方向に行き、途中で水平線に出会うと、そこからポジションを開き、線がさらに遠くに飛び、所定の距離だけ、損失が増え、次に水平線に当たると、ロットが増えて開くことになります)。

唖然としています。- このロジックは、すべてをプラスに引っ張ります。こんな奇跡、いくらで売れるんだろう!

スナップショット3

-------------------------------------------------------------- これは別の例で、価格が私に不利になるものです。

米ドル円M5 図1

USDJPYM5z 図2

撮影者 図3

 

仕組みを理解するために

ユーティリティにはボタン(BUYとSELL)があり、ホリゾンタルラインが 行うすべてのコマンドを実行します - テスターで調べれば、どのように動作するかわかります。

ボタンの設定 ----------------

input string   t7="----- Button:            -----";              //
input ENUM_TRADE_COMMAND InpTradeCommandBut = Line1_buys;        // Obj(BUY):  command:Button: BUY
input ENUM_TRADE_COMMAND InTradeCommandBut  = Line2_sells;       // Obj(SELL):  command:Button: SELL
input int      TrailingStop_STOP_LEVEL      = 36;                // Button: Trailing Stop LEVEL

ホリゾンタルラインの設定 --------------------

input string   t3="----- Trailing Line: 1   -----";              //
input string   InpObjUpName                 = "ZTOP";            // Obj: TOP (Horizontal Line)
input int      InpStep1                     = 20;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InpTradeCommand    = Line2_sells;       // Obj:  command:
input string   InpObjDownName               = "ZLOWER";          // Obj: LOWER (Horizontal Line)
input int      InpStep2                     = 20;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InTradeCommand     = Line1_buys;        // Obj:  command:
input ushort   InpObjTrailingStop           = 0;                 // 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   t4="----- Trailing Line: 2   -----";              //
input string   InpObjUpNameG                = "POT";             // Obj: TOP (Horizontal Line)
input int      InpStep3                     = 20;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InpTradeCommandG   = Line2_sells;       // Obj:  command:
input string   InpObjDownNameG              = "REWOL";           // Obj: LOWER (Horizontal Line)
input int      InpStep4                     = 20;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InTradeCommandG    = Line1_buys;        // Obj:  command:
input ushort   InpObjTrailingStopG          = 0;                 // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStepG          = 5;                 // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)

以下は、実行可能なコマンドです --------------------------------。

//+------------------------------------------------------------------+
//| ENUM_TRADE_COMMAND                                                 |
//+------------------------------------------------------------------+
enum ENUM_TRADE_COMMAND
  {
   Turn_Off=0,       // TURN OFF
   Line1_Line1=1,    // Line: LOWER
   Line2_Line2=2,    // Line: TOP
   Line_Line=3,      // Line: LOWER+Line: TOP
   Line1_buys=4,     // Line: LOWER+Buy's
   Line2_sells=5,    // Line: TOP+Sell's
   sells_Line1=6,    // Line: LOWER+Sell's
   buys_Line2=7,     // Line: TOP+Buy's
   close_buys=8,     // Close All Buy's
   close_sells=9,    // Close All Sell's
   close_all=10,     // Close All Buy's and Sell's
   open_buy=11,      // Open Buy
   open_sell=12,     // Open Sell
   close_open_b=13,  // Close Sell+Open Buy
   close_open_s=14,  // Close Buy+Open Sell
   open_buy_sell=15, // Open Buy and Sell
  };
//+------------------------------------------------------------------+

プロフィット機能

------------ 利益は共通ではありません - 買いは独自の利益を持っている 売りは独自の利益を持っている(例えば、あなたはそれらの各々は100を取ることはありませんが、100を獲得したい設定で 購入し、販売で 別のものを開いて2つの位置を持っています)また、各ペアは別の利益を持って、それぞれが100を(あなたが複数のペアで作業している場合 - 各ペアは、別々にユーティリティを設定する必要があります)取る必要が あります。

input double   TargetTakeProfit             = 1000000;           // Прибыль на паре в валюте
Важно!!! правильно настроить , открытии лота (До убытка валюте)
input string   tL="----  Lots Parameters    -----";              //
input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots1                     = 0.01;              // Lots 1
input int      InpLots_01                   = 500;               // До убытка валюте Lots 0.01
input double   InpLots2                     = 0.02;              // Lots 2
input int      InpLots_02                   = 1000;              // До убытка валюте Lots 0.02
input double   InpLots3                     = 0.04;              // Lots 3
input int      InpLots_03                   = 2000;              // До убытка валюте Lots 0.04
input double   InpLots4                     = 0.08;              // Lots 4

ペアの損失は、トータル損失と(買いと売り、それぞれに損失がある)の2つです。

ここでは、sell yourからbuy your lossで計算します。

 

わずかな補正 -ホリゾンタルラインが 信号に対してより速く反応するようにします。

価格が水平線に触れ、交差したが、トリガーされなかったという状況があった。

動作せず

#property version "1.019"

ファイル:
 

新しい機能を試してみる .カレンダーが信号を出し、その信号からコマンドを選択することができる

input string   t10="---- CalendarValueLast  -----";              //
input bool     Inpndar                      = false;             // Сигнал Календаря Включить
input ENUM_TRADE_COMMAND InpCalendCommandS  = Line_Line;         // Trade command:

他にカレンダーに必要なコマンドは何か、まだ考える必要がありますね。

これ、もう持ってるんですよ。

//+------------------------------------------------------------------+
//| ENUM_TRADE_COMMAND                                                 |
//+------------------------------------------------------------------+
enum ENUM_TRADE_COMMAND
  {
   Turn_Off=0,       // TURN OFF
   Line1_Line1=1,    // Line: LOWER
   Line2_Line2=2,    // Line: TOP
   Line_Line=3,      // Line: LOWER+Line: TOP
   Line1_buys=4,     // Line: LOWER+Buy's
   Line2_sells=5,    // Line: TOP+Sell's
   sells_Line1=6,    // Line: LOWER+Sell's
   buys_Line2=7,     // Line: TOP+Buy's
   close_buys=8,     // Close All Buy's
   close_sells=9,    // Close All Sell's
   close_all=10,     // Close All Buy's and Sell's
   open_buy=11,      // Open Buy
   open_sell=12,     // Open Sell
   close_open_b=13,  // Close Sell+Open Buy
   close_open_s=14,  // Close Buy+Open Sell
   open_buy_sell=15, // Open Buy and Sell
  };
//+------------------------------------------------------------------+

画像はユーティリティを設定し、これは画像1です。2番目は実行されたコマンド(与えられた距離で水平線)になります

スナップショット7写真1


 
Alexsandr San:

今日、この機能を損切り用の水平線重複機能でテストしてみました(価格が間違った方向に行き、途中で水平線に出会い、そこからポジションを開き、線がさらに跳ね返されると、所定の距離だけ、損失が増え、次に水平線に触れると、ロットが増えて開くことになります)。

唖然としています。- このロジックは、すべてをプラスに引っ張ります。そんな奇跡の 一品、いくらで売れるんだろう!

"ハローマーチン "だ:-)それがドローダウンによる出来高の増加です。説明から判断すると、グリッドでもある。

これは悪いことではありませんが、あなたは自分自身に正直でなければならない - それは小さな "市場は私に対して行った "から引き出しますが、預金を失うことのリスクはそこに大きいです。

理由: