In reviewing a previous post, I found a code to determine previous swing highs.
int BarsAgo = Swing(5).SwingHighBar(0, 1, Bars.BarsSinceNewTradingDay);
if(BarsAgo < 0 || CurrentBar <= BarsAgo) return;
double swingHigh = Swing(5).SwingHigh[BarsAgo];
Print(swingHigh);
int BarsAgo2 = Swing(5).SwingHighBar(0, 2, Bars.BarsSinceNewTradingDay);
if(BarsAgo2 < 0 || CurrentBar <= BarsAgo2) return;
double swingHigh2 = Swing(5).SwingHigh[BarsAgo2];
Print(swingHigh2);
This is exactly what I was looking for, but when I add this to my strategy, it compiles but does not run in the chart. It produces a bars issue (i have 20 years of data loaded) I believe due to the if(BarsAgo < 0 || CurrentBar <= BarsAgo) return;.
I'm not sure how to fix this, so I was wondering if anyone has any suggestions on what I can try?
Thanks,
Lee
Comment