我将免费撰写一份顾问报告 - 页 168

 
Aesen #:
嘿,安东,你能帮助我使我的 "平衡量背离 "EA更加持续盈利吗?也许可以改变代码中的一些东西,或者增加一些功能,让它变得更好,谢谢。
#include <trade/trade.mqh>

input double Lots = 0.01;
input int VerificationCandles = 20;
input int TimeGapCandles = 5;

input int TpPoints = 1000;
input int SlPoints = 1000;

int totalBars;
int handleOBV;

datetime timeLow1, timeLow2, timeHigh1, timeHigh2;
double low1, low2, high1, high2;
datetime timeLowOBV1, timeLowOBV2, timeHighOBV1, timeHighOBV2;
double lowObv1, lowObv2, highObv1, highObv2;

int OnInit(){
   totalBars = iBars(_Symbol,PERIOD_CURRENT);
   
   handleOBV = iOBV(_Symbol,PERIOD_CURRENT,VOLUME_TICK);

   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason){

}

void OnTick(){
   int bars = iBars(_Symbol,PERIOD_CURRENT);
   if(totalBars != bars){
      totalBars = bars;
      
      datetime newTime = 0;
      double newlow = 0, newhigh = 0;
      findHighLow(newlow,newhigh,newTime);
      
      datetime newTimeObv = 0;
      double newlowOBV = 0, newhighOBV = 0;      
      findHighLowOBV(newlowOBV,newhighOBV,newTimeObv); 
      
      if(newlow != 0 || newlowOBV != 0){
         if(newlow != 0){
            low2 = low1;
            timeLow2 = timeLow1;
            low1 = newlow;
            timeLow1 = newTime;            
         }   
         if(newlowOBV != 0){
            lowObv2 = lowObv1;
            timeLowOBV2 = timeLowOBV1;
            lowObv1 = newlowOBV;
            timeLowOBV1=newTime;
         }
         
         ulong timeGap = TimeGapCandles * PeriodSeconds(PERIOD_CURRENT);
         if(low1 < low2 && lowObv1 > lowObv2 && (ulong)MathAbs(timeLow1-timeLowOBV1) < timeGap && (ulong)MathAbs(timeLow2-timeLowOBV2) < timeGap){
            Print(__FUNCTION__," > New Buy Signal...");
            
            double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
            ask = NormalizeDouble(ask,_Digits);
            
            double tp = ask + TpPoints * _Point;
            tp = NormalizeDouble(tp,_Digits);
            
            double sl = ask - SlPoints * _Point;
            sl = NormalizeDouble(sl,_Digits);
            
            CTrade trade;
            trade.Buy(Lots,_Symbol,ask,sl,tp);                 
         }
      } 
         
         if(newhigh != 0 || newhighOBV != 0){
            if(newhigh != 0){
               high2 = high1;
               timeHigh2 = timeHigh1;
               high1 = newhigh;
               timeHigh1 = newTime;
            }
            if(newhighOBV != 0){
               highObv2 = highObv1;
               timeHighOBV2 = timeHighOBV1;
               highObv1 = newhighOBV;
               timeHighOBV1 = newTimeObv;
            }
            
           ulong timeGap = TimeGapCandles * PeriodSeconds(PERIOD_CURRENT);
           if(high1 > high2 && highObv1 < highObv2 && (ulong)MathAbs(timeHigh1-timeHighOBV1) < timeGap && (ulong)MathAbs(timeHigh2-timeHighOBV2) < timeGap){
            Print(__FUNCTION__," > New Sell Signal...");
            
            double bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);
            bid = NormalizeDouble(bid,_Digits);
            
            double tp = bid - TpPoints * _Point;
            tp = NormalizeDouble(tp,_Digits);
            
            double sl = bid + SlPoints * _Point;
            sl = NormalizeDouble(sl,_Digits);
            
            CTrade trade;
            trade.Sell(Lots,_Symbol,bid,sl,tp);                  
         }   
      }
   }             
} 
     
void findHighLow(double &newlow, double &newhigh, datetime &newTime){
   int indexBar = VerificationCandles+1;
   double high = iHigh(_Symbol,PERIOD_CURRENT,indexBar);
   double low = iLow(_Symbol,PERIOD_CURRENT,indexBar);
   datetime time = iTime(_Symbol,PERIOD_CURRENT,indexBar);
      
   bool isHigh = true, isLow = true;
   for(int i = 1; i <= VerificationCandles; i++){
       double highLeft = iHigh(_Symbol,PERIOD_CURRENT,indexBar+i);
       double highRight = iHigh(_Symbol,PERIOD_CURRENT,indexBar-i);
       if(highLeft > high || highRight > high) isHigh = false;
         
       double lowLeft = iLow(_Symbol,PERIOD_CURRENT,indexBar+i);
       double lowRight = iLow(_Symbol,PERIOD_CURRENT,indexBar-i);
       if(lowLeft < low || highRight < low) isLow = false;
          
       if(!isHigh && !isLow) break;
       if(i == VerificationCandles){
         if(isHigh){
            Print(__FUNCTION__," > Found a new high (",DoubleToString(high,_Digits),") at ",time,"...");
            ObjectCreate(0,"High@"+TimeToString(time),OBJ_ARROW_SELL,0,time,high);
            newhigh = high;
            newTime = time;  
         }            
         if(isLow){
            Print(__FUNCTION__," > Found a new low (",DoubleToString(low,_Digits),") at ",time,"...");
            ObjectCreate(0,"Low@"+TimeToString(time),OBJ_ARROW_BUY,0,time,low); 
            newlow = low;
            newTime = time;               
         }
      }   
   }
}
   
void findHighLowOBV(double &newlow, double &newhigh, datetime &newTime){
   int indexBar = VerificationCandles;
   double OBV[];
   if(CopyBuffer(handleOBV,0,1,VerificationCandles*2+1,OBV) < VerificationCandles *2+1) return;
   
   double value = OBV[indexBar];
   datetime time = iTime(_Symbol,PERIOD_CURRENT,indexBar+1);
      
   bool isHigh = true, isLow = true;
   for(int i = 1; i <= VerificationCandles; i++){
       double valLeft = OBV[indexBar+i];
       double valRight = OBV[indexBar-i];
       if(valLeft > value || valRight > value) isHigh = false;      
       if(valLeft < value || valRight < value) isLow = false;
          
       if(!isHigh && !isLow) break;
       if(i == VerificationCandles){
         if(isHigh){
            Print(__FUNCTION__," > Found a new high (",DoubleToString(value,_Digits),") at ",time,"...");
            ObjectCreate(0,"High@"+TimeToString(time),OBJ_ARROW_SELL,1,time,value);
            newhigh = value;
            newTime = time;    
         }
         if(isLow){
            Print(__FUNCTION__," > Found a new low (",DoubleToString(value,_Digits),") at ",time,"...");
            ObjectCreate(0,"Low@"+TimeToString(time),OBJ_ARROW_BUY,1,time,value);
            newlow = value;
            newTime = time;    
         }
      }   
   }
} 
附加的文件:
 
Aesen #:

我想在EA上拥有的一些功能是,当价格图表和obv指标上形成隐性和规律性背离时的趋势线,也许是一个漂亮的追踪止损,还有类似这样的输入。


变量

常规背离 真/假

隐藏背离 真/假

指标趋势线 真/假

价格趋势线 真/假


我试图让这个OBV背离式EA遵循我从babypips.com得到的背离式小抄。


看涨背离(向上反转)。

蜡烛图价格 - 较低的低点

平衡成交量 - 较高的低点


看跌背离(反转下跌)。

蜡烛图价格-高点

平衡成交量 - 较低的高点


看涨的隐性背离(趋势持续上升)。

蜡烛图价格-较高的低点

平衡成交量 - 较低的低点


看跌的隐性背离(趋势 持续下跌)。

蜡烛图价格-较低的高点

平衡成交量--高点

A New Approach to Interpreting Classic and Hidden Divergence. Part II
A New Approach to Interpreting Classic and Hidden Divergence. Part II
  • www.mql5.com
The article provides a critical examination of regular divergence and efficiency of various indicators. In addition, it contains filtering options for an increased analysis accuracy and features description of non-standard solutions. As a result, we will create a new tool for solving the technical task.
 
Aesen #:

我想在EA上拥有的一些功能是,当价格图表和obv指标上形成隐性和规律性背离时的趋势线,也许是一个漂亮的追踪止损,还有类似这样的输入。


变量

常规背离 真/假

隐藏背离 真/假

指标趋势线 真/假

价格趋势线 真/假


我试图让这个OBV背离式EA遵循我从babypips.com得到的背离式小抄。


看涨背离(向上反转)。

蜡烛图价格 - 较低的低点

平衡成交量 - 较高的低点


看跌背离(反转下跌)。

蜡烛图价格-高点

平衡成交量 - 较低的高点


看涨的隐性背离(趋势持续上升)。

蜡烛图价格-较高的低点

平衡成交量 - 较低的低点


看跌的隐性背离(趋势 持续下跌)。

蜡烛图价格-较低的高点

平衡成交量--高点

我想到的另一个功能是,如果EA对其放置的第一笔交易有利,它将堆积更多的交易,如果这有意义的话....。


例如,当EA发现了一个看涨的背离,并且有一个买入信号,并且放置了第一个买入交易,如果交易有利于EA放置的第一个买入交易,那么EA将在买入方向上堆积更多的交易,如果是卖出交易,则反之。
 
Aesen #:

我想到的另一个功能是,如果EA对其放置的第一笔交易有利,它将堆积更多的交易,如果这有意义的话....。


例如,当EA发现一个看涨的背离,并且有一个买入信号,并且放置了第一个买入交易,如果交易有利于EA放置的第一个买入交易,那么EA将在买入方向上堆积更多的交易,反之亦然,如果是卖出交易。
你能不能包括一个区域恢复 对冲策略,即启动第一笔交易,比如说手数为0.01的买入,当它向负面方向移动一些点,比如说低于30点时,激活一个手数更高的反卖出,比如说0.02,如果它继续下降,交易在收支平衡或盈利时关闭,循环再次开始。然而,如果卖出的效果不好,价格上涨,则激活另一个更高手数的买入交易,如0.03,在第一次买入的相同价格。如果继续上涨,净结果是盈利,则循环以盈利关闭交易并重新开始。因此,30点的差距是固定的,被称为恢复区,通过消除损失使其对高额账户有利。如果可以这样编程
 
代码脚本是针对Mt5的,而不是针对mt4的。
 

你好。请为MT4编写一个EA。

当MA(所有可用的muwings设置)触及当前价格 时,关闭所有之前手动开启的交易。没有其他东西(是半自动的EA吗?)

 
torrr 当前价格 时,关闭所有未结交易。没有别的了。

你好。

我刚做完,没来得及测试。我希望它对你有用。

注意到。

//+------------------------------------------------------------------+
//|                                                     Practica.mq4 |
//|                        Copyright 2022, Antonio Simón Del Vecchio |
//|                    https://www.mql5.com/es/users/simondelvecchio |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Antonio Simón Del Vecchio"
#property link      "https://www.mql5.com/es/users/simondelvecchio"
#property version   "1.00"
#property strict


input int Periodo = 50;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(OrdersTotal() > 0 && CruceMediaPrecio())
     {
      Cerrar();
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Cerrar()
  {
   double Precio = 0;
   for(int i = OrdersTotal() - 1; i >= 0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS))
        {
         if(OrderType() == OP_BUY)
            Precio = Bid;
         else
            Precio = Ask;
         if(!OrderClose(OrderTicket(), OrderLots(), Precio, 3, clrNONE))
            Print("Error al cerrar la órden: ", GetLastError());
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CruceMediaPrecio()
  {
   double Media = iMA(Symbol(), PERIOD_CURRENT, Periodo, 0, MODE_SMA, PRICE_CLOSE, 0);
   double Max = iHigh(Symbol(), PERIOD_CURRENT, 0);
   double Min = iLow(Symbol(), PERIOD_CURRENT, 0);
   if(Max > Media && Min < Media)
     {
      return(true);
     }
   return(false);
  }
//+------------------------------------------------------------------+
 

致:Antonio Simon Del Vecchio

谢谢你!我是个傻子...我必须在MetaEditor中创建一个EA,插入这段代码,编译后就可以了?

 
torrr 一个EA,插入这段代码,编译后就可以了?
正确。当你编译它时,EA将以你在MetaEditor中给这个文件的名字生成。

现在我想问一下那些能读懂我的人:由于我分享了代码,是否禁止分享EA? 我是指.exe文件?
 
"我刚刚煮好,没有时间测试"。那你怎么能在测试器中运行一个只平仓 的EA呢?