Afl required for HPT model system-here is ts code

#1
(courtesy HPT,By Marcel Link)
===============================================
ADX(14) ABOVE 30=NOW STRONG TRENDING PHASE-Go on buddy
ADX(14) BELOW 20= NOW WEAK TRENDING PHASE -Hey Man Go slow-reduce ps
ADX(14) BELOW 16= NOW NO TREND AT ALL PHASE - Hey WRONG TIME to trade
===========================================================
Can I get a code line for the above,please
> general caution
>
Two precautions I think of are
1 Dont trade against trend of major index(say ^DJI,ETC)
2.Dont trade in a weak or no trend zone OR ATLEAST TRADE WITH RIGHT INDICATORS
>
> how to use the precautions? possibly try these
>
> a ribbon at chart bottom of ^Dji trend-GIVES INDIRECT HINT
> Another ribbon of ADX and pdi-mdi Gives trending up-trending down or no trend at all
>
> After this any system can be safely used with its natural advantages
> ===========================================================
> wish2
> I am trying to code the following.
> came some distance
> still need more to do
> any help is welcome
> =========================================
>
> HPT MODEL SYSTEM
>
>
> This sample system should give you a good idea of what
> goes into writing a system AND what it should look like.
>
> This system buys when the market breaks above the Highest
> bar of the last 10 periods, with a Filter of a 0.5 standard deviation
> move of the last 10 bars.
> The Sell Signal is just the opposite.
> The entry is simple enough,
> Marcel says
> but I made the exit more interesting by
> using the ADX to give me
> different exit conditions.
> if it is strong
> AND the market is trending, the system will stay in until two moving
> averages Cross;
> if the ADX is weak, the system takes profits
> after 10 bars;
> AND if it is in between, it will exit if the stochastics
> reach overbought territory.
>
> Finally, the system exits on a stop if the
> price is more than 2 standard deviations from the entry price.
> //=================================
> Input: Length(10), BSE(10), LengthADX(10),
> SD(.5)Length1(10),Length2(35);
> {*******ENTRY SIGNALS*******}
> If Close > Highest(High,Length)[1]
> StdDev(Close,10)[1]* SD Then Buy("Buy1") On
> Close;
> If Close < Lowest(Low,Length)[1]
> StdDev(Close,10)[1]* SD Then Sell("Sell1")On
> Close;
> {********** STOPS **********}
> ExitLong("Stop1") From Entry("Buy1") at$ Close -
> 2*StdDev(Close,10) Stop;
> ExitShort("Stop2") From Entry("Sell1") at$ Close +
> 2*StdDev(Close,10) Stop;
>
> {********** EXITS **********trade station code }
> If ADX(LengthADX)> 30 Then
> If Average(Close,Length1) Crosses Below
> Average(Close,Length2) Then ExitLong ("ExitL1");
> If Average(Close,Length1) Crosses Above
> Average(Close,Length2) Then ExitShort ("ExitS1");
> Else
> If ADX(LengthADX) < 20 Then
> If BarsSinceEntry=BSE Then
> ExitLong("ExitL2");
> If BarsSinceEntry=BSE then
> ExitShort("ExitL2");
>  
> Else
> If SlowD(14)> 85 Then
> ExitLong("ExitL3");
> If SlowD(14)< 15 Then
> ExitShort("ExitL3");
> */
> std = 0.5*StDev( Close, 10 );
> Buy = Cross(C,(HHV(H,10) + std)) ;
> Sell = Cross((LLV(L,10) - std),C);
> IIf( (Buy),PlotShapes(shapeUpTriangle*Buy,colorBlue),0);
> IIf( (Sell),PlotShapes(shapeDownTriangle*Sell,colorRed),0);
> Longexitstop = Buy - 2*StDev( Close, 10 );
> Shortexitstop = Sell + 2*StDev( Close, 10 );
> Plot(Longexitstop,"LESTP",colorRed,styleThick);
> Plot(Shortexitstop,"SHESTP",colorBlue,styleThick);
//if ADX(10) > 30, THEN EXIT if MA(C,10) CrossES MA(C,35)
Exitlong = IIf(ADX(10)> 30,Sell == Cross(MA(C,35),MA(C,10)),0);
Exitshort = IIf(ADX(10) > 30,Sell == Cross(MA(C,10),MA(C,35)),0);
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();


========================================
can somebody code this in afl please
ford
 

Similar threads