Einzelnen Beitrag anzeigen
  #1 (permalink)  
Alt 20.05.15
Raul0 Raul0 ist offline
Premium Mitglied
 
Registriert seit: Apr 2015
Beiträge: 422
Raul0 befindet sich auf einem aufstrebenden Ast
Standard Fehler mit dem Buffer vom Indikator beim auslesen

Hallo,

Stück für Stück müht es sich vorwärts.

Ich erhalte leider zwei Signale von einem Indikator nicht. Ich bin noch nicht so tief in der Materie, dass ich mich an den Indikator traue.

Die Abfrage, denke ich, habe ich richtig. Für 3 Buffer erhalte ich Werte, nur die zwei Fractalen(FrDn,FrUp) Signalwerte fehlen, da erhalte ich immer 0.

PHP-Code:
string DivOsMA0 iCustom(Symbol(),0,"DivOsMA",12,26,9,1,4,3,0,0);
Print(
"DivOsMA0(Osma): "DivOsMA0);
string DivOsMA1 iCustom(Symbol(),0,"DivOsMA",12,26,9,1,4,3,1,0);
Print(
"DivOsMA1(FrDn): "DivOsMA1);
string DivOsMA2 iCustom(Symbol(),0,"DivOsMA",12,26,9,1,4,3,2,0);
Print(
"DivOsMA2(FrUp): "DivOsMA2);
string DivOsMA3 iCustom(Symbol(),0,"DivOsMA",12,26,9,1,4,3,3,0);
Print(
"DivOsMA3(Macd): "DivOsMA3);
string DivOsMA4 iCustom(Symbol(),0,"DivOsMA",12,26,9,1,4,3,4,0);
Print(
"DivOsMA4(Signal): "DivOsMA4); 
Ich vermute, dass im Indikator ein Schalter noch nicht gesetzt ist. Der Indikator an sich scheint mir ganz brauchbar zur Weiterverwendung.

Über einen kurzen Hinweis würde ich mich freuen.
Gruss,Raul

Indikator: ds_HDiv_OsMA_01
Link: ds_HDiv_OsMA_01 - Desynced Forex MT4 Indicators and Expert Advisors Repository
Code
PHP-Code:
//+------------------------------------------------------------------
//                                                                  ds_HDiv_OsMA.mq4
//                                                                 dolsergon@yandex.ru
//                                                                 icq(qip)-366382375
//+------------------------------------------------------------------+
//|                                                         OsMA.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 5
#property  indicator_color1  Silver
#property  indicator_width1  2
#property  indicator_color2  Blue
#property  indicator_width2  1
#property  indicator_color3  Orange
#property  indicator_width3  1
//---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;

extern int FractRightBars=1;   // êîë-âî áàð ñïðàâà (ôðàêòàë)
extern int FractLeftBars 4;      // êîë-âî áàð ñëåâà (ôðàêòàë)
extern int MaxFanSize 3;         // ìàêñ. êîë-âî ëèíèé â "âååðå"



//---- indicator buffers
double     OsmaBuffer[];
double     MacdBuffer[];
double     SignalBuffer[];
double      FrUpBuffer[];
double      FrDnBuffer[];

string IndName;
//=======================================================================================================================================================================
int init()
  {
//---- 2 additional buffers are used for counting.
   
IndicatorBuffers(5);
//---- drawing settings
   
SetIndexStyle(0,DRAW_HISTOGRAM);
   
SetIndexDrawBegin(0,SignalSMA);
   
IndicatorDigits(Digits+2);
//---- 3 indicator buffers mapping
   
SetIndexBuffer(0,OsmaBuffer);

   
SetIndexBuffer(1,FrDnBuffer);
   
SetIndexStyle(1,DRAW_ARROW);
   
SetIndexArrow(1,119);
   
SetIndexEmptyValue(1,0.0);

   
SetIndexBuffer(2,FrUpBuffer);
   
SetIndexStyle(2,DRAW_ARROW);
   
SetIndexArrow(2,119);
   
SetIndexEmptyValue(2,0.0);

   
SetIndexBuffer(3,MacdBuffer);
   
SetIndexBuffer(4,SignalBuffer);
//---- name for DataWindow and indicator subwindow label
   
IndName="ds_HDiv_OsMA("+FastEMA+","+SlowEMA+","+SignalSMA+")";
   
IndicatorShortName(IndName);
//---- initialization done
   
return(0);
  }
//=======================================================================================================================================================================
void deinit() 
  {

   
ObjectsDeleteAll();
  }
//=======================================================================================================================================================================
//| Moving Average of Oscillator                                     |
int start()
  {
   
int counted_bars=IndicatorCounted();
   if(
counted_bars<0) return(-1);
   if(
counted_bars>0counted_bars--;
   
int limit=Bars-counted_bars;
   if(
counted_bars==0limit-=1+FractLeftBars;

//---- macd counted in the 1-st additional buffer
   
for(int i=0i<limiti++)
      
MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2-nd additional buffer
   
for(i=0i<limiti++)
      
SignalBuffer[i]=iMAOnArray(MacdBuffer,0,SignalSMA,0,MODE_SMA,i);
//---- main loop
   
for(i=0i<limiti++)
      
OsmaBuffer[i]=MacdBuffer[i]-SignalBuffer[i];
//---- done

// FRACTALS -------------------------------------------------------------------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------

   
int l_bars,r_bars;
   
int p;
   
double v,v2;

   for(
i=1+FractRightBarsi<limiti++) 
     {

      
l_bars 0;
      
r_bars 0;
      
v=OsmaBuffer[i];
      for(
p=1p<=FractLeftBarsp++) 
        {
         if(
OsmaBuffer[i+p]>v
           {
            
l_bars++;
            
v=OsmaBuffer[i+p];
           }
         else    break;
        }
      
v=OsmaBuffer[i];
      for(
p=1p<=FractRightBarsp++) 
        {
         if(
OsmaBuffer[i-p]>=v
           {
            
r_bars++;
            
v=OsmaBuffer[i-p];
           }
         else    break;
        }
      if((
l_bars==FractLeftBars) && (r_bars==FractRightBars)) 
        {
         
FrDnBuffer[i]=OsmaBuffer[i];
        }

      
l_bars 0;
      
r_bars 0;
      
v=OsmaBuffer[i];
      for(
p=1p<=FractLeftBarsp++) 
        {
         if(
OsmaBuffer[i+p]<v
           {
            
l_bars++;
            
v=OsmaBuffer[i+p];
           }
         else    break;
        }
      
v=OsmaBuffer[i];
      for(
p=1p<=FractRightBarsp++) 
        {
         if(
OsmaBuffer[i-p]<=v
           {
            
r_bars++;
            
v=OsmaBuffer[i-p];
           }
         else    break;
        }
      if((
l_bars==FractLeftBars) && (r_bars==FractRightBars)) 
        {
         
FrUpBuffer[i]=OsmaBuffer[i];
        }

     }

// DIVERGENCE -----------------------------------------------------------------------------------------------------------------------------------------------------------

   
int PointsOffset=9;

   for(
p=1+FractRightBarsp<limitp++) 
     {

      if(
FrUpBuffer[p]!=0
        {
         
int count=0;

         for(
i=FractLeftBars+pi<Barsi++) 
           {
            if(
FrUpBuffer[i]!=0
              {

               if((
FrUpBuffer[i]<FrUpBuffer[p]) && (High[i]>High[p])) 
                 {
                  
DrawIndicatorTrendLine(Time[i],Time[p],OsmaBuffer[i],OsmaBuffer[p],Red,2);
                  
DrawPriceTrendLine(Time[i],Time[p],High[i],High[p],Red,2);
                  
DrawPriceArrow(Time[p-2],Open[p-2]+PointsOffset*Point,Red,167);
                  
count++;
                  if(
count>=MaxFanSize) break;
                 }
               else    break;

              }
           }
        }

      if(
FrDnBuffer[p]!=0
        {
         
count=0;

         for(
i=FractLeftBars+pi<Barsi++) 
           {
            if(
FrDnBuffer[i]!=0
              {

               if((
FrDnBuffer[i]>FrDnBuffer[p]) && (Low[i]<Low[p])) 
                 {
                  
DrawIndicatorTrendLine(Time[i],Time[p],OsmaBuffer[i],OsmaBuffer[p],Green,2);
                  
DrawPriceTrendLine(Time[i],Time[p],Low[i],Low[p],Green,2);
                  
DrawPriceArrow(Time[p-2],Open[p-2]+PointsOffset*Point,Blue,167);
                  
count++;
                  if(
count>=MaxFanSize) break;
                 }
               else    break;

              }
           }
        }

     }


   return(
0);
  }
//=======================================================================================================================================================================
void DrawPriceTrendLine(datetime x1,datetime x2,double y1,
                        
double y2,color lineColor,double style)
  {
   
string label="DivergLine# "+DoubleToStr(x1+x2,0);
   
ObjectDelete(label);
   
ObjectCreate(label,OBJ_TREND,0,x1,y1,x2,y2,0,0);
   
ObjectSet(label,OBJPROP_RAY,0);
   
ObjectSet(label,OBJPROP_COLOR,lineColor);
   
ObjectSet(label,OBJPROP_STYLE,style);
  }
//=======================================================================================================================================================================
void DrawIndicatorTrendLine(datetime x1,datetime x2,double y1,
                            
double y2,color lineColor,double style)
  {
   
int indicatorWindow=WindowFind(IndName);
   if(
indicatorWindow<0)
      return;
   
string label="DivergLine$# "+DoubleToStr(x1+x2,0);
   
ObjectDelete(label);
   
ObjectCreate(label,OBJ_TREND,indicatorWindow,x1,y1,x2,y2,0,0);
   
ObjectSet(label,OBJPROP_RAY,0);
   
ObjectSet(label,OBJPROP_COLOR,lineColor);
   
ObjectSet(label,OBJPROP_STYLE,style);
  }
//=======================================================================================================================================================================
void DrawPriceArrow(datetime x1,double y1,color Color,double style)
  {
   
string label="DivergArrow# "+DoubleToStr(x1,0);
   
ObjectDelete(label);
   
ObjectCreate(label,OBJ_ARROW,0,x1,y1);
   
ObjectSet(label,OBJPROP_ARROWCODE,style);
   
ObjectSet(label,OBJPROP_COLOR,Color);
  }
//+------------------------------------------------------------------+