feeding sizer with stop loss value
Hi, I have my strategy that predicts an entry point for a trade, after it predicts a stop loss and a take profit to exit the trade, so far so good.
My issue appears on the sizing and leverage part.
My goal is to, when I hit the stop loss I should lose 1% of my bank(can ignore commissions, slippage... , will deal with that later).
I was hoping I could take leverage and sizing to achieve this goal, but I cannot find a way to feed the custom sizer with data from my strategy.
basically, my sizing and leverage are dependent on the stop loss, but I am having an issue sending my stop loss value to the costume sizer.
any suggestions on how to pass my stop loss and take profit values to the sizer?
I have the same issue. My sizing is base on the risk and margin:
size_base_on_risk = 1%*cash / abs(entry_price - stop_price); size_base_on_margin = cash * leverage / entry_price; size = min(size_base_on_risk, size_base_on_margin);
Question is how does sizer receive the stop price, entry price when _getsizing is called? If my entry is through limit order, I can pre-calculate the size. But if in market order, the entry price is determined in the next bar, I cannot pre-calculate the size until the next bar open price is known.