Closed markxbaker closed 2 months ago
Hi @markxbaker,
The stop loss is calculated as the number of points from the entry price of the trade. The stop is never hit with:
stop_loss_calc = (ctx.close[-1] - ATR)
ctx.stop_loss = stop_loss_calc
This should instead be:
ctx.stop_loss = ATR
Ah ok, thank you.
Hey Ed, thanks for updating the slippage, tested and working!
I still can't seem to set a stop loss price based on an ATR distance from the entry or close as below - the prints seem correct but no stop loss is set? I want to size my positions based on the stop distance and so forth to maintain a consistent cash exposure.
if not pos: if sma_short[-1] > sma_long[-1] and ctx.close[-1] >= 1 : ctx.buy_shares = ctx.calc_target_shares(0.01)