Logging a variable

Questions about MultiCharts and user contributed studies.
User avatar
johnsel
Posts: 7
Joined: 11 Aug 2011
Has thanked: 8 times

Logging a variable

Postby johnsel » 29 May 2012

I would like to add a variable to the Strategy Performance Report list of trades. It shows me the trade details, but I want to log the initial value of my stop loss as well.

I have a variable in my code called iStop. Is there any way to add iStop to the Strategy Performance Report such that it is logged in the trade list somewhere?

I've been trying to write my own log file using FileAppend but I have trouble with that because it logs for each bar and I only want the log written when I am filled. Is there any way to trigger code to run only when a trade is opened? It seems like I could do it retroactively if the trade was opened on the previous bar using something like BarsSinceEntry[1], but that is tricky because if I have an entry right after an exit I need to handle it.

Any suggestions would be very much appreciated.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Logging a variable

Postby Henry MultiСharts » 29 May 2012

I would like to add a variable to the Strategy Performance Report list of trades. It shows me the trade details, but I want to log the initial value of my stop loss as well.

I have a variable in my code called iStop. Is there any way to add iStop to the Strategy Performance Report such that it is logged in the trade list somewhere?
Unfortunately that is not possible.
I've been trying to write my own log file using FileAppend but I have trouble with that because it logs for each bar and I only want the log written when I am filled. Is there any way to trigger code to run only when a trade is opened? It seems like I could do it retroactively if the trade was opened on the previous bar using something like BarsSinceEntry[1], but that is tricky because if I have an entry right after an exit I need to handle it.
Any suggestions would be very much appreciated.
You need to write out only when the condition is met. The simplest condition is market position check. Another suggestion is PosTradeIsOpen word.

User avatar
johnsel
Posts: 7
Joined: 11 Aug 2011
Has thanked: 8 times

Re: Logging a variable

Postby johnsel » 29 May 2012

Thanks. I will try PosTradeIsOpen.


Return to “MultiCharts”