Where in this code can I implement an initial fixed stop loss of $1500 once a position is entered? This is for Futures. I am also using the Percent Volitily PosSizer.
CODE:
Please log in to see this code.
Size:
Color:
If you're using the % Volatility PosSizer, it won't work together with a fixed dollar stop set in code.
As an alternative, add a percentage- or volatility-based stop using RiskStopLevel. The QuickRef example will show you how to implement it.
Size:
Color:
Can it be done without using RiskStopLevel? for example:
CODE:
Please log in to see this code.
Size:
Color:
What you're trying to do is expressed like the following:
CODE:
Please log in to see this code.
However as I said it won't work because there's no direct access to portfolio equity (and you're working in portfolio simulation mode when using a PosSizer i.e. % Volatility). Check one of the remarks in the QuickRef for MFEAsOfBar where it says:
QUOTE:
In portfolio simulation mode, all trades are pre-executed using 1 share per Position, and then position sizing is applied after the fact. So the MFEAsOfBar property will always be based on 1 share while the Strategy is executing.
Size:
Color:
Ok so basically you are saying this can't be done in Portfolio simulation mode, but I should switch to Raw Profit mode and use the RiskStopLevel in my code to set an initial stop.
Size:
Color:
It can be done in Portfolio simulation mode by using RiskStopLevel.
Size:
Color: