Einzelnen Beitrag anzeigen
  #3 (permalink)  
Alt 28.05.21
Max2018 Max2018 ist offline
Mitglied
 
Registriert seit: Sep 2018
Beiträge: 238
Max2018 befindet sich auf einem aufstrebenden Ast
Standard

Irgendwie geht das nicht:

Code:
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT
#property indicator_type1   DRAW_LINE
#property indicator_label1    "RSL"
#property indicator_level1    1.0
#property indicator_color1  DodgerBlue
//--- indicator buffer
input int InpMAPeriod               = 14;          // MA Period
input ENUM_MA_METHOD InpMAMethod    = MODE_SMA;    // MA Method
input ENUM_APPLIED_PRICE InpMAPrice = PRICE_CLOSE; // MA Applied Price
double ExtWADBuffer[];
double Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
   SetIndexBuffer(0,Buffer);
   string sShortName="RSL("+IntegerToString(InpMAPeriod)+")";

  // string sShortName="RSL("+IntegerToString(InpMAPeriod)+")";
  // IndicatorShortName(sShortName);
  // return(INIT_SUCCEEDED);
  
//--- define buffer
   SetIndexBuffer(0,ExtWADBuffer);
//--- set draw begin
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,1);
//--- indicator name
   IndicatorSetString(INDICATOR_SHORTNAME,"LEVY");
//--- round settings
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   if(rates_total<2)
      return(0);
//--- start working
   int pos=prev_calculated-1;
   int bars = rates_total-1;
   if(pos<1)
     {
      pos=1;
      ExtWADBuffer[0]=0.0;
     }
//--- main cycle

   if(!VerifyHistory()) return(prev_calculated);
   if(prev_calculated>0) bars = rates_total - prev_calculated;
   for(int i=0; i<bars; i++)
     {
      //--- get data 
      //--- calculate WA/D
      ExtWADBuffer[i]= close[i]/iMA(NULL,0,InpMAPeriod,i,InpMAMethod,InpMAPrice);
     }
      
//--- OnCalculate done. Return new prev_calculated.
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

bool VerifyHistory(string symbol = NULL) {
   if(symbol==NULL) symbol=_Symbol;
   bool x = true;
   datetime ArrayTime[];
   ArraySetAsSeries(ArrayTime,true);
   int copied = CopyTime(symbol,PERIOD_M1,0,2,ArrayTime);
   if(copied<0) x = false;
   return x;
}