0
indicator("India VIX Modified",overlay=true)
A=ta.lowest(low,15)
B=low
C=close>open
D=B==A
Sell=C and D
E=ta.highest(high,15)
F=high
G=close<open
H=F==E
Buy=G and H
plotshape(Sell,"sell",style=shape.arrowdown,color=color.red)
plotshape(Buy,"Buy",style = shape.arrowup,color=color.green)

Hello All,

I want the above code for one security only so that when I overlay it on any chart / symbol, it picks result only of the security defined in the code. How do I use request.symbol function here?

Thanks

Avi Singh
  • 5
  • 6

1 Answers1

0

You can add all the logic to a function, and run this function as the expression you want from the request.security() function.

Keep in mind that in your case, you're looking to get back a tuple, so you'll need to add a tuple as the return values of the function:

//@version=5
indicator("India VIX Modified",overlay=true)

buySellTriggers() => 
    A=ta.lowest(low,15)
    B=low
    C=close>open
    D=B==A
    Sell=C and D
    E=ta.highest(high,15)
    F=high
    G=close<open
    H=F==E
    Buy=G and H
    [Sell, Buy]

[sell, buy] = request.security(syminfo.tickerid, "30", buySellTriggers())

plotshape(sell,"sell",style=shape.arrowdown,color=color.red)
plotshape(buy,"Buy",style = shape.arrowup,color=color.green)
mr_statler
  • 1,913
  • 2
  • 3
  • 14
  • Thank you for prompt reply. I don't know what tuple is and google was not of great help. I have used request.symbol on every condition / line and it has worked for me. Had to break C and F. Will find out more about Tuple. Thank you. – Avi Singh Nov 24 '22 at 03:14