Is there any way to save either math.min() or array.min() price? Every time my algo recognizes a candle pattern and a breakdown from math.min() happens the candle after, that's the only time it goes in the bar after the candle pattern for a trade. Is there a way to save the price so that the algo can wait until market price hits it to take a trade if there's no breakdown right after? Or am I just doing this wrong?
Thanks for the help in advance!
//@version=5
strategy("Entry Price", overlay=true)
var float entryprice = na
var lows = array.new_float()
if close[2] > open[2] and close[1] < open[1] and strategy.position_size == 0
entryprice := math.min(low[2], low[1])
array.push(lows, entryprice)
plot(array.min(lows), title='Entry', color=color.new(color.purple, 0), style=plot.style_stepline_diamond)
if close > array.min(lows)
array.push(lows, low)
if close <= array.min(lows)
strategy.entry("Go Short", strategy.short, qty=1, oca_type=strategy.oca.cancel)
The idea is to have the array "lows" have the elements initially with the min price of the last 2 bars and if there's no breakdown, to add the last current price to the array until it hits min price. Unless there's an easier way to do this?