I'm trying to put together a pine script for tradingview and I'm almost done with it, but i'm not sure how I can get it to close the trade at either the end of the day (11:59PM) OR when the current price is equal to the previous day candle high (high[1] + X pips on day candles).
Here's what I have so far:
//@version=2
strategy("Previous Day High and Low Breakout Strategy", overlay=true)
D_High = security(tickerid, 'D', high[1])
D_Low = security(tickerid, 'D', low[1])
D_Close = security(tickerid, 'D', close[1])
D_Open = security(tickerid, 'D', open[1])
// Go Long - if prev day high is broken and stop loss prev day low
// Go Short - if prev day low is broken and stop loss prev day high
plot(isintraday ? D_High : na, title="Daily High",style=line, color=blue,linewidth=2)
plot(isintraday ? D_Low : na, title="Daily Low",style=line, color=red,linewidth=2)
signal =crossover(high,D_High) ? true : crossover(D_Low,low) ? false : signal[1]
longCondition = signal
if (longCondition)
strategy.entry("Long", strategy.long)
shortCondition = signal != true
if (shortCondition)
strategy.entry("Short", strategy.short)