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

 

该指标有4条水平线--其中2条从指标Heiken_Ashi工作。

2个水平,你可以买入或卖出。 当它们穿过红色,你得到一个信号 -当它们穿过蓝色,你得到另一个信号

EURJPYM1

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

当处于中间位置时(在线(红色和蓝色)之间),信号不工作 - 将会工作,因为会向两边走出来

附加的文件:
LN_2.mq5  22 kb
 
Alexsandr San:

指标有4条水平线--其中2条从指标Heiken_Ashi工作。

2个水平,你可以买入或卖出。 当它们穿过红色,你得到一个信号 -当它们穿过蓝色,你得到另一个信号

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

当位于中间(红色和蓝色线之间)时,信号不工作 - 将工作,因为在任何方向上都是如此

我已将专家顾问附在该指标上。

您需要在图表上安装指标,然后在同一图表上安装专家顾问。

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

在开仓后,指标被删除。过了一会儿,我又设置了指标(如何检查专家的工作)。

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

当信号触发时,打开一个头寸,并将指标和线一起删除。


附加的文件:
Exp_LN_2.mq5  20 kb
 

联合两位专家进行手工交易

这个https://www.mql5.com/ru/code/24803

和这个https://www.mql5.com/ru/code/26353

AutoClose Line
AutoClose Line
  • www.mql5.com
Помощник закрытия позиции, если цена пересекла линию: Правило закрытия: цена Open и цена Close текущего бара должны оказаться по разные стороны от линии. Имя линии задаётся в параметре "Line name" - эту линию пользователь проводит сам. Тип линии может быть...
附加的文件:
 
Alexsandr San:

联合两位专家进行手工交易

这个https://www.mql5.com/ru/code/24803

和这个https://www.mql5.com/ru/code/26353

添加了另一行

//+------------------------------------------------------------------+
//| Enum Lor or Risk                                                 |
//+------------------------------------------------------------------+
enum ENUM_TRADE_COMMAND
  {
   close_buys=0,     // Close All Buy's
   close_sells=1,    // Close All Sell's
   close_all=2,      // Close All Buy's and Sell's
   open_buy=3,       // Open Buy
   open_sell=4,      // Open Sell
   open_buy_sell=5,  // Open Buy and Sell
  };
//--- input parameters
input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots                      = 0.01;              // Lots
input ushort   InpSignalsFrequency          = 10;                // Search signals, in seconds (min value "10")
input string   InpNameR                     = "LineR";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandR   = close_all;         // Trade command:
input bool     ObjRevers                    = false;             // Obj: Revers
input string   InpNameS                     = "LineS";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandS   = close_all;         // Trade command:
input ulong    InpMagic                     = 78712995;          // Magic number
//---
附加的文件:
 
Alexsandr San:

又加了一行。

对于一个成熟的专家来说,缺少 -

1 - 止损、止盈,单位为点(不可见)。

2 - 来自水平线的拖曳式止损

3 - 来自指示器的信号

我将进一步修改专家顾问2_LineOpenClose.mq5

//--- input parameters
input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots                      = 0.01;              // Lots
input ushort   InpSignalsFrequency          = 10;                // Search signals, in seconds (min value "10")
input string   InpNameR                     = "LineR";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandR   = close_all;         // Trade command:
input bool     ObjRevers                    = false;             // Obj: Revers
input string   InpNameS                     = "LineS";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandS   = close_all;         // Trade command:
input ulong    InpMagic                     = 78712995;          // Magic number
//---
 
Alexsandr San:

对于一个成熟的专家来说,缺少 -

1 - 止损、止盈,单位为点(不可见)。

2 - 水平线的拖曳止损

3 - 来自指示器的信号

我将进一步修改专家顾问2_LineOpenClose.mq5

新增 --指标的信号

这样

//+------------------------------------------------------------------+
//| Get value of buffers                                             |
//+------------------------------------------------------------------+
double iGetArray(const int handle,const int buffer,const int start_pos,const int count,double &arr_buffer[])
  {
   bool result=true;
   if(!ArrayIsDynamic(arr_buffer))
     {
      Print("This a no dynamic array!");
      return(false);
     }
   ArrayFree(arr_buffer);
//--- reset error code
   ResetLastError();
//--- fill a part of the iBands array with values from the indicator buffer
   int copied=CopyBuffer(handle,buffer,start_pos,count,arr_buffer);
   if(copied!=count)
     {
      //--- if the copying fails, tell the error code
      PrintFormat("Failed to copy data from the indicator, error code %d",GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
     }
   return(result);
  }
//+------------------------------------------------------------------+
//| Search trading signals                                           |
//+------------------------------------------------------------------+
bool SearchTradingSignals(void)
  {
//--- we work only at the time of the birth of new bar
   datetime time_0=iTime(m_symbol.Name(),Period(),0);
   if(time_0==ExtPrevBarsY)
      return(true);
   ExtPrevBarsY=time_0;
   if(!m_symbol.RefreshRates())
     {
      ExtPrevBarsY=0;
      return(false);
     }
//---
   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)
     {
      switch(InpTradeCommandY)
        {
         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;
        }
     }
   if(SellBuffer[1]!=0.0)
     {
      switch(InpTradeCommandU)
        {
         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;
        }
     }
//---
   return(true);
  }
//+------------------------------------------------------------------+

现在在设置中

//--- input parameters
input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots                      = 0.01;              // Lots
input ushort   InpSignalsFrequency          = 10;                // Search signals, in seconds (min value "10")
input string   InpNameR                     = "LineR";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandR   = open_buy;          // Trade command:
input string   InpNameS                     = "LineS";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandS   = open_sell;         // Trade command:
input string   short_name             = "Examples\\ZigzagColor"; // Name Indicators
input ENUM_TRADE_COMMAND InpTradeCommandY   = open_buy;          // Trade command: (BuyBuffer Indicators)
input ENUM_TRADE_COMMAND InpTradeCommandU   = open_sell;         // Trade command: (SellBuffer Indicators)
input bool     ObjRevers                    = false;             // Obj: Revers
//---

检查一个指示信号

杆数

砾石

附加的文件:
XXX_Ind.mq5  52 kb
 
Alexsandr San:

对于一个成熟的专家来说,缺少 -

1 - 止损、止盈,单位为点(不可见)。

2 - 水平线的拖曳止损

3 - 来自指示器的信号

我将对专家顾问2_LineOpenClose.mq5 进行微调。

我还添加了水平线的追踪止损。我算是把所有东西都加进去了,现在检查它的可操作性。

以下是设置

//+------------------------------------------------------------------+
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:        -----";              //
input string   short_name                   = "Examples\\ZigzagColor"; // Name Indicators
input bool     InpIndicators                = false;             // Indicators: Start (true)
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
//---


附加的文件:
 
Alexsandr San:

也添加了水平线的追踪止损。我想我已经添加了所有的东西,现在我只需要检查它是否工作。

以下是设置

工作的原则,这里的这些参数。

当资金达到给定的目标时,所有未平仓货币对的头寸将被平仓,所有图表将 变为"ADX "模式

(重要的是,在设置中必须写上高于你的余额的数字),专家顾问将关闭所有已开的头寸,并改变模板的图表。

//+------------------------------------------------------------------+
input string   t="-----  Parameters         -----";              //
input string   Template                     = "ADX";             // Имя шаблона(without '.tpl')
input double   TargetProfit                 = 999999.99;         // Цель Баланса(Ваш Баланс + сумма)

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

批量参数。

你能否将一个位置设置为0.06,或将6个位置设置为0.01

input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots                      = 0.01;              // Lots

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

参数与获利T。

它是由点数触发的(如果是 "0",它将关闭头寸),有必要指定距离。

input int      InpTakeProfit                = 50;                // Take Profit ("0"-No. 5<100)

XXX_Trailing Line.mq5

 
Alexsandr San:

新增 --指标的信号

像这样。

在设置中,它现在是这样的

检查来自指示器的信号

该指标只开仓平仓,我从终端的专家顾问(Moving Average)中提取的。

我罚了一点反转

//+------------------------------------------------------------------+
//| Check for close position conditions                              |
//+------------------------------------------------------------------+
void CheckForClose(void)
  {
//---
   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))
     {
      return;
     }
//--- positions already selected before
   bool signal=false;
   long type=PositionGetInteger(POSITION_TYPE);
   if(ObjRevers)
     {
      if(type==(long)POSITION_TYPE_BUY && BuyBuffer[1]!=0.0)
         signal=true;
      if(type==(long)POSITION_TYPE_SELL && SellBuffer[1]!=0.0)
         signal=true;
     }
   if(!ObjRevers)
     {
      if(type==(long)POSITION_TYPE_BUY && SellBuffer[1]!=0.0)
         signal=true;
      if(type==(long)POSITION_TYPE_SELL && BuyBuffer[1]!=0.0)
         signal=true;
     }
//--- additional checking
   if(signal)
     {
      if(TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) && Bars(_Symbol,_Period)>100)
         m_trade.PositionClose(_Symbol,3);
     }
//---
  }
//+------------------------------------------------------------------+

图片来源

使用信号指标的最简单的交易系统

2012年1月13日,13:27



典型的信号灯、信号指示器的样本

目前在代码库 中有很多类似的指标。 为了本文的目的,我将只给出几个源资源的链接。


附加的文件:
 
Alexsandr San:

从指标上看,只有开仓,关闭时,我采取了终端中的专家顾问的方式(移动平均线)。

我对反转进行了一些细化

我不喜欢平仓的时候。我正在寻找一种方法来纠正这个功能,以便从一个指标中关闭一个头寸

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

我把它修好了,我从移动平均线 指标中添加了它

//+------------------------------------------------------------------+
//| Position select depending on netting or hedging                  |
//+------------------------------------------------------------------+
bool SelectPosition()
  {
   bool res=false;
//--- check position in Hedging mode
   if(ExtHedging)
     {
      uint total=PositionsTotal();
      for(uint i=0; i<total; i++)
        {
         string position_symbol=PositionGetSymbol(i);
         if(_Symbol==position_symbol && InpMagic==PositionGetInteger(POSITION_MAGIC))
           {
            res=true;
            break;
           }
        }
     }
//--- check position in Netting mode
   else
     {
      if(!PositionSelect(_Symbol))
         return(false);
      else
         return(PositionGetInteger(POSITION_MAGIC)==InpMagic); //---check Magic number
     }
//--- result for Hedging mode
   return(res);
  }
//+------------------------------------------------------------------+

而在OnTick()中

      if(InpCloseOpposite && InpIndicators)
        {
         //---
         if(SelectPosition())
            CheckForClose();
         else
            SearchTradingSignals();
        }
      if(!InpCloseOpposite && InpIndicators)
        {
         SearchTradingSignals();
        }

事实证明,SelectPosition()应该通过它。

附加的文件: