help needed to code the system

dell

Well-Known Member
#11
write these line at above buy sell condition ,
adxrange = Param("ADX range", 14, 8, 15, 1);
adxfactor =Param("ADX factor", 22, 8, 30, 1);
MyAdx = ADX(adxrange);

and in buy and short condition add this line
AND MyAdx > Ref(MyAdx, -1) AND MyAdx>adxfactor

and u are done .
 

dell

Well-Known Member
#12
Bro plz tell specifically where shd i add the */ for backtesting
add this line at top
setpositionsize(4,4);

and put " // " before line positionsize=350000

now open information window ,
see contract specification
in round lot size =1
margin deposit=250
ticksize=0
point value =50

here see , for nifty we know 1point difference makes 50 rs , so in point value we write 50 , for bnf there is 1point difference makes 25 rs , so we write 25 in point value place .
once done
u r ready to backtest ........
 

bunti_k23

Well-Known Member
#13
write these line at above buy sell condition ,
adxrange = Param("ADX range", 14, 8, 15, 1);
adxfactor =Param("ADX factor", 22, 8, 30, 1);
MyAdx = ADX(adxrange);

and in buy and short condition add this line
AND MyAdx > Ref(MyAdx, -1) AND MyAdx>adxfactor

and u are done .
Dell bhai :lol: its showing the compilation error wit yellow hilight plz post the changes along wit the complete system if possible
 
#14
Dell bhai :lol: its showing the compilation error wit yellow hilight plz post the changes along wit the complete system if possible
_SECTION_BEGIN("SuperTrend");
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);

Plot( C, "Close", ParamColor("Color", colorWhite ), styleThick | ParamStyle("Style") | GetPriceStyle() );


_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

PositionSize = 350000;

TrendMode = ParamToggle("TrendMode","Off|On",1);
Factor=Optimize("Factor",2,0.1,10,0.1);
Pd=Optimize("ATR Periods",5,1,20,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; 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,"Trend",colorWhite);
Plot(TrendDown,"Down",colorWhite);


/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/

TrendMode = ParamToggle("TrendMode","Off|On",1);
Factor1=Optimize("Factor1",0.6,5,10,2);
Pd1=Optimize("ATR Periods1",5,1,10,1);
Up1=(H+L)/2+(Factor1*ATR(Pd1));
Dn1=(H+L)/2-(Factor1*ATR(Pd1));
iATR1=ATR(Pd1);
TrendUp1=TrendDown1=Null;
trend1[0]=1;
changeOfTrend1=0;
flag1=flagh1=0;

for (i = 1; i <BarCount; i++) {
TrendUp1 = Null;
TrendDown1 = Null;

trend1=1;


if (Close>Up1[i-1]) {
trend1=1;
if (trend1[i-1] == -1) changeOfTrend1 = 1;

}
else if (Close<Dn1[i-1]) {
trend1=-1;
if (trend1[i-1] == 1) changeOfTrend1 = 1;
}
else if (trend1[i-1]==1) {
trend1=1;
changeOfTrend1 = 0;
}
else if (trend1[i-1]==-1) {
trend1=-1;
changeOfTrend1 = 0;
}

if (trend1<0 && trend1[i-1]>0) {
flag1=1;
}
else {
flag1=0;
}

if (trend1>0 && trend1[i-1]<0) {
flagh1=1;
}
else {
flagh1=0;
}

if (trend1>0 && Dn1<Dn1[i-1]){
Dn1=Dn1[i-1];
}

if (trend1<0 && Up1>Up1[i-1])
{ Up1=Up1[i-1];
}

if (flag1==1)
{ Up1=(H+L)/2+(Factor1*iATR1);;
}
if (flagh1==1)
{ Dn1=(H+L)/2-(Factor1*iATR1);;
}
if (trend1==1) {
TrendUp1=Dn1;
if (changeOfTrend1 == 1) {
TrendUp1[i-1] = TrendDown1[i-1];
changeOfTrend1 = 0;
}
}
else if (trend1==-1) {
TrendDown1=Up1;
if (changeOfTrend1 == 1) {
TrendDown1[i-1] = TrendUp1[i-1];
changeOfTrend1 = 0;
}
}
}

Plot(TrendUp1,"Trend",colorBlue);
Plot(TrendDown1,"Down",colorRed);


/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/

adxrange = Param("ADX range", 14, 8, 15, 1);
adxfactor =Param("ADX factor", 22, 8, 30, 1);
MyAdx = ADX(adxrange);
Buy = trend==1 AND trend1==1 AND MyAdx > Ref(MyAdx, -1) AND MyAdx>adxfactor ;
Short=trend==-1 AND trend1==-1 AND MyAdx > Ref(MyAdx, -1) AND MyAdx>adxfactor;
Sell=trend1==-1;
Cover=trend1==1;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);



BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);


Title = EncodeColor(colorWhite)+ "Super Trend AFL code from www.marketcalls.in" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorYellow)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","");

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-20);
PlotShapes(IIf(Sell==1, shapeStar, shapeNone), colorRed, 0,High, Offset=30);
PlotShapes(IIf(Short==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
PlotShapes(IIf(Cover==1, shapeStar, shapeNone), colorGreen, 0,Low, Offset=-30);


_SECTION_END();
 

bunti_k23

Well-Known Member
#15
I request to the moderator to close this thread plzzz.
 

bunti_k23

Well-Known Member
#16
:annoyed:so far i found this much



_SECTION_BEGIN("SuperTrend");
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);

HaClose = (O + H + L + C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
xDiff = (HaHigh - Halow) * 10000;
barcolor = IIf(HaClose >= HaOpen,colorBrightGreen,colorRed);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

PositionSize = 350000;

TrendMode = ParamToggle("TrendMode","Off|On",1);
Factor=Optimize("Factor",4,0.1,10,0.1);
Pd=Optimize("ATR Periods",5,1,20,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; 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,"Trend",colorBlue);
Plot(TrendDown,"Down",colorRed);


/*========================================================================================================================================================================*/
/*========================================================================================================================================================================*/
/*========================================================================================================================================================================*/

TrendMode = ParamToggle("TrendMode","Off|On",1);
Factor1=Optimize("Factor1",2,5,10,2);
Pd1=Optimize("ATR Periods1",5,1,10,1);
Up1=(H+L)/2+(Factor1*ATR(Pd1));
Dn1=(H+L)/2-(Factor1*ATR(Pd1));
iATR1=ATR(Pd1);
TrendUp1=TrendDown1=Null;
trend1[0]=1;
changeOfTrend1=0;
flag1=flagh1=0;

for (i = 1; i <BarCount; i++) {
TrendUp1 = Null;
TrendDown1 = Null;

trend1=1;


if (Close>Up1[i-1]) {
trend1=1;
if (trend1[i-1] == -1) changeOfTrend1 = 1;

}
else if (Close<Dn1[i-1]) {
trend1=-1;
if (trend1[i-1] == 1) changeOfTrend1 = 1;
}
else if (trend1[i-1]==1) {
trend1=1;
changeOfTrend1 = 0;
}
else if (trend1[i-1]==-1) {
trend1=-1;
changeOfTrend1 = 0;
}

if (trend1<0 && trend1[i-1]>0) {
flag1=1;
}
else {
flag1=0;
}

if (trend1>0 && trend1[i-1]<0) {
flagh1=1;
}
else {
flagh1=0;
}

if (trend1>0 && Dn1<Dn1[i-1]){
Dn1=Dn1[i-1];
}

if (trend1<0 && Up1>Up1[i-1])
{ Up1=Up1[i-1];
}

if (flag1==1)
{ Up1=(H+L)/2+(Factor1*iATR1);;
}
if (flagh1==1)
{ Dn1=(H+L)/2-(Factor1*iATR1);;
}
if (trend1==1) {
TrendUp1=Dn1;
if (changeOfTrend1 == 1) {
TrendUp1[i-1] = TrendDown1[i-1];
changeOfTrend1 = 0;
}
}
else if (trend1==-1) {
TrendDown1=Up1;
if (changeOfTrend1 == 1) {
TrendDown1[i-1] = TrendUp1[i-1];
changeOfTrend1 = 0;
}
}
}

Plot(TrendUp1,"Trend",colorWhite);
Plot(TrendDown1,"Down",colorWhite);


/*========================================================================================================================================================================*/
/*========================================================================================================================================================================*/
/*========================================================================================================================================================================*/

Buy = trend==1 AND trend1==1 ;
Short=trend==-1 AND trend1==-1;
Sell=trend1==-1;
Cover=trend1==1;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);



BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);


Title = EncodeColor(colorWhite)+ "Super Trend AFL code from www.marketcalls.in" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorYellow)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","");

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-40);
PlotShapes(IIf(Sell==1, shapeStar, shapeNone), colorRed, 0,High, Offset=30);
PlotShapes(IIf(Short==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-40);
PlotShapes(IIf(Cover==1, shapeStar, shapeNone), colorGreen, 0,Low, Offset=-30);


_SECTION_END();



P = ParamField("Price field",-1);
Periods = Param("Periods", 9, 2, 300, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );



tf is 3m or 5m i like 3min ,3min is not too fast like 1min and not so late like 5min,the higher parameter supertrend line with the parameters 4 factors will indicate the main trend of intraday when its red the trend is down when its blue the trend is up. but to take the entries and exit iam trying for suitable parameters for the faster supertrend line which is in white color ,anybody have any idea ,anybody like to help in this welcome:thumb:
 

Similar threads