Algo Trading using 52 Week High Low Strategy
52 Week HL Strategy
In this episode, we will be
scripting a Strategy for intraday traders to trade using a
simple 52 Week HL. This strategy is back-testable.
So, let’s begin with the rules….
Rules
Buy :
We need to buy, If price closes above the 52 Week High
Short :
We need to short, If price closes below the 52 Week Low
Simple., isn’t it?
Moving on to the script part.
First, we setting the 52 Week High and Low value in the chart title for
easy usage and setting the title.
_SECTION_BEGIN(“52-Wk-H-L”);
Hclose=HHV(H,250);
Lclose= LLV(L,250);
Sha1 =
EncodeColor(colorGreen) + “52-Week-High = ” + Hclose +
“\n”;
Sha2 =
EncodeColor(colorRed) + “52-Week-Low = ” + Lclose + “\n”;
_N(Title =
StrFormat(“{{NAME}} ({{INTERVAL}}), {{DATE}} ; {{OHLCX}}, V=%1.0f\n
{{VALUES}}\n\n”, V) + Sha1 + Sha2);
_SECTION_END();
Then comes the buy and sell signal,
Buy = Close > Ref(HHV(High,250),-1);
Sell = Close < Ref(LLV(Low,250),-1);
We will buy, If price closes
above the 52 Week High
Likewise, We will short, If
price closes below the 52 Week Low
For 52 Week high, we will be
considering 250 candl es. Considering we have 5 working days a week, we will have
260 working days and we are taking out 10 days for holidays, so 250 candles is
good enough.
//52 Week High Low
High52 = HHV(High,250);
Low52 = LLV(Low,250);
Filter = 1;
Last few lines of code is to
plot the values to back test report which is not mandatory.
AddColumn(High52,”52 Week High”);
AddColumn(Low52,”52 Week
Low”);
Check Out Script Library to get script used for this episode:
https://marketsecrets.in/script-library/
To know more, checkout:
Related
amibroker tutorial videos Getting started with algo-trading basics how to backtest a trading strategy? how to do algo trading in india? how to do algo trading in Zerodha? how to start with algo trading in india? how to use amibroker afl for algo trading? how to use pine script for algo trading? how to write algo trading scripts? Pine script tutorial videos step-by-step approach to start with algo-trading in India