Does anyone have a script on how to backtest Daily gap fill using PrevDayClose price and Daily open?
ex. Sell if DailyOpen is greater than PrevDayclose and buy to close if price touches PrevDayClose?
Heres what I got...
(Dailyopenbelow)
input aggregationPeriod = AggregationPeriod.DAY;
input showOnlyLastPeriod = yes;
def prevPrice = open(period = aggregationPeriod)[-1];
def price = open(period = aggregationPeriod);
plot DailyOpen = if showOnlyLastPeriod and !IsNaN(prevPrice) then Double.NaN else price;
DailyOpen.SetDefaultColor(GetColor(2));
DailyOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
(prevdayclose)
plot Data = close;
input aggregationPeriod2 = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input showOnlyLastPeriod2 = no;
plot PrevDayClose;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
PrevDayClose = Double.NaN;
} else {
PrevDayClose = Highest(close(period = aggregationPeriod)[-displace], length);
}
PrevDayClose.SetDefaultColor(GetColor(9));
PrevDayClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
addOrder(orderType.SELL_TO_OPEN, DailyOpen > PrevDayClose);
addOrder(orderType.BUY_TO_CLOSE, price = prevdayclose);
PROBLEM, (No default value for parameter 'condition' on addorder) ???? thinkscript refering to buy to close order
ex. Sell if DailyOpen is greater than PrevDayclose and buy to close if price touches PrevDayClose?
Heres what I got...
(Dailyopenbelow)
input aggregationPeriod = AggregationPeriod.DAY;
input showOnlyLastPeriod = yes;
def prevPrice = open(period = aggregationPeriod)[-1];
def price = open(period = aggregationPeriod);
plot DailyOpen = if showOnlyLastPeriod and !IsNaN(prevPrice) then Double.NaN else price;
DailyOpen.SetDefaultColor(GetColor(2));
DailyOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
(prevdayclose)
plot Data = close;
input aggregationPeriod2 = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input showOnlyLastPeriod2 = no;
plot PrevDayClose;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
PrevDayClose = Double.NaN;
} else {
PrevDayClose = Highest(close(period = aggregationPeriod)[-displace], length);
}
PrevDayClose.SetDefaultColor(GetColor(9));
PrevDayClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
addOrder(orderType.SELL_TO_OPEN, DailyOpen > PrevDayClose);
addOrder(orderType.BUY_TO_CLOSE, price = prevdayclose);
PROBLEM, (No default value for parameter 'condition' on addorder) ???? thinkscript refering to buy to close order