Programming an indicator without using indicator-buffer

 

Hi,

I want to program an pivot - indicator, which isn't using any indicator buffer.

I have already reprogrammed an existing ea:

double Res3[], Res2[], Res1[], Piv[], Sup1[], Sup2[], Sup3[];

int init()

{

   SetIndexBuffer( 0, Res3);
   SetIndexBuffer( 1, Res2);
   SetIndexBuffer( 2, Res1);
   SetIndexBuffer( 3, Piv);
   SetIndexBuffer( 4, Sup1);
   SetIndexBuffer( 5, Sup2);
   SetIndexBuffer( 6, Sup3);

}

int start

{

         // Determine High & Low for the previous Pivot Day
         Count = iBarShift( NULL, 0, PivotDayStartTime ) - i;           // number of bars in the day
         PDayHigh = High[ iHighest( NULL, 0, MODE_HIGH, Count, i+1 ) ]; // Pivot Day high
         PDayLow = Low[ iLowest( NULL, 0, MODE_LOW, Count, i+1 ) ];     // Pivot Day low

         // Pivot calculations
         Piv[i] = ( PDayHigh + PDayLow + Close[i+1] ) / 3;    // Pivot point
         Range = PDayHigh - PDayLow;
         Res1[i] = 2 * Piv[i] - PDayLow;                     // R1
         Res2[i] = Piv[i] + Range;                           // R2
         Res3[i] = Res1[i] + Range;                            // R3
         Sup1[i] = 2 * Piv[i] - PDayHigh;                    // S1
         Sup2[i] = Piv[i] - Range;                           // S2

         Sup3[i] = Sup1[i] - Range;                            // S3

}


Now I am using the calculated values and draw them with objects!!

But I can only work with the results, when I calculate with given buffers.


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


I also saw another example. Which calculates the with the following lines

ArrayInitialize(Day_Price,0);
ArrayCopyRates(Day_Price,(Symbol()), 1440);

YesterdayHigh  = Day_Price[1][3];
YesterdayLow   = Day_Price[1][2];
YesterdayClose = Day_Price[1][4];

But I don't understand? Does it only work once?

 
 

Sorry, what does it mean?

 
sunshineh:

I also saw another example. Which calculates the with the following lines

But I don't understand? Does it only work once?


That looks like reasonable code although I have never used that function. I would say you can call that set of 4 lower instructions as often as you like. The tricky part is the array initialize. that looks wrong. Although the function is called ArrayCopyRates() the help file clearly says that it does no such thing. It is returning a pointer to the relevant array which means that no copying is necessary. This means that dayPrice needs to be a pointer to an array and not an actual array. If you assign an actual array this will allocate memory to it. Changing the pointer value - well I don't know what that's going to do. If it is simply a pointer then you absolutely mustn't initialize it because the pointer will not be pointing anywhere.

Write it out and post the full code then somebody may be able to fix up the last little but for you.

Reason: