Sorry, Didn't realize that this indicator plots a higher timeframe on a lower aggregation chart.@BenTen
How can i create a strategy and back test with this script, when price cross and close above and below 2nd deviation to go long and short, thanks in advance
# Define strategy def longEnterPrice = if price crosses above LowerBand2 then price else double.nan; def longExitPrice = if close crosses below LowerBand2 or price == VWAP then close else double.nan; AddOrder(OrderType.BUY, longEnterPrice, 100, color.green, "Long Entry"); AddOrder(OrderType.SELL, longExitPrice, 100, color.red, "Long Exit"); # Define short strategy def shortEnterPrice = if price crosses below UpperBand2 then price else double.nan; def shortExitPrice = if price crosses above UpperBand2 or price == VWAP then price else double.nan; AddOrder(OrderType.SELL_SHORT, shortEnterPrice, 100, color.red, "Short Entry"); AddOrder(OrderType.BUY_TO_COVER, shortExitPrice, 100, color.green, "Short Exit");
This is what I came up with so far, Im getting errors
Think about the repainting:
For example, if you have a 30-min overlay on a five-min chart. There is no way of predicting at what price that 30min candle is going to close UNTIL it closes.
When the 30min candle finally closes, only then can it repaint the previous 6 bars with the 30min close price.
Read more:
https://usethinkscript.com/threads/...d.-,Multi-Timeframe,-REPAINTING-type Behavior
The repainting from this indicator prevents us from being able to get any reliable backtesting results.
We don't allow repainting backtesting scripts to be posted to this forum because viewers would be misled by the results.
Last edited: