完善顾问的战略 - 页 4

 
IRIP:

我在哪里可以看到关于如何设置止损的信息?

我需要,比如说,在Low bar 2处停止。


https://book.mql4.com/ru/trading/index
 
谢谢你
 

现在有几个挑战

1.达到一定的利润时,达到收支平衡

2.通过分形或固定数字进行拖网

 
IRIP:

现在有几个挑战

1.达到一定的利润时,达到收支平衡

2.通过分形或固定数字进行拖网


开始写,边写边问...
 
IRIP:
if ( ( (Low[0]>Low[1]) && (Low[1]<Low[2]) && (Low[1]<Low[2]) && ( High[1]<High[2]) ) BuyOp=true;

if ( ( (High[0]<High[1]) && (Low[0]<Low[1]) && (High[1]>High[2]) && ( Open[0]<Close[1]) ) SellOp=true;


出售 .而且没有Trall或Breakeven会帮助你。而且,如果你不利用任何规律性的东西,它永远不会有帮助,就像在这个案例中。

 
DYN:


你会卖掉的。而且,任何拖网或收支平衡都不能帮助你。而且,如果你不像本案那样利用任何规律性的东西,它将永远不会有帮助。


它将。但是,这个人正在学习编程,而且还不赖!"。
 
ktest0:

他将。但一个人学会了编程,这并不是一件坏事!

是的,我同意。为这一点向这位老兄致敬。一开始从头开始学习是很困难的--我知道是怎么回事--)--)--))。
 
ktest0:

他将。但一个人学会了编程,这并不是一件坏事!

是的,我真的想学习如何编程。
 


书籍,这很好。但是,举例来说,我找到了一个顾问,一般来说,他能满足我的需要

//+------------------------------------------------------------------+

//| TrailingStopLight.mq4|

//| Copyright © 2011, Khlystov Vladimir | 版权所有。

//| http://cmillion.narod.ru |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2011, cmillion@narod.ru"

#属性链接 "http://cmillion.narod.ru"

#property show_inputs

//--------------------------------------------------------------------

外部int Stoploss = 0, //stopploss,如果是0,保持不变。

盈利 = 0; //盈利,如果是0,保持不变

外部int TrailingStop = 20; //tramp length, if 0, then no trailing stop

外部int StepTrall = 0; //tramp step - 移动StopLoss的距离不超过StepTrall。

外部int NoLoss = 10, //在指定的利润点数上转移到盈亏平衡点,如果是0,则不转移到盈亏平衡点。

MinProfitNoLoss = 0; // 转移到收支平衡的最低利润

//--------------------------------------------------------------------

int STOPLEVEL,TimeBar;

//--------------------------------------------------------------------

int init()

{

}

//--------------------------------------------------------------------

int deinit()

{

ObjectDelete("SLb")。

ObjectDelete("SLs")。

}

//--------------------------------------------------------------------

int start()

{

//while(!IsStopped())

{

//RefreshRates()。

STOPLEVEL=MarketInfo(Symbol(),MODE_STOPLEVEL)。

双OSL,OTP,OOP,StLo,SL,TP。

双重 Profit,ProfitS,ProfitB,LB,LS,NLb,NLs,price_b,price_s,OL,sl;

int b,s,OT,OMN;

for (int i=OrdersTotal()-1; i>=0; i--)

{

如果(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

{

OMN = OrderMagicNumber()。

如果(OrderSymbol() == Symbol()

{

OOP = NormalizeDouble(OrderOpenPrice(),Digits)。

OT = OrderType()。

OL = OrderLots()。

如果(OT==OP_BUY)

{

price_b = price_b+OOP*OL。

b++; LB+= OL。

ProfitB+=OrderProfit()+OrderSwap()+OrderCommission()。

}

如果(OT==OP_SELL)

{

price_s = price_s+OOP*OL。

s++;LS+=OL。

ProfitS+=OrderProfit()+OrderSwap()+OrderCommission()。

}

}

}

}

ObjectDelete("SLb")。

ObjectDelete("SLs")。

如果(b>0)

{

NLb = NormalizeDouble(price_b/LB,Digits)。

ObjectCreate("SLb",OBJ_ARROW,0,Time[0],NLb,0,0,0)。

ObjectSet("SLb",OBJPROP_ARROWCODE,6)。

ObjectSet("SLb",OBJPROP_COLOR,Blue)。

}

如果(s>0)

{

NLs = NormalizeDouble(price_s/LS,Digits)。

ObjectCreate("SLs",OBJ_ARROW,0,Time[0],NLs,0,0,0)。

对象集("SLs",OBJPROP_ARROWCODE,6)。

ObjectSet("SLs",OBJPROP_COLOR,Red)。

}

int OTicket。

for (i=0; i<OrdersTotal(); i++)

{

如果(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

{

如果(OrderSymbol()==Symbol())

{

OT = OrderType()。

OSL = NormalizeDouble(OrderStopLoss(),Digits)。

OTP = NormalizeDouble(OrderTakeProfit(),Digits)。

OOP = NormalizeDouble(OrderOpenPrice(),Digits)。

sl=osl; tp=otp;

如果(OT==OP_BUY)

{

b++;

如果(OSL==0 && Stoploss>=STOPLEVEL && Stoploss! =0)

{

SL = NormalizeDouble(Bid - Stoploss * Point,Digits)。

}

否则SL=OSL。

如果(OTP==0 && Takeprofit>=STOPLEVEL && Takeprofit! =0)

{

TP = NormalizeDouble(Ask + Takeprofit * Point,Digits)。

}

否则TP=OTP。

如果(NoLoss>=STOPLEVEL && OSL<NLb && NoLoss!=0)

{

如果(OOP<=NLb && NLb!=0 && NLb <= NormalizeDouble(Bid-NoLoss*Point,Digits))

SL = NormalizeDouble(NLb+MinProfitNoLoss*Point,Digits)。

}

如果(TrailingStop>=STOPLEVEL && TrailingStop!=0)

{

StLo = NormalizeDouble(Bid - TrailingStop*Point,Digits)。

如果(StLo>=NLb && NLb!=0)如果(StLo>OSL)SL=StLo。

}

如果(SL != OSL || TP != OTP)

{

OTicket=OrderTicket()。

如果(!OrderModify(OTicket,OOP,SL,TP,0,White))Print("OrderModify Error",GetLastError())。

}

}

如果(OT==OP_SELL)

{

s++;

如果(OSL==0 && Stoploss>=STOPLEVEL && Stoploss! =0)

{

SL = NormalizeDouble(Ask + Stoploss * Point,Digits)

}

否则SL=OSL。

如果(OTP==0 && Takeprofit>=STOPLEVEL && Takeprofit! =0)

{

TP = NormalizeDouble(Bid - Takeprofit * Point,Digits)。

}

否则TP=OTP。

如果(NoLoss>=STOPLEVEL && (OSL>NLs || OSL==0) && NoLoss!=0)

{

如果(OOP>=NLs && NLs!=0 && NLs >= NormalizeDouble(Ask+NoLoss*Point,Digits))

SL = NormalizeDouble(NLs-MinProfitNoLoss*Point,Digits)。

}

如果(TrailingStop>=STOPLEVEL && TrailingStop!=0)

{

StLo = NormalizeDouble(Ask + TrailingStop*Point,Digits);

如果(StLo<=NLs &&NLs!=0)如果(StLo<OSL ||OSL==0)SL = StLo;

}

如果((SL != OSL || OSL==0) || TP != OTP)

{

OTicket=OrderTicket()。

如果(!OrderModify(OTicket,OOP,SL,TP,0,White))Print("OrderModify Error",GetLastError())。

}

}

}

}

}

如果(IsTesting())

{

如果(TimeBar!=Time[0])

{

OrderSend(Symbol(),OP_BUY,1,NormalizeDouble(Ask,Digits),3,0,0, "test",0,0,Blue)。

OrderSend(Symbol(),OP_SELL,1,NormalizeDouble(Bid,Digits),3,0,0, "test",0,0,Red)。

TimeBar=Time[0];

}

}

//Sleep(1000);

}

}

//--------------------------------------------------------------------

它(理论上)可以插入我的吗?

 
IRIP:


书籍,这很好。但是,举例来说,我找到了一个顾问,一般来说,他能满足我的需要

//+------------------------------------------------------------------+

//|                                            TrailingStopLight.mq4 |

//|                              Copyright © 2011, Khlystov Vladimir |

//|                                         http://cmillion.narod.ru |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2011, cmillion@narod.ru"

#property link      "http://cmillion.narod.ru"

#property show_inputs

//--------------------------------------------------------------------
extern int Stoploss             = 0,//стоплосс, если 0 то не изменяется
           Takeprofit           = 0;//тейкпрофит, если 0 то не изменяется
extern int TrailingStop         = 20;//длинна тралла, если 0 то нет тралла
extern int StepTrall            = 0;//шаг тралла - перемещать стоплосс не ближе чем StepTrall
extern int NoLoss               = 10,//перевод в безубыток при заданном кол-ве пунктов прибыли, если 0 то нет перевода в безубыток
           MinProfitNoLoss      = 0//минимальная прибыль при переводе вбезубыток
//--------------------------------------------------------------------
int  STOPLEVEL,TimeBar;
//--------------------------------------------------------------------
int init()
{

}
//--------------------------------------------------------------------
int deinit()
{
   ObjectDelete("SLb");
   ObjectDelete("SLs");
}
//--------------------------------------------------------------------
int start()                                  
{
   //while(!IsStopped())
   {
      //RefreshRates();
      STOPLEVEL=MarketInfo(Symbol(),MODE_STOPLEVEL);
      double OSL,OTP,OOP,StLo,SL,TP;
      double Profit,ProfitS,ProfitB,LB,LS,NLb,NLs,price_b,price_s,OL,sl;
      int b,s,OT,OMN;
      for (int i=OrdersTotal()-1; i>=0; i--)
      {                                               
         if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         {
            OMN = OrderMagicNumber();
            if (OrderSymbol() == Symbol())
            {
               OOP = NormalizeDouble(OrderOpenPrice(),Digits);

               OT = OrderType();
               OL = OrderLots();
               if (OT==OP_BUY)
               {
                  price_b = price_b+OOP*OL;
                  b++; LB+= OL;
                  ProfitB+=OrderProfit()+OrderSwap()+OrderCommission();
               }
               if (OT==OP_SELL)
               {
                  price_s = price_s+OOP*OL;

                  s++;LS+= OL;

                  ProfitS+=OrderProfit()+OrderSwap()+OrderCommission();

               }

            }

         }

      }

      ObjectDelete("SLb");

      ObjectDelete("SLs");

      if (b>0) 

      {

         NLb = NormalizeDouble(price_b/LB,Digits);

         ObjectCreate("SLb",OBJ_ARROW,0,Time[0],NLb,0,0,0,0);                     

         ObjectSet   ("SLb",OBJPROP_ARROWCODE,6);

         ObjectSet   ("SLb",OBJPROP_COLOR, Blue);

      }

      if (s>0) 

      {

         NLs = NormalizeDouble(price_s/LS,Digits);

         ObjectCreate("SLs",OBJ_ARROW,0,Time[0],NLs,0,0,0,0);                     

         ObjectSet   ("SLs",OBJPROP_ARROWCODE,6);

         ObjectSet   ("SLs",OBJPROP_COLOR, Red);

      }

      int OTicket;

      for (i=0; i<OrdersTotal(); i++)

      {    

         if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

         {

            if (OrderSymbol()==Symbol())

            { 

               OT = OrderType(); 

               OSL = NormalizeDouble(OrderStopLoss(),Digits);

               OTP = NormalizeDouble(OrderTakeProfit(),Digits);

               OOP = NormalizeDouble(OrderOpenPrice(),Digits);

               SL=OSL;TP=OTP;

               if (OT==OP_BUY)             

               {  

                  b++;

                  if (OSL==0 && Stoploss>=STOPLEVEL && Stoploss!=0)

                  {

                      SL = NormalizeDouble(Bid - Stoploss   * Point,Digits);

                  } 

                  else SL=OSL;

                  if (OTP==0 && Takeprofit>=STOPLEVEL && Takeprofit!=0)

                  {

                      TP = NormalizeDouble(Ask + Takeprofit * Point,Digits);

                  } 

                  else TP=OTP;

                  if (NoLoss>=STOPLEVEL && OSL<NLb && NoLoss!=0)

                  {

                     if (OOP<=NLb && NLb!=0 && NLb <= NormalizeDouble(Bid-NoLoss*Point,Digits)) 

                        SL = NormalizeDouble(NLb+MinProfitNoLoss*Point,Digits);

                  }

                  if (TrailingStop>=STOPLEVEL && TrailingStop!=0)

                  {

                     StLo = NormalizeDouble(Bid - TrailingStop*Point,Digits); 

                     if (StLo>=NLb && NLb!=0) if (StLo > OSL) SL = StLo;

                  }

                  if (SL != OSL || TP != OTP)

                  {  

                     OTicket=OrderTicket();

                     if (!OrderModify(OTicket,OOP,SL,TP,0,White)) Print("Error OrderModify ",GetLastError());

                  }

               }                                         

               if (OT==OP_SELL)        

               {

                  s++;

                  if (OSL==0 && Stoploss>=STOPLEVEL && Stoploss!=0)

                  {

                     SL = NormalizeDouble(Ask + Stoploss   * Point,Digits);

                  }

                  else SL=OSL;

                  if (OTP==0 && Takeprofit>=STOPLEVEL && Takeprofit!=0)

                  {

                      TP = NormalizeDouble(Bid - Takeprofit * Point,Digits);

                  }

                  else TP=OTP;

                  if (NoLoss>=STOPLEVEL && (OSL>NLs || OSL==0) && NoLoss!=0)

                  {

                     if (OOP>=NLs && NLs!=0 && NLs >= NormalizeDouble(Ask+NoLoss*Point,Digits)) 

                        SL = NormalizeDouble(NLs-MinProfitNoLoss*Point,Digits);

                  }

                  if (TrailingStop>=STOPLEVEL && TrailingStop!=0)

                  {

                     StLo = NormalizeDouble(Ask + TrailingStop*Point,Digits); 

                     if (StLo<=NLs && NLs!=0) if (StLo < OSL || OSL==0) SL = StLo;

                  }

                  if ((SL != OSL || OSL==0) || TP != OTP)

                  {  

                     OTicket=OrderTicket();

                     if (!OrderModify(OTicket,OOP,SL,TP,0,White)) Print("Error OrderModify ",GetLastError());

                  }

               } 

            }

         }

      }

      if (IsTesting())

      {

         if (TimeBar!=Time[0])

         {

            OrderSend(Symbol(),OP_BUY,1,NormalizeDouble(Ask,Digits),3,0,0,"тест",0,0,Blue);

            OrderSend(Symbol(),OP_SELL,1,NormalizeDouble(Bid,Digits),3,0,0,"тест",0,0,Red);

            TimeBar=Time[0];

         }

      } 

      //Sleep(1000);

   } 
}
//--------------------------------------------------------------------

它(理论上)可以插入我的吗?

首先,学习如何用SRC 按钮插入代码!

这句话 "书是伟大的 "还需要证明!同时,你还想着要出去暗示一下。而 "不劳而获......",你可能知道结果,或者你会发现,而时间已经不多了!没有知识就没有出路!