我如何通过试验和错误组装我的顾问 - 页 47

 

但是,在代码中存在差异,来自指标的信号是不同的。

如果是这样,适合的指标较少

//---
   double BuyBuffer[];
   double SellBuffer[];
   ArraySetAsSeries(BuyBuffer,true);
   ArraySetAsSeries(SellBuffer,true);
   if(!iGetArray(handle_iCustom,1,0,2,BuyBuffer) || !iGetArray(handle_iCustom,0,0,2,SellBuffer))
     {
      ExtPrevBarsY=0;
      return(false);
     }
//---
   if(BuyBuffer[1]!=0.0)
     {

这样更好。

//---
   double main[],signal[];
   ArraySetAsSeries(main,true);
   ArraySetAsSeries(signal,true);
   int start_pos=0,count=3;
   if(!iGetArray(handle_iCustom,MAIN_LINE,start_pos,count,main) ||
      !iGetArray(handle_iCustom,SIGNAL_LINE,start_pos,count,signal))
     {
      ExtPrevBarsY=0;
      return(false);
     }

   if(main[1]>signal[1])
     {

我已经把它改成了这个!我仍然检查专家顾问的可用性,一切似乎都在工作。

它与这种类型的指标配合得很好(下面的文件)。

附加的文件:
2.mq5  17 kb
 

为了避免开仓 和平仓的混淆,最好将所有的线和指标设置为正确的方向,不要使用反向的

否则,你会感到困惑--尤其是在设置中有一个选项(反转适用于所有线条和指标)。

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)

我可以用一个或两个指标进行幻想。

你只需要拿起,指示器--像这样(照片)。

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

图片来源

我做了一个叫( 2 )的指标。

附加的文件:
2.mq5  17 kb
 
Alexsandr San:

我想从指示器中获得一些新的功能,我想做的就是这一切。

我可以用一个或两个指标进行幻想。

你只需要选择,指标 - 像这样(照片)

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

我作弊的指标被称为( 2 )

我检查了1分钟的工作情况--它工作正常。

快照2

 
Alexsandr San:

检查1分钟的工作情况 - 工作正常


expertWWW_Trailing_Line.mq596 kb 工作正常,没有错误。

只是,需要在手动版本的测试器中添加一个用于信息和测试的面板。

小组

 
Alexsandr San:

专家工作顺利WWW_Trailing_Line.mq596 kb,没有错误。

只是,你需要在手动版本的测试器中添加一个用于信息和测试的面板。

我添加了一个面板--现在你可以在测试器中做一些手动测试。

命令_拖曳线

其设置是什么

//+------------------------------------------------------------------+
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 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

附加的文件: