TradingView
Kowasaki
27 de Nov de 2018 06:28

Help Requested - "Time-Slot" Delay for Crossover Strategy 

Bitcoin / DollarBitfinex

Descrição

Hello Tradingview Community,

I've been playing around with some various volume-based indicators, and recently have been experiencing a delay in the entries for my strategy for 2 minutes in this scenario. If the time is adjusted, it also is delayed 2 bars.

In this example, the "Short" position should enter when the blue line Crosses under the upper green line, and visa vera for the "Long" position. A simplified Pine Script is available below as well.

I have Googled this issue and attempted to modify the code with => criteria instead, but too no avail. Would appreciate any help or anyone who could point me in the right direction on this Time Delay Issue. Thanks!
Comentários
AKR_79
You could use "process_orders_on_close=true" flag in the defaults right at the beginning of your strategy script.. example would be:
strategy(shorttitle="My script", title="strategy_new", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.01, process_orders_on_close=true)
HD1184K
I'm trying to do the same thing. have you figured it out yet?
Mtrl_Scientist
"enterShort = crossunder(nv, MAV1)"
There is your problem.
TV is doing everything as it should. It waits for the blue line to cross under the green line, and upon close, it opens your short position at the open of the next candle.

If you want to bring that delay down to 1 candle, use either crossover() or cross().
However, if you really want to keep crossunder(), you can also use the calculateoneverytick option, which will not work in back testing, but will not wait for candle close in real-time, bringing the 2 bar delay down to 1. The problem with that is, that the signal might revert before candle close and you're stuck in a trade you didn't want. TV refers to this issue as 'repainting'.

Hope that helps.
Mais