Simple Coding Help - No Promise.

Nehal_s143

Well-Known Member
Positional Buy Nifty already in gain of 250+ points, method seems to be next to Holy Grail ;) please help to code trend reversal

hi

I came across very good thread SH Swing trading system

Its very big thread 100+ pages, I am slow reader still at page 10, SH has given summary
at https://docs.google.com/file/d/0BwQT...QQQ/edit?pli=1

I was trying this method on Nifty future, I was surprised to see the chart,


I am trying to make afl for the same, but dont know how to write condition of last swing high/low broken for trend reversal and pullback to 15 ema.



Code:
_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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("Percent Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 17, 2, 300, 1 );
Width = Param("Width%", 1.5, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style", styleLine | styleNoLabel );
CenterLine = MA( P, Periods );
Plot( (1 + Width * 0.01) * CenterLine, "%EnvTop" + _PARAM_VALUES(), Color, Style ); 
Plot( (1 - Width * 0.01) * CenterLine, "%EnvBot" + _PARAM_VALUES(), Color, Style ); 
_SECTION_END();

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

_SECTION_BEGIN("ZIG - Zig");
P = ParamField( "Price field" );
change = Param("% change",0.3,0.1,25,0.1);
Plot( Zig(P, change), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
Please help me to write trend reversal code and pullback code

Thanks
 
Positional Buy Nifty already in gain of 250+ points, method seems to be next to Holy Grail ;) please help to code trend reversal
I guess you spoke a page too soon. On page 11 of the pdf document at google (the same one you also are referring to), the @Tradewithhunter clearly states following


Please review the method properly and the trade. Like any other method this one is no holy grail, it will have its whipsaws every now and then and the key will remain to be consistent, patient and disciplined.
 

Nehal_s143

Well-Known Member
Ref(K4, 1) ?

You've got a repainting problem too
Thanks sir, for pointing out the mistake in coding


Today it was repainting on Nifty1 5min chart


sir below afl code will not re-paint :)

Code:
_SECTION_BEGIN("Stochastic_30_MINS");
periods = Param( "Periods", 8, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 4, 1, 200, 1 );

TimeFrameSet(in1Minute * 30);
k30 = StochK( periods , Ksmooth);
d30 = StochD( periods , Ksmooth, DSmooth );
TimeFrameRestore();

K4	=	TimeFrameExpand(k30, in1Minute * 30, expandFirst);
D4	=	TimeFrameExpand(d30, in1Minute * 30, expandFirst);

Plot(D4, "D4", colorRed, styleDashed );
Plot(K4, "K4", colorBlue, styleDashed );


mycNTIth=IIf(k4>d4,colorBlue,
     IIf(k4<d4,colorRed,31));

Plot(6, "", mycNTIth, styleOwnScale| styleArea|styleNoLabel,-0.5,100);

_SECTION_END();
 
Can someone please post an afl to plot a bar(OHLC) chart from the prices of 2 stocks, A and B?
Something like Oa/Ob, Ha/Hb, La/Lb, Ca/Cb and plot the result. It should be useful for pair trading.
Thanks.
 

ocil

Well-Known Member
New code is also repainting. Can any one confirm ? i think (expandFirst) is culprit ...I am not programmer
Mastermind pls help... :)
Thanks sir, for pointing out the mistake in coding


Today it was repainting on Nifty1 5min chart


sir below afl code will not re-paint :)

Code:
_SECTION_BEGIN("Stochastic_30_MINS");
periods = Param( "Periods", 8, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 4, 1, 200, 1 );

TimeFrameSet(in1Minute * 30);
k30 = StochK( periods , Ksmooth);
d30 = StochD( periods , Ksmooth, DSmooth );
TimeFrameRestore();

K4	=	TimeFrameExpand(k30, in1Minute * 30, expandFirst);
D4	=	TimeFrameExpand(d30, in1Minute * 30, expandFirst);

Plot(D4, "D4", colorRed, styleDashed );
Plot(K4, "K4", colorBlue, styleDashed );


mycNTIth=IIf(k4>d4,colorBlue,
     IIf(k4<d4,colorRed,31));

Plot(6, "", mycNTIth, styleOwnScale| styleArea|styleNoLabel,-0.5,100);

_SECTION_END();
 
Last edited:

extremist

Well-Known Member
Somehow i am feeling that new code is also repainting. Can any one confirm ?
Mastermind pls help... :)
The indicator is fine.
It is not looking in to future.

Though u might feel like it is repainting in live market because in Timefameexpand he has used expand first.
due to this it will display the current value as it comes.

As u have selected the HTF during the period frm start of the first min to last min from 30 min it will keep on changing the value.
as the candle of 30 min is closed the value will be finalized.
It wont change after completion of that candle. so this not repainting.

Though if it is bothering u then change the expandfirst to expandlast.

but due to this adjustment u may find tht indicator is actually lagging by 30 min.
Coz it will display the value after the completion of the timeframe.
so during the current candle it will display last candles value.

Now choice is yours.

I prefer expandfirst.
 
i want to replace buy sell arrow with letter "K" .. in supertrend afl when ever buy sell signal comes
k

please use PlotText instead of PlotShape. Also, realize that unlike PlotShape, You will also need to surround plot text with a loop.
 

Similar threads