San Francisco
Posts: 1 since Mar 2016
Thanks Given: 0
Thanks Received: 0
|
Hi All,
I want to write a code that allows me to backtest a day trading strategy. To be specific, I am concerned with just the first 4 bars of each trading day using the 10 minute bar (09:30 - 10:00). The issue I have is the code I have will produce meaningful results if I ran the code today for todays trading session but If I ran the code today for yesterdays price action, the code won't produce meaningful results. I think the issue is with the date parameter?
How can I adjust the code such that the code will only look at the price action of the 0930, 0940, 0950, and 10:00
bar for any trading day? Ideally, I'd like to just change the date parameter when I do my backtesting.
Here is my code. Its a simple inside bar setup. I want to be able to back test the code for day trades using the 10 minute bar. Thanks!
Input Bar_1 = 3;
Input Bar_2 = 2;
Input Bar_3 = 1;
Input Bar_4 = 0;
Input Vol = Volume;
Input Price = Close;
Input High_P = High;
Input Low_P = Low;
Input Length = 26;
Input Increase = 50;
Def AVG_Vol = average(Vol, Length);
Def Change_Vol = 100*(Vol[Bar_1] / Avg_Vol - 1);
Def RegularMarketHours = secondsFromTime(930) >= 0 and secondsTillTime(1600)>=0;
Def TradingDay = GETYYYYMMDD() ;
Plot Scan;
Scan =
Price[Bar_4] < High_P[Bar_1]
and Price[Bar_4] > Low_P[Bar_1]
and Price[Bar_3] < High_P[Bar_1]
and Price[Bar_3] > Low_P[Bar_1]
and Price[Bar_2] < High_P[Bar_1]
and Price[Bar_2] > Low_P[Bar_1]
and Change_Vol > Increase
AND RegularMarketHours
AND TradingDay
;
|