How to code this Strategy ?

#1
Hi,

First of all thanks to the teachers on the forum (especially Saint). I am just a new learner (obvious from my posts). Hence, request all the senior members to help.

I had tested a strategy which had given good results on chartnexus. Strategy is: "N-days-Breakouts". The AFL has more info in detail.

Need to code a similar but better strategy such that:

1. it can be backtested
2. Elements could be toggled (as it might lead to many lines drawn on live chart)

(the figure attached is actually of a different Support Resistance afl. It helps to visualize the requirement of permanent lines that should remain from High to BO candle)

As i have no idea of coding (so copied some from other codes) and tried my best. Came up with this code below WHICH DOES NOT WORK CORRECTLY and also does not draws permanent lines from High to BO .

Waiting for help!

Hope this also helps the Traderji Community.


/*=======================================*/
/*AFL to Trade Breakouts in any TimeFrame*/
/*=======================================*/


myTF = Param("TimeFrame in Hours",1,0.25,2000,0.25,0);

/*
Below we will convert the above input -- from hours to multiple of 60 seconds --
as Amibroker defines Interval in minimum of 60 seconds (http://www.amibroker.com/guide/afl/timeframeset.html)
*/

tf = myTF*3600;

LastHigh = LastValue(TimeFrameGetPrice("High", tf, 1));
LastLow = LastValue(TimeFrameGetPrice("Low", tf, 1));

/*
the figure attached is actually of a different Support Resistance afl. It helps to visualize the requirement of permanent lines that should remain from High to BO candle
*/

Plot (LastValue(TimeFrameGetPrice("High", LastHigh, 1)), "High", ParamColor("High Color", colorGreen));
Plot (LastValue(TimeFrameGetPrice("Low", LastLow, 1)), " Low", ParamColor("Low Color", colorOrange));



/*****************************************************************************************************
-------------
|Sensitivity|
-------------

There can be too many lines plotted on chart using this code (OR a few other
indicators). The need is to maintain focus AND remove distractions by
plotting only what is needed.

So, audio-visual Alerts should trigger only when trade setup is about
to emerge. So, we get sufficient time prepare for the breakout trade.

Line starting from Past High should touch OR Cross the candle slightly
that has given the breakout

IMPORTANT - this might speed up our analysis as can be detected visually as to "which
timeframe" and "which issue/share" generally gives more such successful breakouts
IMPORTANT --- Also should help later in locating AND drawing Support Resistances as we go ahead in time

----------------------
|Defining Sensitivity|
----------------------
- The distance of Current Price from the Previous High at which the system triggers Audio-Visual alerts
- Trader should be able to change this distance based on market conditions (fast/slow markets) etc.

****************************************************************************************************/

Sensitivity = Param("Sensitivity",.0008,.0005,.005,.0001,0);
HBOalert = IIf((H >= (LastHigh - LastHigh*Sensitivity)) AND (H < LastHigh) ,colorGreen,colorBlack);
LBOalert = IIf((L <= (LastHigh - LastHigh*Sensitivity)) AND (L > LastLow) ,colorRed,colorBlack);
 
Last edited:

Similar threads