SetIndexBuffer() und deren Eigenheiten

 

Hallo!

Mir ist nun schon öfters aufgefallen, dass die SetiIndexBuffer() nicht immer funktioniert. Manchmal bekomme ich z.B. probleme, wenn ich 3 Plots anzeigen möchte, aber versehentlich in den #properties 6 plots angegeben habe.
Dann fiel mir auf, dass wenn ich zuerst die SetindexBuffer(0,akf,INDICATOR_CALCULATIONS) und dann im buffer 1 den plot anlege, dass auch dann der Indikator falsche Werte im Chart anzeigt. Leider bin ich dem ganzen noch nicht ganz auf die Schliche gekommen.

SetIndexBuffer(0,akf,INDICATOR_CALCULATIONS);  
SetIndexBuffer(1,fus,INDICATOR_DATA);  


Hier ist ein aktuelles Problem. Es sind eine Reihe von Buffer deffiniert(alle funktionsfähig). der letzte buffer bei if(FuzzyMode){...} wollte ich hinzufügen, allerdings zeigt mir der Chart überhaupt kein angemessenes Bild.
Kann mir jemand bei dieser Sache weiterhelfen?

Dankeschön :)

#property indicator_buffers 33
#property indicator_plots   9
  
 
if(USD)
     {
      countVal++;
      SetIndexBuffer(0,USDplot,INDICATOR_DATA);                // array for rendering
      PlotIndexSetString(0,PLOT_LABEL,"USDplot");              // name of the indicator line (when selected with a mouse)
      PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,shiftbars);        // from which we begin rendering
      PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_LINE);         // drawing style (line)
      PlotIndexSetInteger(0,PLOT_LINE_COLOR,Color_USD);        // color of line rendering
      if(StringFind(Symbol(),"USD",0)!=-1)
        {PlotIndexSetInteger(0,PLOT_LINE_WIDTH,wid_main);}     // if the symbol name contains USD 
      // then draw a line of appropriate width 
      else
        {PlotIndexSetInteger(0,PLOT_LINE_STYLE,style_slave);}
      ArraySetAsSeries(USDplot,true);                          // indexation of array as a timeseries
      ArrayInitialize(USDplot,EMPTY_VALUE);                    // zero values 
      f_draw("USD",Color_USD);                                 // rendering in the indicator information window 
     }
   SetIndexBuffer(15,USDx,INDICATOR_CALCULATIONS);             // array of dollar index for calculations
                                                               // (is not displayed in the indicator as a line) 
   ArraySetAsSeries(USDx,true);                                // indexation of an array as a time series
   ArrayInitialize(USDx,EMPTY_VALUE);                          // zero values

   if(ind_type==Use_Stochastic_Main_on_indexes)
     {
      SetIndexBuffer(23,USDstoch,INDICATOR_CALCULATIONS);      // if the destination of the indicator as a Use_Stochastic_Main_on_indexes,
                                                               // then this intermediate array is needed
      ArraySetAsSeries(USDstoch,true);                         // indexation of array as a time series
      ArrayInitialize(USDstoch,EMPTY_VALUE);                   // zero values
     }

   if(EUR)
     {
      countVal++;
      SetIndexBuffer(1,EURplot,INDICATOR_DATA);                // array for rendering
      PlotIndexSetString(1,PLOT_LABEL,"EURplot");              // name of the indicator line (when pointed to with a mouse)
      PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,shiftbars);        // which we begin rendering from
      PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_LINE);         // drawing style (lines)
      PlotIndexSetInteger(1,PLOT_LINE_COLOR,Color_EUR);        // the color of rendering lines
      if(StringFind(Symbol(),"EUR",0)!=-1)
        {PlotIndexSetInteger(1,PLOT_LINE_WIDTH,wid_main);}     // if the symbol name contains EUR
      // then we draw a line of the appropriate width 
      else
        {PlotIndexSetInteger(1,PLOT_LINE_STYLE,style_slave);}  // if the symbol name does NOT contain EUR,
      // then we draw a line of an appropriate style (on the crosses)
      ArraySetAsSeries(EURplot,true);                          // indexation of the array as a time series
      ArrayInitialize(EURplot,EMPTY_VALUE);                    // zero values
      SetIndexBuffer(8,EURUSD,INDICATOR_CALCULATIONS);         // data of Close currency pair EURUSD
      ArraySetAsSeries(EURUSD,true);                           // indexation of the array as a time series
      ArrayInitialize(EURUSD,EMPTY_VALUE);                     // zero values
      SetIndexBuffer(16,EURx,INDICATOR_CALCULATIONS);          // array of the EURO index for calculations
                                                               // (not displayed on the indicator as a line) 
      ArraySetAsSeries(EURx,true);
      ArrayInitialize(EURx,EMPTY_VALUE);
      if(ind_type==Use_Stochastic_Main_on_indexes)
        {
         SetIndexBuffer(24,EURstoch,INDICATOR_CALCULATIONS);   // if the indicator destination as a Use_Stochastic_Main_on_indexes,
                                                               // then this intermediate array is needed
         ArraySetAsSeries(EURstoch,true);                      // indexation of the array as a time series
         ArrayInitialize(EURstoch,EMPTY_VALUE);                // zero values
        }
      f_draw("EUR",Color_EUR);                                 // rendering in the indicator information window
     }
   if(GBP)
     {
      countVal++;
      SetIndexBuffer(2,GBPplot,INDICATOR_DATA);
      PlotIndexSetString(2,PLOT_LABEL,"GBPplot");
      PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,shiftbars);
      PlotIndexSetInteger(2,PLOT_DRAW_TYPE,DRAW_LINE);
      PlotIndexSetInteger(2,PLOT_LINE_COLOR,Color_GBP);
      if(StringFind(Symbol(),"GBP",0)!=-1)
        {PlotIndexSetInteger(2,PLOT_LINE_WIDTH,3);}
      else
        {PlotIndexSetInteger(2,PLOT_LINE_STYLE,STYLE_SOLID);}
      ArraySetAsSeries(GBPplot,true);
      ArrayInitialize(GBPplot,EMPTY_VALUE);
      SetIndexBuffer(9,GBPUSD,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(GBPUSD,true);
      ArrayInitialize(GBPUSD,EMPTY_VALUE);
      SetIndexBuffer(17,GBPx,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(GBPx,true);
      ArrayInitialize(GBPx,EMPTY_VALUE);
      if(ind_type==Use_Stochastic_Main_on_indexes)
        {
         SetIndexBuffer(25,GBPstoch,INDICATOR_CALCULATIONS);
         ArraySetAsSeries(GBPstoch,true);
         ArrayInitialize(GBPstoch,EMPTY_VALUE);
        }
      f_draw("GBP",Color_GBP);
     }
   if(JPY)
     {
      countVal++;
      SetIndexBuffer(3,JPYplot,INDICATOR_DATA);
      PlotIndexSetString(3,PLOT_LABEL,"JPYplot");
      PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,shiftbars);
      PlotIndexSetInteger(3,PLOT_DRAW_TYPE,DRAW_LINE);
      PlotIndexSetInteger(3,PLOT_LINE_COLOR,Color_JPY);
      if(StringFind(Symbol(),"JPY",0)!=-1)
        {PlotIndexSetInteger(3,PLOT_LINE_WIDTH,wid_main);}
      else
        {PlotIndexSetInteger(3,PLOT_LINE_STYLE,style_slave);}
      ArraySetAsSeries(JPYplot,true);
      ArrayInitialize(JPYplot,EMPTY_VALUE);
      SetIndexBuffer(10,USDJPY,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(USDJPY,true);
      ArrayInitialize(USDJPY,EMPTY_VALUE);
      SetIndexBuffer(18,JPYx,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(JPYx,true);
      ArrayInitialize(JPYx,EMPTY_VALUE);
      if(ind_type==Use_Stochastic_Main_on_indexes)
        {
         SetIndexBuffer(26,JPYstoch,INDICATOR_CALCULATIONS);
         ArraySetAsSeries(JPYstoch,true);
         ArrayInitialize(JPYstoch,EMPTY_VALUE);
        }
      f_draw("JPY",Color_JPY);
     }
   if(CHF)
     {
      countVal++;
      SetIndexBuffer(4,CHFplot,INDICATOR_DATA);
      PlotIndexSetString(4,PLOT_LABEL,"CHFplot");
      PlotIndexSetInteger(4,PLOT_DRAW_BEGIN,shiftbars);
      PlotIndexSetInteger(4,PLOT_DRAW_TYPE,DRAW_LINE);
      PlotIndexSetInteger(4,PLOT_LINE_COLOR,Color_CHF);
      if(StringFind(Symbol(),"CHF",0)!=-1)
        {PlotIndexSetInteger(4,PLOT_LINE_WIDTH,wid_main);}
      else
        {PlotIndexSetInteger(4,PLOT_LINE_STYLE,style_slave);}
      ArraySetAsSeries(CHFplot,true);
      ArrayInitialize(CHFplot,EMPTY_VALUE);
      SetIndexBuffer(11,USDCHF,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(USDCHF,true);
      ArrayInitialize(USDCHF,EMPTY_VALUE);
      SetIndexBuffer(19,CHFx,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(CHFx,true);
      ArrayInitialize(CHFx,EMPTY_VALUE);
      if(ind_type==Use_Stochastic_Main_on_indexes)
        {
         SetIndexBuffer(27,CHFstoch,INDICATOR_CALCULATIONS);
         ArraySetAsSeries(CHFstoch,true);
         ArrayInitialize(CHFstoch,EMPTY_VALUE);
        }
      f_draw("CHF",Color_CHF);
     }
   if(CAD)
     {
      countVal++;
      SetIndexBuffer(5,CADplot,INDICATOR_DATA);
      PlotIndexSetString(5,PLOT_LABEL,"CADplot");
      PlotIndexSetInteger(5,PLOT_DRAW_BEGIN,shiftbars);
      PlotIndexSetInteger(5,PLOT_DRAW_TYPE,DRAW_LINE);
      PlotIndexSetInteger(5,PLOT_LINE_COLOR,Color_CAD);
      if(StringFind(Symbol(),"CAD",0)!=-1)
        {PlotIndexSetInteger(5,PLOT_LINE_WIDTH,wid_main);}
      else
        {PlotIndexSetInteger(5,PLOT_LINE_STYLE,style_slave);}
      ArraySetAsSeries(CADplot,true);
      ArrayInitialize(CADplot,EMPTY_VALUE);
      SetIndexBuffer(12,USDCAD,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(USDCAD,true);
      ArrayInitialize(USDCAD,EMPTY_VALUE);
      SetIndexBuffer(20,CADx,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(CADx,true);
      ArrayInitialize(CADx,EMPTY_VALUE);
      if(ind_type==Use_Stochastic_Main_on_indexes)
        {
         SetIndexBuffer(28,CADstoch,INDICATOR_CALCULATIONS);
         ArraySetAsSeries(CADstoch,true);
         ArrayInitialize(CADstoch,EMPTY_VALUE);
        }
      f_draw("CAD",Color_CAD);
     }
   if(AUD)
     {
      countVal++;
      SetIndexBuffer(6,AUDplot,INDICATOR_DATA);
      PlotIndexSetString(6,PLOT_LABEL,"AUDplot");
      PlotIndexSetInteger(6,PLOT_DRAW_BEGIN,shiftbars);
      PlotIndexSetInteger(6,PLOT_DRAW_TYPE,DRAW_LINE);
      PlotIndexSetInteger(6,PLOT_LINE_COLOR,Color_AUD);
      if(StringFind(Symbol(),"AUD",0)!=-1)
        {PlotIndexSetInteger(6,PLOT_LINE_WIDTH,wid_main);}
      else
        {PlotIndexSetInteger(6,PLOT_LINE_STYLE,style_slave);}
      ArraySetAsSeries(AUDplot,true);
      ArrayInitialize(AUDplot,EMPTY_VALUE);
      SetIndexBuffer(13,AUDUSD,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(AUDUSD,true);
      ArrayInitialize(AUDUSD,EMPTY_VALUE);
      SetIndexBuffer(21,AUDx,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(AUDx,true);
      ArrayInitialize(AUDx,EMPTY_VALUE);
      if(ind_type==Use_Stochastic_Main_on_indexes)
        {
         SetIndexBuffer(29,AUDstoch,INDICATOR_CALCULATIONS);
         ArraySetAsSeries(AUDstoch,true);
         ArrayInitialize(AUDstoch,EMPTY_VALUE);
        }
      f_draw("AUD",Color_AUD);
     }
   if(NZD)
     {
      countVal++;
      SetIndexBuffer(7,NZDplot,INDICATOR_DATA);
      PlotIndexSetString(7,PLOT_LABEL,"NZDplot");
      PlotIndexSetInteger(7,PLOT_DRAW_BEGIN,shiftbars);
      PlotIndexSetInteger(7,PLOT_DRAW_TYPE,DRAW_LINE);
      PlotIndexSetInteger(7,PLOT_LINE_COLOR,Color_NZD);
      if(StringFind(Symbol(),"NZD",0)!=-1)
        {PlotIndexSetInteger(7,PLOT_LINE_WIDTH,wid_main);}
      else
        {PlotIndexSetInteger(7,PLOT_LINE_STYLE,style_slave);}
      ArraySetAsSeries(NZDplot,true);
      ArrayInitialize(NZDplot,EMPTY_VALUE);
      SetIndexBuffer(14,NZDUSD,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(NZDUSD,true);
      ArrayInitialize(NZDUSD,EMPTY_VALUE);
      SetIndexBuffer(22,NZDx,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(NZDx,true);
      ArrayInitialize(NZDx,EMPTY_VALUE);
      if(ind_type==Use_Stochastic_Main_on_indexes)
        {
         SetIndexBuffer(30,NZDstoch,INDICATOR_CALCULATIONS);
         ArraySetAsSeries(NZDstoch,true);
         ArrayInitialize(NZDstoch,EMPTY_VALUE);
        }
      f_draw("NZD",Color_NZD);
     }
   if(FuzzyMode)
     {

      SetIndexBuffer(32,EURUSDplot,INDICATOR_DATA);
      PlotIndexSetString(32,PLOT_LABEL,"EURUSD");
      PlotIndexSetInteger(32,PLOT_DRAW_BEGIN,shiftbars);
      PlotIndexSetInteger(32,PLOT_DRAW_TYPE,DRAW_LINE);
      PlotIndexSetInteger(32,PLOT_LINE_COLOR,clrWhite);
      if(StringFind(Symbol(),"EURUSD",0)!=-1)
        {PlotIndexSetInteger(32,PLOT_LINE_WIDTH,wid_main);}
      else
        {PlotIndexSetInteger(32,PLOT_LINE_STYLE,style_slave);}
      ArraySetAsSeries(EURUSDplot,true);
      ArrayInitialize(EURUSDplot,EMPTY_VALUE);
      /*SetIndexBuffer(14,NZDUSD,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(NZDUSD,true);
      ArrayInitialize(NZDUSD,EMPTY_VALUE);
      SetIndexBuffer(22,NZDx,INDICATOR_CALCULATIONS);
      ArraySetAsSeries(NZDx,true);
      ArrayInitialize(NZDx,EMPTY_VALUE);
      if(ind_type==Use_Stochastic_Main_on_indexes)
        {
         SetIndexBuffer(30,NZDstoch,INDICATOR_CALCULATIONS);
         ArraySetAsSeries(NZDstoch,true);
         ArrayInitialize(NZDstoch,EMPTY_VALUE);
        }
      */
      f_draw("EURUSD",clrWhite);
     }
     
 
Claudius Marius Walter:

Hallo!

Mir ist nun schon öfters aufgefallen, dass die SetiIndexBuffer() nicht immer funktioniert. Manchmal bekomme ich z.B. probleme, wenn ich 3 Plots anzeigen möchte, aber versehentlich in den #properties 6 plots angegeben habe.
Dann fiel mir auf, dass wenn ich zuerst die SetindexBuffer(0,akf,INDICATOR_CALCULATIONS) und dann im buffer 1 den plot anlege, dass auch dann der Indikator falsche Werte im Chart anzeigt. Leider bin ich dem ganzen noch nicht ganz auf die Schliche gekommen.


Hier ist ein aktuelles Problem. Es sind eine Reihe von Buffer deffiniert(alle funktionsfähig). der letzte buffer bei if(FuzzyMode){...} wollte ich hinzufügen, allerdings zeigt mir der Chart überhaupt kein angemessenes Bild.
Kann mir jemand bei dieser Sache weiterhelfen?

Dankeschön :)

Ich habe aufgehört zu versuchen zu verstehen. Ich such eine Lösung, das reicht mir.
 
nach meinen aktuellen "Erkentnnissen"

müssen sämtliche Plots (.._DATA) als erstes aufgelistet werden. Danach können die _CALCULATIONS eingefügt werden. Umgekehrt funktioniert garnichts
 

Ist wohl so, wenn man sich Beispiele in der CodeBase oder der Artikel anschaut und klingt logisch. Und die Anzahl von

#property indicator_buffers muss um ein höher sein als der höchste, verwendete Pufferindex.