Trading Nifty by Levels

AFL for SAR
(MSA ji plz check)


accel = Param("Acceleration", 0.03, 0, 1, 0.001);
mx = Param("Max. acceleration", 0.5, 0, 1, 0.001);

f_sar = SAR(accel,mx);

colordots = IIf(f_sar < L,colorBrightGreen,IIf( f_sar >
H,colorRed,colorWhite));

Buy = Cross(H,f_sar); Buy = Ref(Buy,-1); BuyPrice = O;
Sell = Cross(f_sar,L); Sell = Ref(Sell,-1); SellPrice = O;

SetBarsRequired(-2,-2);
SetChartOptions(0, chartShowDates);
Plot(C,"\nClose",colorWhite,64);
Plot(f_sar,"\nf_sar",colordots,styleDots|styleNoLine);

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,L,-15);
PlotShapes(IIf(Buy,shapeHollowUpArrow,shapeNone),colorWhite,0,L,-15);


PlotShapes(IIf(Buy,shapeHollowSmallCircle,shapeNone),colorWhite,0,BuyPrice,0);



PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15);
PlotShapes(IIf(Sell,shapeHollowDownArrow,shapeNone),colorWhite,0,H,-15);


PlotShapes(IIf(Sell,shapeHollowSmallCircle,shapeNone),colorWhite,0,SellPrice,0);
SetChartBkColor(3 ) ;
Hello Khushiji,
MSA Ji is using different Discussion Forum for his regular SAR update, and it is excellently performing ... If he permits then I can give that forum address on your mail...

But the code which is you gave above are little different then MSA ji,

Kindly send full code to my mail [email protected] so that I also can analyse the logic behind it...If you don't have problem to share it ???
 

khushi00

Well-Known Member
Hello Khushiji,
MSA Ji is using different Discussion Forum for his regular SAR update, and it is excellently performing ... If he permits then I can give that forum address on your mail...

But the code which is you gave above are little different then MSA ji,

Kindly send full code to my mail [email protected] so that I also can analyse the logic behind it...If you don't have problem to share it ???
tonight i will send other afl's for sar
 

msa5678

Well-Known Member
Khushiji, please give me 5 mins, I have just added the AFL in Ami and come back with the result.
Great , it is a Good one. I suggest addding a few lines so that we will get the price displayed along with the arrows.


dist = 1.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "Buy\n@" + C[ i ], i, L[ i ]-dist, colorBlack );
if( Sell ) PlotText( "Sell\n@" + C[ i ], i, H[ i ]+dist, colorBlack );
}
 
Great , it is a Good one. I suggest addding a few lines so that we will get the price displayed along with the arrows.


dist = 1.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "Buy\n@" + C[ i ], i, L[ i ]-dist, colorBlack );
if( Sell ) PlotText( "Sell\n@" + C[ i ], i, H[ i ]+dist, colorBlack );
}


Whatz this SAR about ? Can u give insight ? Just 2- 3 points enough as this is mkt time...don't want to disturb....
 
Great , it is a Good one. I suggest addding a few lines so that we will get the price displayed along with the arrows.


dist = 1.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "Buy\n@" + C[ i ], i, L[ i ]-dist, colorBlack );
if( Sell ) PlotText( "Sell\n@" + C[ i ], i, H[ i ]+dist, colorBlack );
}


MSA Ji,
Here Khushi Ji is using PSAR in above code...Is it right????

But the capturing Parabolic SAR reversal alone to take BUY SELL decision is bit risky ....we need to apply RSI & ADX with it to confirm BUY/SELL...

What say...???
 

khushi00

Well-Known Member
MSA plz plz check this also
(when free)




_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("Auto Trading System");
acc = Param("Acceleration", 0.019, 0, 1, 0.001 );
accm = Param("Max. acceleration", 0.019, 0, 1, 0.001 );
Plot( SAR( acc, accm ), _DEFAULT_NAME(), ParamColor( "Color", colorYellow ),
ParamStyle("Style", styleLine | styleLine, maskDefault | styleLine | styleLine )
);

Buy = Cross(Open, SAR(acc,accm));
Sell = Cross(SAR(acc,accm), Open );
Short=Sell;
Cover=Buy;
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone), colorYellow, 0, Low, Offset=-15);
PlotShapes(IIf(Sell, shapeDownArrow,shapeNone), colorBlue, 0, High,
Offset=-15);

AlertIf( Buy, "SOUND C:\\Windows\\Media\\Chord.wav", "Audio alert", 2 );
AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );

Filter = Buy OR Sell;

AddColumn( Buy, "Buy", 1);
AddColumn( Sell, "Sell", 1);

_SECTION_END();

_SECTION_BEGIN("BW Fractal");

//Fractal up

FUp =
((Ref(H,-4)<Ref(H,-2)) AND (Ref(H,-3)<Ref(H,-2)) AND (Ref(H,-1) <Ref(H,-2)) AND (H <Ref(H,-2))) OR
((Ref(H,-5)<Ref(H,-2)) AND (Ref(H,-4)<Ref(H,-2)) AND (Ref(H,-3)<=Ref(H,-2)) AND (Ref(H,-1)< Ref(H,-2)) AND (H <Ref(H,-2))) OR
((Ref(H,-6)<Ref(H,-2)) AND (Ref(H,-5)<Ref(H,-2)) AND (Ref(H,-4)<=Ref(H,-2)) AND (Ref(H,-3)<=Ref(H,-2)) AND (Ref(H,-1)<Ref(H,-2)) AND (H <Ref(H,-2))) OR
((Ref(H,-7)<Ref(H,-2)) AND (Ref(H,-6)<Ref(H,-2)) AND (Ref(H,-5)<=Ref(H,-2)) AND (Ref(H,-4)<=Ref(H,-2)) AND (Ref(H,-3)<=Ref(H,-2)) AND (Ref(H,-1)<Ref(H,-2)) AND (H <Ref(H,-2))) OR
((Ref(H,-8)<Ref(H,-2)) AND (Ref(H,-7)<Ref(H,-2)) AND (Ref(H,-6)<=Ref(H,-2)) AND (Ref(H,-5)<=Ref(H,-2)) AND (Ref(H,-4)<=Ref(H,-2)) AND (Ref(H,-3)<=Ref(H,-2)) AND (Ref(H,-1)<Ref(H,-2)) AND (H <Ref(H,-2)));

FractalUp = ValueWhen(FUp ,Ref(H,-2) ,1);

FUpBuyPrice = FractalUp + 0.01;
FUpHit = FUpBuyPrice <= H AND FUpBuyPrice >= L;
FUpSignalOn = Flip(Ref(FractalUp,-1) != FractalUp, FUpHit);

//Fractal Down

FDown=
((Ref(L,-4)>Ref(L,-2)) AND (Ref(L,-3)>Ref(L,-2)) AND (Ref(L,-1) >Ref(L,-2)) AND (L > Ref(L,-2))) OR
((Ref(L,-5)>Ref(L,-2)) AND (Ref(L,-4)>Ref(L,-2)) AND (Ref(L,-3)>=Ref(L,-2)) AND (Ref(L,-1) >Ref(L,-2)) AND (L > Ref(L,-2))) OR
((Ref(L,-6)>Ref(L,-2)) AND (Ref(L,-5)>Ref(L,-2)) AND (Ref(L,-4)>=Ref(L,-2)) AND (Ref(L,-3)>=Ref(L,-2)) AND (Ref(L,-1) >Ref(L,-2)) AND (L > Ref(L,-2))) OR
((Ref(L,-7)>Ref(L,-2)) AND (Ref(L,-6)>Ref(L,-2)) AND (Ref(L,-5)>=Ref(L,-2)) AND (Ref(L,-4)>=Ref(L,-2)) AND (Ref(L,-3)>=Ref(L,-2)) AND (Ref(L,-1)> Ref(L,-2)) AND (L > Ref(L,-2))) OR
((Ref(L,-8)>Ref(L,-2)) AND (Ref(L,-7)>Ref(L,-2)) AND (Ref(L,-6)>=Ref(L,-2)) AND (Ref(L,-5)>=Ref(L,-2)) AND (Ref(L,-4)>=Ref(L,-2)) AND (Ref(L,-3)>=Ref(L,-2)) AND (Ref(L,-1)> Ref(L,-2)) AND (L >Ref(L,-2)));

FractalDown=ValueWhen(FDown, Ref(L,-2), 1);

FDownSellPrice= FractalDown+ 0.01;
FDownHit = FDownSellPrice <= H AND FDownSellPrice >= L;
FDownSignalOn = Flip(Ref(FractalDown,-1) != FractalDown, FDownHit );

FractalBuy = Cross(C,FractalUp);
FractalSell = Cross(FractalDown,C);

//Plot Fractal on the title
ShowFSign = ParamToggle("Display Fractal Point", "No|Yes", 1);
ShowBSign = ParamToggle("Display Fractal Buy/Sell", "No|Yes", 1);

//PlotShapes(IIf(FractalBuy AND ShowBSign, shapeUpArrow, 0) ,colorCustom11, 0, L);
//PlotShapes(IIf(FractalSell AND ShowBSign, shapeDownArrow, 0) ,colorRed, 0, H);

Plot(Ref(FractalUp,4), "Fractal Up", ParamColor("Fractal Up Color", colorBrown) , ParamStyle("Fractal Up Style",styleLine|styleThick));
Plot(Ref(FractalDown,4), "Fractal Down", ParamColor("Fractal Down Color", colorBrown), ParamStyle("Fractal Down Style",styleLine|styleThick));
//PlotOHLC(Ref(FractalUp,4),Ref(FractalDown,4),Ref(FractalUp,4),Ref(FractalDown,4),"",colorAqua,styleCloud|4096,0,0,0);

//Looks into the future. This is done only to display Fractal arrow at the right bar.
//The calculation of the fractal up is done without looking into the future.
//PlotShapes(IIf((Ref(FractalUp,2) != Ref(FractalUp,1)) AND ShowFSign, shapeSmallCircle, shapeNone), colorWhite,0,Ref(FractalUp,2), 12);
//PlotShapes(IIf((Ref(FractalDown,2) != Ref(FractalDown,1)) AND ShowFSign, shapeSmallCircle, shapeNone), colorPink,0,Ref(FractalDown,2), -12);

_SECTION_END();




 

khushi00

Well-Known Member
Traders plz note
Any AFL i upload r not my creations
I just choose from my collections n upload
credit to, who wrote it
when i run on my PC i just write my name thats it
my contribution is just changes in original settings as per my style
 

khushi00

Well-Known Member
Hi khushi,

In the image its showing 4706 as resistance(Green Line) and 4643 as support(Red Line) in 3 min chart.

But for me its showing 4719 resistance and 4629 Support, why is it differs for me. I am also in 3 min chart

Can u help me out to figure this?


Also can we use this indicator for commodities. When i checked it out there is no support and resistance lines for commodities:confused::confused:

Can u please help me out

thanks


Anil
never tested for commodity
plz mail me i will send code agan
 

Similar threads