For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
strategy logging with trailing stop losses
-
I'm new to backtrader and trying to create a strategy that also uses trailing stop losses.
Is there any way to log when a position is closed due to a planned strategy vs a trailing stop loss?
-
No one has any ideas?
-
You could track you stop loss orders in a list/dictionary, and in notify_order when an order executes you could check the list, if it's in there you print or save in an analyzer.
-
In
notify_order
, you can check iforder.exectype
is5=StopTrail
as opposed to whatever exectype your regular close is. -
thats great! thanks