E-Mini Trading Strategy (Amibroker Code)
The original article is here.
Logic in plain English:
- Calculate a 10-day average of the (High minus Low – (H-L)). That is the “ATR”.
- Calculate the High of the last 10 days.
- Calculate a band 3.5 times below the 10-day High using the average from point number 1 (ATR).
- If @ES closes below the band in number 3, then go long at the close.
- Exit at the close when the close is higher than yesterday’s high.
Amibroker code:
range=MA((H-L),10);
OddisHigh=HHV(H,10);
OddisBand=OddisHigh - (range*3.5);
Buy=Close<OddisBand ;
buyprice= Close;
Sell= C>Ref(H,-1) ;
sellPrice= Close;
Tradestation code
{
e-mini futures strategy (no 160):
Calculate a 10-day average of the (High minus Low – (H-L)). That is the “ATR” or Range.
Calculate the High of the last 10 days.
Calculate a band 3.5 times below the 10-day High using the average from point number 1 (ATR).
If @ES closes below the band in number 3, then go long at the close.
Exit at the close when the close is higher than yesterday’s high.
}
Inputs:
Lookback(10),
RangeMult(3.5);
Vars:
Range(0),
HighestHigh(0),
Treshold(0);
Range = Average(H - L, Lookback);
HighestHigh = Highest(H, Lookback);
Treshold = HighestHigh - RangeMult * Range;
if Marketposition = 0 and C < treshold then // Check Marketposition to avoid the same bar exit and re-entry
Buy this bar at close; // In real trading the "Buy at this bar close" order will be converted to the "Buy at next bar open" order
if C > H[1] then
Sell this bar at close; // In real trading the "Buy at this bar close" order will be converted to the "Buy at next bar open" order
