ttyishu 发表于 2019-2-25 21:51:44

求一款RSI里面加布林源码

各位大神,我想求一款RSI里面加布林的代码,有没有人会弄的

hyryanli 发表于 2019-2-25 22:05:45

https://www.tradingview.com/script/zopumZ8a-Bollinger-RSI-Double-Strategy-by-ChartArt/

ttyishu 发表于 2019-2-25 22:09:16

hyryanli 发表于 2019-2-25 22:05
https://www.tradingview.com/script/zopumZ8a-Bollinger-RSI-Double-Strategy-by-ChartArt/

好像不是这个,那个布林要加载在rsi里面的

ttyishu 发表于 2019-2-25 23:05:35

//+------------------------------------------------------------------+
//|                                                          RSI.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link      "http://www.mql4.com"
#property description "Relative Strength Index"
#property strict

#property indicator_separate_window
#property indicator_minimum    0
#property indicator_maximum    100
#property indicator_buffers    1
#property indicator_color1   DodgerBlue
#property indicator_level1   20.0
#property indicator_level2   80.0
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT
//--- input parameters
input int InpRSIPeriod=14; // RSI Period
//--- buffers
double ExtRSIBuffer[];
double ExtPosBuffer[];
double ExtNegBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   string short_name;
//--- 2 additional buffers are used for counting.
   IndicatorBuffers(3);
   SetIndexBuffer(1,ExtPosBuffer);
   SetIndexBuffer(2,ExtNegBuffer);
//--- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtRSIBuffer);
//--- name for DataWindow and indicator subwindow label
   short_name="RSI("+string(InpRSIPeriod)+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//--- check for input
   if(InpRSIPeriod<2)
   {
      Print("Incorrect value for input variable InpRSIPeriod = ",InpRSIPeriod);
      return(INIT_FAILED);
   }
//---
   SetIndexDrawBegin(0,InpRSIPeriod);
//--- initialization done
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
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,pos;
   double diff;
//---
   if(Bars<=InpRSIPeriod || InpRSIPeriod<2)
      return(0);
//--- counting from 0 to rates_total
   ArraySetAsSeries(ExtRSIBuffer,false);
   ArraySetAsSeries(ExtPosBuffer,false);
   ArraySetAsSeries(ExtNegBuffer,false);
   ArraySetAsSeries(close,false);
//--- preliminary calculations
   pos=prev_calculated-1;
   if(pos<=InpRSIPeriod)
   {
      //--- first RSIPeriod values of the indicator are not calculated
      ExtRSIBuffer=0.0;
      ExtPosBuffer=0.0;
      ExtNegBuffer=0.0;
      double sump=0.0;
      double sumn=0.0;
      for(i=1; i<=InpRSIPeriod; i++)
      {
         ExtRSIBuffer=0.0;
         ExtPosBuffer=0.0;
         ExtNegBuffer=0.0;
         diff=close-close;
         if(diff>0)
            sump+=diff;
         else
            sumn-=diff;
      }
      //--- calculate first visible value
      ExtPosBuffer=sump/InpRSIPeriod;
      ExtNegBuffer=sumn/InpRSIPeriod;
      if(ExtNegBuffer!=0.0)
         ExtRSIBuffer=100.0-(100.0/(1.0+ExtPosBuffer/ExtNegBuffer));
      else
      {
         if(ExtPosBuffer!=0.0)
            ExtRSIBuffer=100.0;
         else
            ExtRSIBuffer=50.0;
      }
      //--- prepare the position value for main calculation
      pos=InpRSIPeriod+1;
   }
//--- the main loop of calculations
   for(i=pos; i<rates_total && !IsStopped(); i++)
   {
      diff=close-close;
      ExtPosBuffer=(ExtPosBuffer*(InpRSIPeriod-1)+(diff>0.0?diff:0.0))/InpRSIPeriod;
      ExtNegBuffer=(ExtNegBuffer*(InpRSIPeriod-1)+(diff<0.0?-diff:0.0))/InpRSIPeriod;
      if(ExtNegBuffer!=0.0)
         ExtRSIBuffer=100.0-100.0/(1+ExtPosBuffer/ExtNegBuffer);
      else
      {
         if(ExtPosBuffer!=0.0)
            ExtRSIBuffer=100.0;
         else
            ExtRSIBuffer=50.0;
      }
   }
//---
   return(rates_total);
}
//+------------------------------------------------------------------+


这个是RSI代码,怎么在里面加一个布林代码呢?布林代码要融合RSI指标里面,手机可以添加,电脑怎么添加呢?

外汇比赛网 发表于 2020-4-13 11:20:27

:lol不错

xsttdda 发表于 2020-6-19 11:44:07

沙发!沙发!

散落一地忧伤 发表于 2020-7-27 20:50:29

谢谢楼主分享

654209864 发表于 2020-8-2 16:34:09

谢谢楼主分享

布来海 发表于 2020-8-17 12:50:59

谢谢楼主分享

蒋委员长 发表于 2020-8-29 22:33:46

谢谢楼主分享
页: [1] 2
查看完整版本: 求一款RSI里面加布林源码