Search code examples
pine-scriptpine-script-v5

i am looking to implement a strategy with MTF supertrend cross over


I want to implement a strategy that works on cross over of multiple time frame supertrend. my chart is on 15 min time frame, but want to look at one of the entry condition as the cross over on 5 minute supertrend.

ta,supertrend takes only 2 parameters (factor and atr period)

is there any work around this to include the timeframe? or is it necessary that i create a seperate function for LTF_supertrend with lower timeframe ?

pls help and advice


Solution

  • You need to use the security() function for that. If you want to access data from lower timeframes, you should use the request.security_lower_tf() function.

    request.security_lower_tf(symbol, timeframe, expression, ignore_invalid_symbol, currency, ignore_invalid_timeframe) → array<type>
    

    However, analysing that array might be complicated. I would suggest, you set your timeframe to 5min, and then request data from the 15min chart by using the request.security() function.

    request.security(symbol, timeframe, expression, gaps, lookahead, ignore_resolve_errors, currency) → series <type>