well... here is the code for it

Quote:
function run()
{
set(PLOTNOW);

StartDate = 20150101;
LookBack = 500;
BarPeriod = 30;
NumYears = 1;


PlotBars = 1000;

vars Price= series(price());

int factor =3;
int Period = 10;

TimeFrame = 1;

vars UpBand = series();
vars DnBand = series();
UpBand[0] = (priceHigh()+priceLow())/2 + factor*ATR(Period);
DnBand[0] = (priceHigh()+priceLow())/2 - factor*ATR(Period);

vars ST = series();
ST[0] = 0;

vars Direction = series();
Direction[0] = 1;//just to initialize

vars PriceC = series(priceClose());

// Begin Direction calculation
if ( PriceC[0] > UpBand[1] )
Direction[0] = 1;
else
if ( PriceC[0] < DnBand[1] )
Direction[0] = -1;
else
Direction[0] = Direction[1];
// End Direction calculation

// Begin SuperTrend calculation
if ( Direction[0] == 1 )
{
if ( DnBand[1] > DnBand[0] )
DnBand[0] = DnBand[1];

ST[0] = DnBand[0];
plot("ST",ST[0],0,GREEN);

}
else
if ( Direction[0] == -1 )
{
if ( UpBand[1] < UpBand[0] )
UpBand[0] = UpBand[1];

ST[0] = UpBand[0];
plot("ST2",ST[0],0,RED);
}
// End SuperTrend calculation


plot("ST3",ST[0],0,DARKGREEN);


}