找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
首页论坛EAHub 外汇论坛
查看: 9|回复: 0

求这个FXBS2指标的mt4版本,求大佬帮我改改,已经做出雏形了。但不知道如何取差值。

[复制链接]

4万

主题

54

回帖

4万

积分

管理员

积分
45954
发表于 2026-8-26 05:42:00 | 显示全部楼层 |阅读模式
最后由 猎鲸狐 于 2021-10-20 22:45 编辑

求这个FXBS2指标的mt4版本,求大佬帮我改改,已经做出雏形了。但不知道如何做出原功能中的砖块效果,现在放出源码,希望有大佬能继续写下去。

原指标效果:




目前效果:





//+------------------------------------------------------------------+
//|                                                        FXBS2.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
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_plots   3
//--- plot FXBS_d
#property indicator_label1  "FXBS_d"
#property indicator_type1   DRAW_HISTOGRAM
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- plot FXBS_x
#property indicator_label2  "FXBS_x"
#property indicator_type2   DRAW_HISTOGRAM
#property indicator_color2  clrGreen
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2
//--- plot 生命线
#property indicator_label3  "生命线"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrYellow
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
input int InpPeriod_1=9; //
input int InpPeriod_2=60; //
input int InpPeriod_3=34; //
//--- indicator buffers
double         FXBS_dBuffer[];
double         FXBS_xBuffer[];
double         生命线Buffer[];
double   VAR1Buffer[];
double   VAR2Buffer[];
double   VAR3Buffer[];
double   VAR4Buffer[];
double   VAR5Buffer[];
double   VAR6Buffer[];
double   VAR7Buffer[];
double   VAR8Buffer[];
double   VAR9Buffer[];
double   VAR10Buffer[];
double   VAR11Buffer[];
double   VAR12Buffer[];
double   VAR13Buffer[];
double   VAR14Buffer[];
double   VAR15Buffer[];
double   VAR16Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   string short_name;
   IndicatorBuffers(18);
//--- indicator buffers mapping
// SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,Red);
// SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,Green);
   SetIndexBuffer(0,VAR12Buffer);
   SetIndexBuffer(1,VAR13Buffer);
// SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,Yellow);//  SetIndexStyle(1,DRAW_NONE);
   SetIndexBuffer(2,生命线Buffer);
   SetIndexStyle(3,DRAW_NONE);   //  SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1,White);
   SetIndexBuffer(3,VAR1Buffer);
   SetIndexStyle(4,DRAW_NONE);     // SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1,White);
   SetIndexBuffer(4,VAR2Buffer);
   SetIndexStyle(5,DRAW_NONE);          //   SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,1,White);
   SetIndexBuffer(5,VAR3Buffer);
   SetIndexStyle(6,DRAW_NONE);      //  SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,1,White);
   SetIndexBuffer(6,VAR4Buffer);
   SetIndexStyle(7,DRAW_NONE);     // SetIndexStyle(6,DRAW_LINE,STYLE_SOLID,1,Red);
   SetIndexBuffer(7,VAR5Buffer);
   SetIndexStyle(8,DRAW_NONE); //  SetIndexStyle(7,DRAW_LINE,STYLE_SOLID,1,White);
   SetIndexBuffer(8,VAR6Buffer);
   SetIndexStyle(9,DRAW_NONE);    // SetIndexStyle(8,DRAW_LINE,STYLE_SOLID,1,Red);
   SetIndexBuffer(9,VAR7Buffer);
   SetIndexStyle(10,DRAW_NONE);  //SetIndexStyle(9,DRAW_LINE,STYLE_SOLID,1,White);
   SetIndexBuffer(10,VAR8Buffer);
   SetIndexStyle(11,DRAW_NONE);  //SetIndexStyle(10,DRAW_LINE,STYLE_SOLID,1,White);
   SetIndexBuffer(11,VAR9Buffer);
   SetIndexStyle(12,DRAW_NONE);// SetIndexStyle(11,DRAW_LINE,STYLE_SOLID,1,White);
   SetIndexBuffer(12,VAR10Buffer);
   SetIndexStyle(13,DRAW_NONE);            // SetIndexStyle(12,DRAW_LINE,STYLE_SOLID,1,White);
   SetIndexBuffer(13,VAR11Buffer);
   SetIndexStyle(14,DRAW_NONE); // SetIndexStyle(15,DRAW_LINE,STYLE_SOLID,1,Red);
   SetIndexBuffer(14,VAR14Buffer);
   SetIndexStyle(15,DRAW_NONE); //SetIndexStyle(16,DRAW_LINE,STYLE_SOLID,1,Red);
   SetIndexBuffer(15,VAR15Buffer);
   SetIndexStyle(16,DRAW_NONE); // SetIndexStyle(17,DRAW_LINE,STYLE_SOLID,1,White);
   SetIndexBuffer(16,VAR16Buffer);
   short_name="FXBS2("+IntegerToString(InpPeriod_1)+","+IntegerToString(InpPeriod_2)+","+IntegerToString(InpPeriod_3)+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int i,limit;
//---
   if(rates_total<InpPeriod_2)
      return(0);
//--- last counted bar will be recounted
   limit=rates_total-prev_calculated;
   if(prev_calculated>0)
      limit++;
//--- macd counted in the 1-st buffer
   for(i=0; i<limit; i++)
     {
      VAR1Buffer=  High[iHighest(NULL,0,MODE_HIGH,InpPeriod_1,i)]  -Low[iLowest(NULL,0,MODE_LOW,InpPeriod_1,i)];
      VAR2Buffer=  High[iHighest(NULL,0,MODE_HIGH,InpPeriod_1,i)]-close;
      VAR3Buffer=  close-Low[iLowest(NULL,0,MODE_LOW,InpPeriod_1,i)];
      if(VAR1Buffer !=0)
         VAR4Buffer =VAR2Buffer/VAR1Buffer*100-70;
      if((High[iHighest(NULL,0,MODE_HIGH,InpPeriod_2,i)]-Low[iLowest(NULL,0,MODE_LOW,InpPeriod_2,i)])>0)
         VAR5Buffer=(close-Low[iLowest(NULL,0,MODE_LOW,InpPeriod_2,i)])/(High[iHighest(NULL,0,MODE_HIGH,InpPeriod_2,i)]-Low[iLowest(NULL,0,MODE_LOW,InpPeriod_2,i)])*100;
      VAR6Buffer=(2*close+high+low)/4;
      if(VAR1Buffer !=0)
         VAR14Buffer=VAR3Buffer/VAR1Buffer*100;
     }
   for(i=0; i<limit; i++)
     {
      // VAR7Buffer=SimpleMA(i,3,VAR14Buffer);
      VAR7Buffer=iMAOnArray(VAR14Buffer,0,3,0,MODE_SMA,i);
      VAR8Buffer=Low[iLowest(NULL,0,MODE_LOW,InpPeriod_3,i)];
     }
   for(i=0; i<limit; i++)
     {
      //VAR9Buffer=SimpleMA(i,3,VAR7Buffer)-SimpleMA(i,9,VAR4Buffer);
      VAR9Buffer=iMAOnArray(VAR7Buffer,0,3,0,MODE_SMA,i)-iMAOnArray(VAR4Buffer,0,9,0,MODE_SMA,i);
     }
   for(i=0; i<limit; i++)
     {
      VAR10Buffer=0;
      if(VAR9Buffer>100)
         VAR10Buffer=VAR9Buffer-100;
      else
         VAR10Buffer=0;
      VAR11Buffer=High[iHighest(NULL,0,MODE_HIGH,InpPeriod_3,i)];
      if((VAR11Buffer-VAR8Buffer)!=0)
         VAR15Buffer=(VAR6Buffer-VAR8Buffer)/(VAR11Buffer-VAR8Buffer)*100;
     }
   for(i=0; i<limit; i++)
     {
      //VAR12Buffer=ExponentialMA(i,13,0,VAR15Buffer);
      VAR12Buffer=iMAOnArray(VAR15Buffer,0,13,0,MODE_EMA,i);
     }
   for(i=0; i<limit; i++)
     {
      if(prev_calculated==0 && i==limit-1)
         VAR16Buffer=0.667*VAR12Buffer+0.333*VAR12Buffer;
      else
         VAR16Buffer=0.667*VAR12Buffer[i+1]+0.333*VAR12Buffer;
     }
   for(i=0; i<limit; i++)
     {
      //VAR13Buffer=ExponentialMA(i,2,0,VAR16Buffer);
      VAR13Buffer=iMAOnArray(VAR16Buffer,0,2,0,MODE_EMA,i);
     }
   for(i=0; i<limit; i++)
     {
      // 生命线Buffer=ExponentialMA(i,5,0,VAR13Buffer);
      生命线Buffer=iMAOnArray(VAR13Buffer,0,5,0,MODE_EMA,i);
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|EAHub外汇论坛

GMT+8, 2026-10-11 07:44 , Processed in 0.100781 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表