protected override void OnBarUpdate() { if(CurrentBar <= Period) { // bar_Count.Set(0); // up_Bar_Count.Set(0); // dn_Bar_Count.Set(0); return; } [COLOR="Red"] for (int x = Count_Length; x > 0; x--) { if( x == Count_Length) { bar_Count.Set(0); up_Bar_Count.Set(0); dn_Bar_Count.Set(0); } else if (Close[Count_Length] >= Open[Count_Length] ) { bar_Count.Set(bar_Count[1] + 1) ; // up_Bar_Count.Set(up_Bar_Count[1] + 1); } else if (Close[Count_Length] < Open [Count_Length] ) { bar_Count.Set(bar_Count[1] - 1) ; // dn_Bar_Count.Set(dn_Bar_Count[1] + 1); } }[/COLOR] // double ratio = up_Bar_Count[0] / dn_Bar_Count[0]; UpDnBarCount.Set(bar_Count[0] ); Max_Ratio.Set((MAX(UpDnBarCount, Period)[0])); Min_Ratio.Set((MIN(UpDnBarCount, Period)[0])); Avg_Count.Set(EMA(UpDnBarCount, Period)[0]); if (Prnt_Values) { Print(CurrentBar + " Bar Count " + Instrument.FullName + " is " + UpDnBarCount); // Print (CurrentBar + " Average True Range for " + Instrument.FullName + " is " + Value[0]); }
Thanks
DaveN
Comment