Einzelnen Beitrag anzeigen
  #3 (permalink)  
Alt 08.04.12
Biatsch Biatsch ist offline
Mitglied
 
Registriert seit: Oct 2011
Beiträge: 77
Biatsch befindet sich auf einem aufstrebenden Ast
Standard

Thx, ich habe den Code nun nachgebessert, aber das Resultat ist nicht das, das ich erhofft hatte.

Ich wollte, dass der Pfeil immer dann auftaucht, wenn der Kurs das untere Band innerhalb der letzten 25 Perioden im 4H_Chart unterschritten hat.

Dies trifft aber nicht zu.
Ich scheine also noch (mindestens) einen Denkfehler zu machen.

Ich habe mal ein Bild des Indikators hochgeladen.
Unter anderem dort, wo die Daumen sind hätten weitere Pfeile sein müssen.

PS: Dass der Indikator keinen Sinn macht ist mir bewusst. Es geht mir darum das Prinzip zu verstehen.



HTML-Code:
#property indicator_chart_window

#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 LightSeaGreen
#property indicator_color3 LightSeaGreen

extern int    BandsPeriod=34;
extern int    BandsShift=0;
extern double BandsDeviations=2.0;

double MovingBuffer[];
double UpperBuffer[];
double LowerBuffer[];
int x=0;
int MinPosition=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int deinit()
{
 for(int z=1;z<=x;z++)
      {
       ObjectDelete("BUY" + z);
      }
}

int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,MovingBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,UpperBuffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,LowerBuffer);
//----
   SetIndexDrawBegin(0,BandsPeriod+BandsShift);
   SetIndexDrawBegin(1,BandsPeriod+BandsShift);
   SetIndexDrawBegin(2,BandsPeriod+BandsShift);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Bollinger Bands                                                  |
//+------------------------------------------------------------------+
int start()
{
   int i,k,counted_bars=IndicatorCounted();

   i = Bars-counted_bars-1;

   while(i>=0)
      {
      MovingBuffer[i] = iMA   (NULL,240,BandsPeriod,BandsShift,MODE_SMA,MODE_CLOSE,i);
      UpperBuffer[i]  = iBands(NULL,240,BandsPeriod,BandsDeviations,0,PRICE_CLOSE,MODE_UPPER,i);
      LowerBuffer[i]  = iBands(NULL,240,BandsPeriod,BandsDeviations,0,PRICE_CLOSE,MODE_LOWER,i);

      double Min = Low[iLowest(NULL,240,MODE_LOW,25,i)];
      int MinPosition = ArrayMinimum(LowerBuffer,25,i);
      double MinLowerBand = iBands(NULL,240,BandsPeriod,BandsDeviations,0,PRICE_CLOSE,MODE_LOWER,MinPosition);  

         if(Min<MinLowerBand){
            x++;
            ObjectCreate("BUY" + x,OBJ_ARROW,0,Time[i],Low[i]);
            ObjectSet("BUY" + x,OBJPROP_COLOR,Red); 
            ObjectSet("BUY" + x,OBJPROP_STYLE,SYMBOL_ARROWUP); 
            ObjectSet("BUY" + x,OBJPROP_WIDTH,3); 
            ObjectSet("BUY" + x,OBJPROP_BACK,true);
         }

      i--;
     }
//----
   return(0);
}