strategy("Impulsive Candle" , shorttitle="Big Candle", overlay = true , initial_capital = 100000)
I have made a variable which is defined as below:
impulsive_candle = (close-open) > 0.00102
I would like to buy when the price returns to the open of the most recent candle that satisfies the impulsive_candle condition defined above. I realise I can use the historical reference operator [] to gather previous candle data. e.g. open[1] gives me the value of the open of the previous candle, but I would like to do this for the most recent impulsive_candle.
I have tried:
buy = impulsive_candle(close[1]) == true
But this doesn't work.
I get this as my error: funRefInfo.typeExpression.dereference is not a function
So I tried making a function of the original variable (while keeping the original variable as is because I use it for plotting later):
impulsive_candle_func => (close-open) > 0.00102
And then writing:
buy = impulsive_candle_func(close[1]) == true
But still it's not working.
Now I get: Script could not be translated from: |B|impulsive_candle_func => (close-open) as my error.
Any advice on how to resolve this would be appreciated.
question from:
https://stackoverflow.com/questions/66068941/how-to-buy-at-the-previous-candle-open-of-a-candle-which-satisfies-my-variable-c 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…