Travi,
I need a help on this one too.
its Supertrend AFL
I modified the below code with ATR period as 7 and the factor as 3 but it looks like producing different result than that of investing.com 's suertrend with 7 and 3 values.
I have provided the chart of banknifty in 5 min chart with supertrend 7 and 3 taken fron investing.com. if you use the below code in amibroker for banknifty, it is producing different result. Could you please help
Note: unfortunately I dont have banknifty chart from amibroker. its bit complicated.actually I am checking this afl with options contracts and Investing.com and my SAS online trading terminal are producing same results for 7 and 3. so I compared my optiones contract from my trading terminal with amibroker chart. they are producing different results
//Code taken from the below link
//http://www.traderji.com/amibroker/90119-simple-coding-help-no-promise-496.html#post1227583
_SECTION_BEGIN("Super Trend");
Factor=Param("Factor",4,1,10,0.1);
Pd=Param("ATR Periods",10,1,200,1);
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;
for (i = 1; i <BarCount-1; i++) {
TrendUp = Null;TrendDown = Null; trend=1;
if (Close>Up[i-1]) {
trend=1;
if (trend[i-1] == -1) changeOfTrend = 1;
}
else if (Close<Dn[i-1]) {
trend=-1;
if (trend[i-1] == 1) changeOfTrend = 1;
}
else if (trend[i-1]==1) {
trend=1;
changeOfTrend = 0;
}
else if (trend[i-1]==-1) {
trend=-1;
changeOfTrend = 0;
}
if (trend<0 && trend[i-1]>0) {flag=1;}
else {flag=0;}
if (trend>0 && trend[i-1]<0) {flagh=1;}
else {flagh=0;}
if (trend>0 && Dn<Dn[i-1]){Dn=Dn[i-1];}
if (trend<0 && Up>Up[i-1]){ Up=Up[i-1];}
if (flag==1){ Up=(H+L)/2+(Factor*iATR);}
if (flagh==1){ Dn=(H+L)/2-(Factor*iATR);}
if (trend==1) {
TrendUp=Dn;
if (changeOfTrend == 1) {
TrendUp[i-1] = TrendDown[i-1];
changeOfTrend = 0;
}
}
else if (trend==-1) {
TrendDown=Up;
if (changeOfTrend == 1) {
TrendDown[i-1] = TrendUp[i-1];
changeOfTrend = 0;
}
}
}
Plot(TrendUp,"TrendUp",colorGreen);
Plot(TrendDown,"TrendDown",colorRed);
_SECTION_END();
I need a help on this one too.
its Supertrend AFL
I modified the below code with ATR period as 7 and the factor as 3 but it looks like producing different result than that of investing.com 's suertrend with 7 and 3 values.
I have provided the chart of banknifty in 5 min chart with supertrend 7 and 3 taken fron investing.com. if you use the below code in amibroker for banknifty, it is producing different result. Could you please help
Note: unfortunately I dont have banknifty chart from amibroker. its bit complicated.actually I am checking this afl with options contracts and Investing.com and my SAS online trading terminal are producing same results for 7 and 3. so I compared my optiones contract from my trading terminal with amibroker chart. they are producing different results
//Code taken from the below link
//http://www.traderji.com/amibroker/90119-simple-coding-help-no-promise-496.html#post1227583
_SECTION_BEGIN("Super Trend");
Factor=Param("Factor",4,1,10,0.1);
Pd=Param("ATR Periods",10,1,200,1);
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;
for (i = 1; i <BarCount-1; i++) {
TrendUp = Null;TrendDown = Null; trend=1;
if (Close>Up[i-1]) {
trend=1;
if (trend[i-1] == -1) changeOfTrend = 1;
}
else if (Close<Dn[i-1]) {
trend=-1;
if (trend[i-1] == 1) changeOfTrend = 1;
}
else if (trend[i-1]==1) {
trend=1;
changeOfTrend = 0;
}
else if (trend[i-1]==-1) {
trend=-1;
changeOfTrend = 0;
}
if (trend<0 && trend[i-1]>0) {flag=1;}
else {flag=0;}
if (trend>0 && trend[i-1]<0) {flagh=1;}
else {flagh=0;}
if (trend>0 && Dn<Dn[i-1]){Dn=Dn[i-1];}
if (trend<0 && Up>Up[i-1]){ Up=Up[i-1];}
if (flag==1){ Up=(H+L)/2+(Factor*iATR);}
if (flagh==1){ Dn=(H+L)/2-(Factor*iATR);}
if (trend==1) {
TrendUp=Dn;
if (changeOfTrend == 1) {
TrendUp[i-1] = TrendDown[i-1];
changeOfTrend = 0;
}
}
else if (trend==-1) {
TrendDown=Up;
if (changeOfTrend == 1) {
TrendDown[i-1] = TrendUp[i-1];
changeOfTrend = 0;
}
}
}
Plot(TrendUp,"TrendUp",colorGreen);
Plot(TrendDown,"TrendDown",colorRed);
_SECTION_END();