#define _SUM_PLUS 0 // register for AssetInt
#define _SUM_MINUS 1 // register for AssetInt
//---------------- indicator -----------------------------
double idxPL(){
int sumUP = AssetInt[_SUM_PLUS];
int sumDN = AssetInt[_SUM_MINUS];
var pl=0;
if (priceClose() > priceClose(1)){
sumUP++;
sumDN=0;
pl=(sumUP/12.0)*100;
}
if (priceClose() < priceClose(1)){
sumUP=0;
sumDN++;
pl=-(sumDN/12.0)*100;
}
//watch("\n",sumDN,sumUP,pl);
AssetInt[_SUM_PLUS] = sumUP;
AssetInt[_SUM_MINUS]= sumDN;
return pl;
}
function run()
{
set(PLOTNOW+LOGFILE);
//set(STEPWISE);
StartDate=2020;
BarPeriod = 60;
LookBack = 1;
PlotScale = 8;
PlotWidth = 1600;
PlotHeight1 = 600;
PlotHeight2 = 120;
assetList("Assets");
if (is(INITRUN)){
assetHistory(Asset,1);
}
vars aPL = series(idxPL());
plot("PLine",aPL,NEW,BLUE);
}