below you will find my code. Please ignore my comments
protected override void OnBarUpdate()
{
/* Only need to sync DataSeries objects once. We couldn't do this sync in the Initialize() method because we
cannot access the BarsArray property there. */
if (diff == null && BarsInProgress == 1)
{
/* Syncs another DataSeries object to the secondary bar object.
We use an arbitrary indicator overloaded with an IDataSeries input to achieve the sync.
The indicator can be any indicator. The DataSeries will be synced to whatever the
BarsArray[] is provided.*/
diff = new DataSeries(SMA(BarsArray[1], 50));
}
//checks we have enough bars to calculate
if(CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
return;
double marker = 0;
//double marker2 = 0;
double stop = 0;
if (BarsInProgress == 0)
{
if (CurrentBar < 2)
return;
double Open12 = Opens[1][2];
double Close12 = Closes[1][2];
double Open11 = Opens[1][1];
double Close11 = Closes[1][1];
double Open10 = Opens[1][0];
double Close10 = Closes[1][0];
double Open00 = Opens[0][0];
double Close00 = Closes[0][0];
double Low10 = Lows[1][0];
double Low11 = Lows[1][1];
if (Open12 > Close12 && Open11 < Close11 && Open10 < Close10 && (ToDay(Time[0]) != ToDay(Time[1])))
//&& Close00 <= Open00 && Close00 >= Open00)
{
marker = marker + 1;
}
int dummybarsago = 0;
int barcounting = 0;
/*if (ToDay(Time[0]) != ToDay(Time[1]))
{
dummybarsago = dummybarsago +1;
}*/
bool dummymarker = false;
if (marker == 1)
{
dummymarker = true;
}
//int barsAgo = MRO(delegate {return Close[0] > Open[0];}, 1, 9);
int barsAgo = MRO(delegate {return dummymarker == true;}, 1, 9);
/*double marker2 = dummybarsago;
double dummystop = Lows[1][dummybarsago];
double Open00 = Opens[0][0];
if ( dummystop > Open00)
{
stop = stop + 1;
}*/
Marker2.Set(barsAgo);
/*int dummybarsago = 1;
if (ToDay(Time[0]) != ToDay(Time[1]))
{
dummybarsago = dummybarsago +1;
}
double marker2 = dummybarsago;
double dummystop = Lows[1][dummybarsago];
double Open00 = Opens[0][0];
if ( dummystop > Open00)
{
stop = stop + 1;
}
Marker2.Set(marker2);
*/
Marker.Set(marker);
Stop.Set(stop);
}
My problem is simple if I add the line //int barsAgo = MRO(delegate {return Close[0] > Open[0];}, 1, 9); (right now its in the comment section) the variable int barsAgo counts the bars to the events perfectly. But if I'm using the boolean variable like:
int barsAgo = MRO(delegate {return dummymarker == true;}, 1, 9);
it just does not work. A value of -1 is plotted even if the variable dummymarke is true....
Any suggestion from you guys?
Being very grateful for your help,
Best wishes,
Andrew
Comment