Example Of An Overnight Strategy (Amibroker And Tradestation Code)
This article was published behind a paywall on Substack.
The code in plain English:
- Calculate the absolute value of the % change from today’s close from yesterday’s close (c2c).
- Calculate a 25 day average of number 1.
- When SPY falls more than two times the number in number 2 from Close to Close (c2c), then go long at the close.
- Exit on next day close.
Amibroker code:
c2c = abs((C-Ref(C,-1)) / Ref(C,-1)) ;
avgc2c=MA(c2c,25) ;
Buy= ( Ref(C,-1) -C ) > (2*averagec2c) ;
buyPrice=Close;
Sell= C>0;
sellPrice=Close ;
Tradestation code:
If (c[1]-c)>2*average(AbsValue(C-C[1]),25)
Then buy this bar at close;
If c>o then sell this bar at close;
