Indicator Style

 

Hallo


sagt mal, kann ich eigentlich auch den Zeichnungsstil eines Indicators von

DRAW_LINE auf

DRAW_HISTOGRAM ändern?

#property indicator_type1   DRAW_HISTOGRAM

ich hab das mal getestet indem ich eine Inputvariable definiert habe und diese dann ausgewählt hab.

Das ganze geht nicht, da er schreit es muss eine Konstante sein.

dann hab ich das ganze als

input const ENUM_DRAW_STYLE Style = DRAW_LINE;

definiert,

mit dem gleichen Ergebnis, das MQL5 jammert, er braucht eine Konstante.


denkfehler? oder geht das wirklich nicht?


danke

amando

 

Die Indikatoren mit #property zu definieren sind Relikte. Besser und flexibler ist die Dynamische Definition.

Hier ist das 'const' fehl am Platz.

So geht's:

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1

// ein eigenes enum für DrawType wäre hier sinnvoll

input ENUM_DRAW_TYPE inp_Drawtype = DRAW_HISTOGRAM;   // DrawType
input ENUM_MA_METHOD inp_Method   = MODE_EMA;         // Mode
input int            inp_Period   = 14;               // Period

int      handle;
double   buffer[];

int OnInit()
{
   SetIndexBuffer(0,buffer,INDICATOR_DATA);
   PlotIndexSetInteger(0,PLOT_DRAW_TYPE, inp_Drawtype);

   handle=iMA(_Symbol,_Period,inp_Period,0,inp_Method,PRICE_CLOSE);
   if(handle==INVALID_HANDLE)
      return(INIT_FAILED);

   return(INIT_SUCCEEDED);
  }

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 iStart=(prev_calculated==0)?0:prev_calculated-1;        // Startindex berechnen
   int iEnd  = rates_total-1;                                  // Endindex berechnen
   int iCopy = iEnd-iStart+1;                                  // amount of data to copy

   if(CopyBuffer(handle,0,0,iCopy,buffer)!=iCopy) return(0);   // falls der Indi noch nicht bereit ist raus und nochmal versuchen

   for(int i=iStart; i<rates_total; i++)                       // hier können eigene Dinge Reinprogrammiert werden
     {

     }

   return(rates_total);
}
Wie man Indikatorbuffer besonders bequem und sicher definiert siehe meinen post hier https://www.mql5.com/de/forum/77289
Indikatoren: Donchian Channels
Indikatoren: Donchian Channels
  • 2016.03.21
  • www.mql5.com
Artikel und Bibliothek: Indikatoren: Donchian Channels
 
Otto Pauser:

Die Indikatoren mit #property zu definieren sind Relikte. Besser und flexibler ist die Dynamische Definition.

Hier ist das 'const' fehl am Platz.

So geht's:

Wie man Indikatorbuffer besonders bequem und sicher definiert siehe meinen post hier https://www.mql5.com/de/forum/77289

super, danke, alles klar, eigentlich eh logisch ;-)

Grund der Beschwerde: