I am trying to do a script that will compare the value of the low of the current pivot low with the previous value of the low of the previous pivot low.
For it I try to use the MRO() but I am unable to retrieve the value of the previous low
The idea is to say that if the current low of the pivot low is higher than it's a Lower High if the low of the value is lower than it's a Lower Low
Expected output : Look at Screenshot 1
In final i need to understand the occurrence and the barsback as i will be doing a count that reset or increment depending on if it's a lower low ( resets on lower low) or lower high ( increment on lower high ) But I first need to understand the lower low and lower high concept ( Screenshot 2 )
Here is my code Attempt and as you will see i am able to output the current Pivot Low Low but the previous one doesn't output correctly . I am unsure what is the problem
//Check to make sure that the Chart as at least one Bar before we compute anything
if(CurrentBars[0] < 1 )
return;
//Define some variable
double iOffset = 0.25;
// Definition of pivot
// I go up to 9 equal lows in case
bool pivotlow1 = (Low[0] > Low[1]) && (Low[1] < Low[2]);
bool pivotlow2 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] < Low[3]) ;
bool pivotlow3 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] < Low[4]);
bool pivotlow4 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] < Low[5]);
bool pivotlow5 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] == Low[5]) && (Low[5] < Low[6]) ;
bool pivotlow6 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] == Low[5]) && (Low[5] == Low[6]) && (Low[5] < Low[6]) ;
bool pivotlow7 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] == Low[5]) && (Low[5] == Low[6]) && (Low[5] == Low[6]) && (Low[6] < Low[7]);
bool pivotlow8 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] == Low[5]) && (Low[5] == Low[6]) && (Low[5] == Low[6]) && (Low[6] == Low[7]) && (Low[7] < Low[8]);
bool pivotlow9 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] == Low[5]) && (Low[5] == Low[6]) && (Low[5] == Low[6]) && (Low[6] == Low[7]) && (Low[7] == Low[8]) && (Low[9] < Low[10]);
// Definition of a pivot low
bool pl = (pivotlow1) || (pivotlow2) || (pivotlow3) || (pivotlow4) || (pivotlow5) || (pivotlow6) || (pivotlow7) || (pivotlow8) || (pivotlow9) ;
// Get the bar index at which the pivot is happening
int CurrentPivotLow = MRO(() => pl , 1 , CurrentBar) ;
int PrevioustPivotLow = MRO(() => pl , 2 , CurrentBar) ;
// Plot The Pivot
if (pl) {
Draw.Text(this, "Even"+CurrentBar, "PivotLow" , 1 , Low[1] - iOffset);
Print(string.Format("The Time: {0} | CurrentBar: {1} | LowCurrentPivotLow : {2} | LowPreviousPivotLow : {3} " ,Time[0],CurrentBar,Low[CurrentPivotLow + 1 ], Low[PrevioustPivotLow + 1 ] ) );
// Draw.Text(this, "Even"+CurrentBar, CurrentPivotLowBarValue.ToString() , 1 , Low[1] - 1 );
}
Edit1 : Trying to do another methodology than the MRO
I also try to do it via another methodology where i try to track of the low value and compare it to the previous but the previous value keep resetting to zero. So I am unsure how to reassign a new value to the double within the if statement. I guess i might be missing something on the documentation. I did see the Series<T> object on the documentation but I am unable to understand how to make it work. IF someone could apply the T series object to my example maybe i can figure out then how to access values
if(CurrentBars[0] < 1 )
return;
//Define some variable
double iOffset = 0.25;
// Definition of pivot
// I go up to 9 equal lows in case
bool pivotlow1 = (Low[0] > Low[1]) && (Low[1] < Low[2]);
bool pivotlow2 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] < Low[3]) ;
bool pivotlow3 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] < Low[4]);
bool pivotlow4 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] < Low[5]);
bool pivotlow5 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] == Low[5]) && (Low[5] < Low[6]) ;
bool pivotlow6 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] == Low[5]) && (Low[5] == Low[6]) && (Low[5] < Low[6]) ;
bool pivotlow7 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] == Low[5]) && (Low[5] == Low[6]) && (Low[5] == Low[6]) && (Low[6] < Low[7]);
bool pivotlow8 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] == Low[5]) && (Low[5] == Low[6]) && (Low[5] == Low[6]) && (Low[6] == Low[7]) && (Low[7] < Low[8]);
bool pivotlow9 = (Low[0] > Low[1]) && (Low[1] == Low[2]) && (Low[2] == Low[3]) && (Low[3] == Low[4]) && (Low[4] == Low[5]) && (Low[5] == Low[6]) && (Low[5] == Low[6]) && (Low[6] == Low[7]) && (Low[7] == Low[8]) && (Low[9] < Low[10]);
//// Definition of a pivot low
bool pl = (pivotlow1) || (pivotlow2) || (pivotlow3) || (pivotlow4) || (pivotlow5) || (pivotlow6) || (pivotlow7) || (pivotlow8) || (pivotlow9) ;
//// Get the bar index at which the pivot is happening
// int CurrentPivotLow = MRO(() => pl , 1 , CurrentBar) ;
// int PrevioustPivotLow = MRO(() => pl , 2 , CurrentBar) ;
//// Plot The Pivot
// if (pl) {
// Draw.Text(this, "Even"+CurrentBar, "PivotLow" , 1 , Low[1] - iOffset);
// Print(string.Format("The Time: {0} | CurrentBar: {1} | LowCurrentPivotLow : {2} | LowPreviousPivotLow : {3} " ,Time[0],CurrentBar,Low[CurrentPivotLow + 1 ], Low[PrevioustPivotLow + 1 ] ) );
//// Draw.Text(this, "Even"+CurrentBar, CurrentPivotLowBarValue.ToString() , 1 , Low[1] - 1 );
// }
//Other method
double PivotCurrentlow = 0 ;
double PreviousPivotlow = 0 ;
if (pl) {
PivotCurrentlow = Low[1] ;
Print(string.Format("The Time: {0} | CurrentBar: {1} | PivotCurrentlow:{2} | PreviousPivotlow : {3} " ,Time[0],CurrentBar, PivotCurrentlow , PreviousPivotlow ) );
if ( PivotCurrentlow > PreviousPivotlow ) {
PreviousPivotlow = PivotCurrentlow ;
Draw.Text(this, "Even"+CurrentBar, "Lower High" , 1 , Low[1] - iOffset);
}
if ( PivotCurrentlow <= PreviousPivotlow ) {
PreviousPivotlow = PivotCurrentlow ;
Draw.Text(this, "Even"+CurrentBar, "Lower Low" , 1 , Low[1] - iOffset);
}
}
Edit 2: I found one solution to my question using the Edit 1 methodology
//Other method
if (pl) {
double PivotCurrentlow = Low[1] ;
Print(string.Format("The Time: {0} | CurrentBar: {1} | PivotCurrentlow:{2} | PreviousPivotlow : {3} | " ,Time[0],CurrentBar, PivotCurrentlow , PreviousPivotlow) );
if ( PivotCurrentlow > PreviousPivotlow ) {
Draw.Text(this, "Higher Low"+CurrentBar, "[HL]" , 1 , Low[1] - iOffset2);
}
if ( PivotCurrentlow < PreviousPivotlow ) {
Draw.Text(this, "Lower Low"+CurrentBar, "[LL]" , 1 , Low[1] - iOffset2);
}
if ( PivotCurrentlow == PreviousPivotlow ) {
CountPivotLowABCDE = 1 ;
Draw.Text(this, "Equal Low"+CurrentBar, "[EQL]" , 1 , Low[1] - iOffset2);
}
PreviousPivotlow = Low[1] ;
}
But I am still interested to understand why the MRO solution is not working if you guys can guide on what i am doing wrong as in my opinion it could be much easier for me to keep track of previous values
Thanks in advance

Maybe there is something again that i don't understand to be able to retrieve the Bar number
Comment