新人对MQL4和MQL5的任何问题,对算法和代码的帮助和讨论 - 页 464

 

@Konstantin Nikitin 对你来说更容易!你是个专家!你是个专家。我正在学习!

if(!OrderSelect(i,SELECT_BY_POS)) continue;
     if(OrderSymbol()!=Symbol()) continue;
А это как прочитать? Если (Ордер не выбран) продолжить;
                     Если (Текущий Символ не равен Символу) продолжить; Так? Или как?
 

Rewerpool:

你怎么看这个?如果(未选择订单)继续。

如果(当前符号不等于符号)继续;对吗?或如何?

操作员继续

 

@Konstantin Nikitin 明白了,所以:如果有什么问题,请纠正我。

if(!OrderSelect(i,SELECT_BY_POS)) continue;
Если (Ордер не выбран ордер) начать цикл снова; //(Вернутся в начало функции)
if(OrderSymbol()!=Symbol()) continue;
Если (ОрдерСимвола не равен текущему Графику)начать цикл снова; //(Вернутся в начало функции)


还有一个问题:!"OrderSelect"--是指:没有订单还是没有选中订单?

 
Rewerpool:

明白了,所以:如果有什么问题,请纠正我!。

如果没有选择顺序,则选择循环的下一个元素

另外,这里有一个问题:!"OrderSelect"--它的意思是:不是一个订单,还是没有选中一个订单?

操作和表达式,看看那里的逻辑操作

 
@Konstantin Nikitin 把它放在一起是这样的。
 void STOP_TAKE()
   int tip,Ticket;
   double OOP,OSL,OTP;
   int SPREAD    = (int)MarketInfo(Symbol(),MODE_SPREAD);
   if (stoploss<STOPLEVEL) stoploss=0; 
   if (takeprofit<STOPLEVEL) takeprofit=0; 

for(int i=0; i<OrdersTotal(); i++)
{
     if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
     if(OrderSymbol()!=Symbol()) continue;
     
     int tip = OrderType();
     if(tip!=OP_BUY && tip!=OP_BUYSTOP && tip!=OP_BUYLIMIT) continue;
     
     // переменные которые будут использоваться в любых ордерах
     int Ticket = OrderTicket();
     double OOP = OrderOpenPrice();
     
     //---
     switch( OrderMagicNumber() )
     {
          case Magic:    //----------Если Ордера Советника
               {
                if(tip<2)
           {
            OSL = OrderStopLoss();
            OTP = OrderTakeProfit();
            if ((OSL==0&&stoploss!=0)||(OTP==0&&takeprofit!=0))
            {  
              if (tip==OP_BUY || tip==OP_BUYSTOP || tip==OP_BUYLIMIT)             
               {
                  if (takeprofit!=0) TP = NormalizeDouble(OOP + takeprofit*Point,Digits); else TP=OTP;
                  if (stoploss!=0)   SL = NormalizeDouble(OOP - (stoploss+SPREAD)* Point,Digits); else SL=OSL;       
                  if (OrderModify(Ticket,OOP,SL,TP,0,White)) Print("STOP_TAKE",Ticket," SL ",OSL," -> ",SL,"   TP ",OTP," -> ",TP);
                  else Print(Symbol()," Error STOP_TAKE",GetLastError(),"  Ticket ",Ticket);
               }                                         
               if (tip==OP_SELL || tip==OP_SELLSTOP || tip==OP_SELLLIMIT)        
               {
                  if (takeprofit!=0) TP = NormalizeDouble(OOP - takeprofit*Point,Digits); else TP=OTP;
                  if (stoploss!=0)   SL = NormalizeDouble(OOP + (stoploss+SPREAD)* Point,Digits); else SL=OSL;             
                  if (OrderModify(Ticket,OOP,SL,TP,0,White)) Print("STOP_TAKE",Ticket," SL ",OSL," -> ",SL,"   TP ",OTP," -> ",TP);
                  else Print(Symbol()," Error STOP_TAKE",GetLastError(),"  Ticket ",Ticket);
               } 
            }
         }
               }
               break;

          default:       //----------Если Ордера Оператора 
               {
                 {
                if(tip<2)
           {
            OSL = OrderStopLoss();
            OTP = OrderTakeProfit();
            if ((OSL==0&&stoploss!=0)||(OTP==0&&takeprofit!=0))
            {  
              if (tip==OP_BUY || tip==OP_BUYSTOP || tip==OP_BUYLIMIT)             
               {
                  if (takeprofit!=0) TP = NormalizeDouble(OOP + takeprofit*Point,Digits); else TP=OTP;
                  if (stoploss!=0)   SL = NormalizeDouble(OOP - (stoploss+SPREAD)* Point,Digits); else SL=OSL;       
                  if (OrderModify(Ticket,OOP,SL,TP,0,White)) Print("STOP_TAKE",Ticket," SL ",OSL," -> ",SL,"   TP ",OTP," -> ",TP);
                  else Print(Symbol()," Error STOP_TAKE",GetLastError(),"  Ticket ",Ticket);
               }                                         
               if (tip==OP_SELL || tip==OP_SELLSTOP || tip==OP_SELLLIMIT)        
               {
                  if (takeprofit!=0) TP = NormalizeDouble(OOP - takeprofit*Point,Digits); else TP=OTP;
                  if (stoploss!=0)   SL = NormalizeDouble(OOP + (stoploss+SPREAD)* Point,Digits); else SL=OSL;             
                  if (OrderModify(Ticket,OOP,SL,TP,0,White)) Print("STOP_TAKE",Ticket," SL ",OSL," -> ",SL,"   TP ",OTP," -> ",TP);
                  else Print(Symbol()," Error STOP_TAKE",GetLastError(),"  Ticket ",Ticket);
               } 
            }
         }
               }
               }
     }
}
对吗?
 

增加了更多这样的内容。


6

 

为什么还要这样写呢?

if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
     if(OrderSymbol()!=Symbol()) continue;

如果你只把EA放在一个符号上,它将在所有的符号上工作?而魔术师将看到他自己的!

完全糊涂了!

 

我的朋友们,谁知道如何实现:一个EA可以获得一个指标的绝对值,例如iStohastic()。如何判断指标是否已离开超买或超卖区?

从视觉上看,像一个带有80和20水平的随机指标。

 

雷沃浦:好吧,你去吧,没有错误。

void STOP_TAKE(void)
{
   int SPREAD    = (int)MarketInfo(Symbol(),MODE_SPREAD);
   if (stoploss<STOPLEVEL) stoploss=0; 
   if (takeprofit<STOPLEVEL) takeprofit=0;

     for(int i=0; i<OrdersTotal(); i++)
     {
          if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
          if(OrderSymbol()!=Symbol()) continue;
     
          int tip = OrderType();
          if(  tip!=OP_BUY && tip!=OP_BUYSTOP && tip!=OP_BUYLIMIT &&
               tip!=OP_SELL && tip!=OP_SELLSTOP && tip!=OP_SELLLIMIT ) continue;
     
          // переменные которые будут использоваться в любых ордерах
          int Ticket = OrderTicket();
          double    OOP = OrderOpenPrice(),
                    OSL = OrderStopLoss(),
                    OTP = OrderTakeProfit();
     
          //---
          if( OrderMagicNumber() == Magic )
          { //----------Если Ордера Советника
               switch(tip)
               {
                    case OP_BUY:
                    case OP_BUYSTOP:
                    case OP_BUYLIMIT:
                         {
                              if (takeprofit!=0) TP = NormalizeDouble(OOP + takeprofit*Point,Digits); else TP=OTP;
                              if (stoploss!=0)   SL = NormalizeDouble(OOP - (stoploss+SPREAD)* Point,Digits); else SL=OSL;
                              if (OrderModify(Ticket,OOP,SL,TP,0,White)) Print("STOP_TAKE",Ticket," SL ",OSL," -> ",SL,"   TP ",OTP," -> ",TP);
                              else Print(Symbol()," Error STOP_TAKE",GetLastError(),"  Ticket ",Ticket);
                         }
                         break;
                         // end case
                         
                    default:
                         {
                              if (takeprofit!=0) TP = NormalizeDouble(OOP - takeprofit*Point,Digits); else TP=OTP;
                              if (stoploss!=0)   SL = NormalizeDouble(OOP + (stoploss+SPREAD)* Point,Digits); else SL=OSL;             
                              if (OrderModify(Ticket,OOP,SL,TP,0,White)) Print("STOP_TAKE",Ticket," SL ",OSL," -> ",SL,"   TP ",OTP," -> ",TP);
                              else Print(Symbol()," Error STOP_TAKE",GetLastError(),"  Ticket ",Ticket);
                         } // end case
               } // end switch

          }
          else
          { //----------Если Ордера Оператора
               switch(tip)
               {
                    case OP_BUY:
                    case OP_BUYSTOP:
                    case OP_BUYLIMIT:
                         {
                              if (takeprofit!=0) TP = NormalizeDouble(OOP + takeprofit*Point,Digits); else TP=OTP;
                              if (stoploss!=0)   SL = NormalizeDouble(OOP - (stoploss+SPREAD)* Point,Digits); else SL=OSL;       
                              if (OrderModify(Ticket,OOP,SL,TP,0,White)) Print("STOP_TAKE",Ticket," SL ",OSL," -> ",SL,"   TP ",OTP," -> ",TP);
                              else Print(Symbol()," Error STOP_TAKE",GetLastError(),"  Ticket ",Ticket);
                         }
                         break;
                         // end case
                         
                    default:
                         {
                              if (takeprofit!=0) TP = NormalizeDouble(OOP - takeprofit*Point,Digits); else TP=OTP;
                              if (stoploss!=0)   SL = NormalizeDouble(OOP + (stoploss+SPREAD)* Point,Digits); else SL=OSL;             
                              if (OrderModify(Ticket,OOP,SL,TP,0,White)) Print("STOP_TAKE",Ticket," SL ",OSL," -> ",SL,"   TP ",OTP," -> ",TP);
                              else Print(Symbol()," Error STOP_TAKE",GetLastError(),"  Ticket ",Ticket);
                         } // end case
               } // end switch
          } // end if
     } // end for
} // end STOP_TAKE
虽然你在修改EA和其他订单时有完全相同的逻辑。究竟为什么需要区分它们,还不是很清楚。但我认为这个原则是有用的。
 
@Konstantin Nikitin USEK POWERFUL!谢谢你的分析!!。