Om det fortsatt är interessant så har du koden för Supertrend nedan. Jag tror den stämmer bra.
basicUpperband[0] = ((High[0] + Low[0]) / 2) + (p1 * ATR(p2)[0]);
basicLowerband[0] = ((High[0] + Low[0]) / 2) - (p1 * ATR(p2)[0]);
if ((basicUpperband[0] < finalUpperband[-1]) || (Close[-1] > finalUpperband[-1]))
finalUpperband[0] = basicUpperband[0]
else
finalUpperband[0] = finalUpperband[-1];
if ((basicLowerband[0] > finalLowerband[-1]) || (Close[-1] < finalLowerband[-1]))
finalLowerband[0] = basicLowerband[0]
else
finalLowerband[0] = finalLowerband[-1];
if ((SuperTrend[-1] == finalUpperband[-1]) && (Close[0] <= finalUpperband[0]))
SuperTrend[0] = finalUpperband[0];
if ((SuperTrend[-1] == finalUpperband[-1]) && (Close[0] >= finalUpperband[0]))
SuperTrend[0] = finalLowerband[0];
if ((SuperTrend[-1] == finalLowerband[-1]) && (Close[0] >= finalLowerband[0]))
SuperTrend[0] = finalLowerband[0];
if ((SuperTrend[-1] == finalLowerband[-1]) && (Close[0] <= finalLowerband[0]))
SuperTrend[0] = finalUpperband[0];
plot1[0] = SuperTrend[0]