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

 
MakarFX:

我希望一切都清楚了。

//+------------------------------------------------------------------+
//|                                             AC_AO_Makar.mq4      |
//|                                               fxmvv@mail.ru      |
//+------------------------------------------------------------------+
extern double Lots       =  1;
extern double StopLoss   =  10000;
extern double TakeProfit =  10000;
//+------------------------------------------------------------------+
int init(){}
int deinit(){}
int start()
{
   int total;
   if(Bars < 10)
   {
      Print("Bars less than 10");
      return(0); 
   } 
//====================================   
   bool Buy  =  (iCustom(NULL,0,"FiboBars2",10,5,1)&&iCustom(NULL,0,"FiboBars_3",2,19,190,5,1));
//help      
   bool Sell =  (iCustom(NULL,0,"FiboBars2",10,5,0)&&iCustom(NULL,0,"FiboBars_3",2,19,190,5,0));
//=================================
//Возвращает общее количество открытых и отложенных ордеров
   total = OrdersTotal(); 
   if(total < 1) // ордеров нет
   {
      if (Buy)
       if(OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Bid-StopLoss*Point,
           Bid+TakeProfit*Point) == 0) 
           Sleep(5000);
//help  OrderSend(Symbol(),OP_BUY,lot,price,slippage,stoploss, 
//takeprofit,      comment,magic,expiration,arrow_color);
      if(Sell)
       if(OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Ask+StopLoss*Point,
          Ask-TakeProfit*Point) == 0) 
           Sleep(5000);
   }
//==================================== OrderClose,
   else // есть ордер
   {
     OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
      if (OrderSymbol() != Symbol()) return(0);
       
        if(OrderType() == OP_BUY && Sell) 
          OrderClose(OrderTicket(),OrderLots(),Bid,5);
        if(OrderType() == OP_SELL && Buy) 
          OrderClose(OrderTicket(),OrderLots(),Ask,5);
   }
}

对不起,请看一下盒子,交易没有打开。

 
darirunu1:

对不起,请你看一下这个,交易没有打开。

0_о

它看起来不像是一个用于交易的EA,把它做成这样,并把条件放在那里



明天我将给你更多细节。

 
MakarFX:

0_о

它看起来并不像一个用于交易的EA,做到这一点,并把条件放在那里。



明天会有更多细节。

就是这样做的。

 
darirunu1:

就是这样做的。

这就是一个干净的模板的样子

//+------------------------------------------------------------------+
//|                                                       Expert.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   
  }
//+------------------------------------------------------------------+
你的MetaEditor是什么版本?
 
MakarFX:

这就是一个干净的模板的样子

你的MetaEditor是什么版本?

我在网上找到了一盏灯,就把它复制到那里,检查是否有错误。 有几个小的错误。改正了。因此,最初有AO和AC指标。我把我需要的东西放进去了。

 
darirunu1:

我在网上找到了一盏灯,就把它复制到那里,检查是否有错误。 有几个小的错误.纠正了它们。因此,最初有AO和AC指标。我把我需要的东西放进去了。

你为什么要这样写呢?

//====================================   
   bool Buy  =  (iCustom(NULL,0,"FiboBars2",10,5,1)&&iCustom(NULL,0,"FiboBars_3",2,19,190,5,1));
//help      
   bool Sell =  (iCustom(NULL,0,"FiboBars2",10,5,0)&&iCustom(NULL,0,"FiboBars_3",2,19,190,5,0));
 
MakarFX:

你为什么要这样写呢?

要进行交易,如果各自有两个相同的缓冲区,那就是两个红色或两个绿色的缓冲区。

 
darirunu1:

要打开交易,如果各自有两个相同的缓冲区,那就是两个红色或两个绿色。

你没有仔细阅读,或者你没有阅读...

你所写的不是在比较两个指标的值

如果"FiboBars_3 "已经做了 ,为什么还要比较 "FiboBars2 "和 "FiboBars_3"

 
MakarFX:

你没有仔细阅读,或者你没有阅读...

你写的不是两个指标值的比较

如果"FiboBars_3 "已经做了 ,为什么还要比较 "FiboBars2 "和 "FiboBars_3"

我明白一切,也读过所有关于指标的描述,但我需要这种方式。 我可以稍后在私信中分享参数以及我想得到的结果。

 
darirunu1:

我明白一切,也读过所有的指标描述,但我需要这种方式。 我可以在私信中分享参数和我想最终得到的东西。

bool Sell;
bool Buy;

if(iCustom(_Symbol,Period(),"FiboBars_3",12,24,48,2,0)==1)
  {Sell=true; Buy=false;}
if(iCustom(_Symbol,Period(),"FiboBars_3",12,24,48,2,1)==1)
  {Sell=false; Buy=true;}

这是一个关于截图中数值的例子

原因: