In the meantime, I have been playing with the idea of printing the metrics that I need under the Tag field of the Positions Scorecard.
However, it's not easy to sort or work with (this because I printed both the MAE and MFE together). Is there a way to programmatically add more user-defined fields to the Positions Scorecard?
However, it's not easy to sort or work with (this because I printed both the MAE and MFE together). Is there a way to programmatically add more user-defined fields to the Positions Scorecard?
Rename
No, adding custom fields to the Positions tab is not supported.
Thanks Eugene!
I was hoping this would be possible somehow. Do you see any other workaround for the issue that I raised in the topic from where this thread was taken out?
I suppose it’s possible to create another Scorecard mimicking the Positions one, but with the values that I am looking for - but that is out of my competence at the moment (no WPF knowledge); so I am thinking of then creating a class to print all Positions (and metrics) to a CSV file and then manipulating it in Excel to try to arrive at the perfect stop/profit targets (a bit cumbersome but should work).
I was hoping this would be possible somehow. Do you see any other workaround for the issue that I raised in the topic from where this thread was taken out?
I suppose it’s possible to create another Scorecard mimicking the Positions one, but with the values that I am looking for - but that is out of my competence at the moment (no WPF knowledge); so I am thinking of then creating a class to print all Positions (and metrics) to a CSV file and then manipulating it in Excel to try to arrive at the perfect stop/profit targets (a bit cumbersome but should work).
Please count me out on suggestions for workarounds because the topic isn't my turf. I see there's a feature request that should solve the main problem once it's accepted and ready.
As for printing out all Positions and metrics e.g. to CSV, it's easily possible. You might want to take a look at the approach suggested in Post #3 below:
https://www.wealth-lab.com/Discussion/Is-there-a-way-to-save-or-export-backtest-results-8686
Hope this helps.
As for printing out all Positions and metrics e.g. to CSV, it's easily possible. You might want to take a look at the approach suggested in Post #3 below:
https://www.wealth-lab.com/Discussion/Is-there-a-way-to-save-or-export-backtest-results-8686
Hope this helps.
I did not read it completly. Maybe the API has everything you need. You can check it out. https://www.wealth-lab.com/Support/ExtensionApi/ScoreCard
Although the ScoreCard API allows to build a complete solution, it implies some learning curve to master the free IDE (Visual Studio Code or Community). On the other hand, with the StrategyRunner approach it isn't necessary.
Thank you both. It’s unlikely that the feature request will make it to the top of the list, so I’m going to study what you posted and see if I can come up with something on my own.
No matter how many different instruments I trade, I keep coming back to futures (it’s with future contracts that I am most successful and their nature definitely fit better with my trading style). And so far I couldn’t adapt to work with the way the % metrics are calculated for the futures positions since WL7/8; so I have to upgrade my knowledge of C# and make it happen somehow.
Thank you again!
No matter how many different instruments I trade, I keep coming back to futures (it’s with future contracts that I am most successful and their nature definitely fit better with my trading style). And so far I couldn’t adapt to work with the way the % metrics are calculated for the futures positions since WL7/8; so I have to upgrade my knowledge of C# and make it happen somehow.
Thank you again!
Looks like you want more performance metrics.
Did you consider Formula Scorecard from the finantic.ScoreCards extension?
There it is possible to create new metrics.
It is way simpler than writing your own ScoreCard.
Did you consider Formula Scorecard from the finantic.ScoreCards extension?
There it is possible to create new metrics.
It is way simpler than writing your own ScoreCard.
I'm under impression that topic starter wants to beef up the Positions tab, that's why I didn't suggest the Formula Scorecard.
DrKoch: I'm familiar with the finantic.ScoreCard extension. You did a great job and there is a lot that can be done with it. I am a happy customer of it - it was money well spent!
However, Eugene is right, I was looking to have metrics added to the Positions visualizer. Actually, not so much to add, but to display some of the current ones differently. This derived from another discussion about how the percentage metrics (MFE %, MAE %, Profit %) are calculated for each position, in Futures mode - at present, they are calculated taking into account the effect of leverage based on the value set for the contract's margin in Markets and Symbols. As it is, they are of now use to me; and so I was looking into an alternative way to have the "raw" values calculated; since I then use this to do my analysis of where to place (if at all) Stops and Profit Targets.
However, Eugene is right, I was looking to have metrics added to the Positions visualizer. Actually, not so much to add, but to display some of the current ones differently. This derived from another discussion about how the percentage metrics (MFE %, MAE %, Profit %) are calculated for each position, in Futures mode - at present, they are calculated taking into account the effect of leverage based on the value set for the contract's margin in Markets and Symbols. As it is, they are of now use to me; and so I was looking into an alternative way to have the "raw" values calculated; since I then use this to do my analysis of where to place (if at all) Stops and Profit Targets.
@alkimist: Could you please produce a screen dump with some editing to show where exactly you want to see which values and probably an explanation how these values should be calculated.
(Let's stop guessing)
(Let's stop guessing)
Sure, just for reference, this was the original topic:
https://www.wealth-lab.com/Discussion/Percentage-calculations-for-futures-trading-7514
As you can see, from the attached screenshot (obtained from running the "Knife Juggler" on the ES futures conttract, the values of:
- Profit %;
- MFE %; and
- MAE %
Look exaggerated. This is because in it current form, they are calculated taking into account the leverage, based on the margin set for the Futures contract.
Then, this is propagated in other places too. For example, if under "Position Metrics", I would try to use the Preset "Perfect Stop Loss" (a neat feature for stocks), I actually arrive at absurd values.
https://www.wealth-lab.com/Discussion/Percentage-calculations-for-futures-trading-7514
As you can see, from the attached screenshot (obtained from running the "Knife Juggler" on the ES futures conttract, the values of:
- Profit %;
- MFE %; and
- MAE %
Look exaggerated. This is because in it current form, they are calculated taking into account the leverage, based on the margin set for the Futures contract.
Then, this is propagated in other places too. For example, if under "Position Metrics", I would try to use the Preset "Perfect Stop Loss" (a neat feature for stocks), I actually arrive at absurd values.
Ok, I see. Solution:
Use the Tag column. This can hold arbitrary strings or objects or sets of values.
I'd suggest you calculate a list of values separated by semicolons and set the Tag field of a position to this string.
Use the Tag column. This can hold arbitrary strings or objects or sets of values.
I'd suggest you calculate a list of values separated by semicolons and set the Tag field of a position to this string.
Indeed: this is what I did yesterday - printing to the Tag column a string with (Profit%; MAE%; MFE%); but then quickly run into limitations while trying to sort it to do the analysis. And hence this new thread, enquiring if it was presently possible to add more columns programmatically (Eugene already confirmed that it is not).
I’d support the request, it would be useful to see user defined columns in the Positions visualizer. Maybe in conjunction with the already defined Position Metrics?
I turned this into a #FeatureRequest.
I turned this into a #FeatureRequest.
Great. Thank you!
I'm late to the party.
If you want to avoid the Visual Studio IDE, then you can simply insert your calculation code in the BacktestComplete{block} of your strategy. I think you can get access to the Backtester.Positions there. Within the BacktestComplete{block}, I would cycle through (via foreach) all the Positions and write each Position result out as a tab delimited row to the Windows Clipboard (via StringWriter WriteLine(...) method). From there, you can paste the Clipboard into Excel.
You'll need a "using" statement to include Windows.Forms in your strategy because the Clipboard classes are in there. You'll need a BacktestComplete{block} for each strategy that wants this Positions workup, which is the main disadvantage of this approach (avoiding a Visual Studio generated DLL).
QUOTE:
Although the ScoreCard API allows [one] to build a complete solution, it implies some learning curve to master the free IDE (Visual Studio Code or Community).
If you want to avoid the Visual Studio IDE, then you can simply insert your calculation code in the BacktestComplete{block} of your strategy. I think you can get access to the Backtester.Positions there. Within the BacktestComplete{block}, I would cycle through (via foreach) all the Positions and write each Position result out as a tab delimited row to the Windows Clipboard (via StringWriter WriteLine(...) method). From there, you can paste the Clipboard into Excel.
You'll need a "using" statement to include Windows.Forms in your strategy because the Clipboard classes are in there. You'll need a BacktestComplete{block} for each strategy that wants this Positions workup, which is the main disadvantage of this approach (avoiding a Visual Studio generated DLL).
I'm working on this one now for Build 86. We'll introduce a new base class, PositionScoreCard.
Completed! You can now select which Position Metrics to appear in the Positions Visualizer with the new Preference tab. And, you can add new Position Metrics via the new Position ScoreCard Extension API!
https://www.wealth-lab.com/Support/ExtensionApi/PositionScoreCard
https://www.wealth-lab.com/Support/ExtensionApi/PositionScoreCard
I'm doing something like this now, but with the PlaceTrade Transaction operation assigning a value to the Position Tag like so
It's not clear to me if PositionScoreCard is called as each Position is close (on the fly) or as a batch operation once the backtest is over.
I think the Tag approach (above) is better when the metrics are associated with one particular strategy; whereas, the PositionScoreCard approach is best when it applies to many different strategies. And that's because what users place (like the PositionScoreCard class) in their local DLL libraries isn't going to change much over different strategies.
CODE:This action lets the above "pre-Position" attributes be assigned to the Position object and lists them in the Tag column of the Positions tabulation. But it looks like the PositionScoreCard provides an alternative approach without using the Tag property. The big advantage of the PositionScoreCard is that it can perform routine calculations for each Position that would otherwise have to be included in the Execute{block}.
//buy conditions below if (attribs.opportunityBar <= idx && bbUVelocity[idx] > bbUVelocityThres.AsDouble) //if (attribs.opportunityBar <= idx && acEmaOvrAtr[idx] > emaAtrThres.AsDouble) PlaceTrade(bars, TransactionType.Buy, OrderType.Stop, bars.Close[attribs.peak2Bar], "123pattn stop Buy") .Tag = string.Format("{0:N1} {1:N2}", attribs.atrMerit, attribs.zigZagMerit);
It's not clear to me if PositionScoreCard is called as each Position is close (on the fly) or as a batch operation once the backtest is over.
I think the Tag approach (above) is better when the metrics are associated with one particular strategy; whereas, the PositionScoreCard approach is best when it applies to many different strategies. And that's because what users place (like the PositionScoreCard class) in their local DLL libraries isn't going to change much over different strategies.
Thank you for this implementation!
Looks great. And perhaps Dr.Koch will eventually leverage this new Position ScoreCard Extension API and extend his finantic.ScoreCard extension to cover Scriptable Position Metrics in addition to Performance Metrics.
Looks great. And perhaps Dr.Koch will eventually leverage this new Position ScoreCard Extension API and extend his finantic.ScoreCard extension to cover Scriptable Position Metrics in addition to Performance Metrics.
QUOTE:
Dr.Koch will eventually leverage this new Position ScoreCard Extension API and extend his finantic.ScoreCard extension
Well, I already had the same idea. I just need to find some time to do this. Too many ideas, not enough time....
Great! Looking forward to it (in case you do manage to squeeze it in between your many projects).
Thank you!
Thank you!
Ready in Build 87!
You're a Build late, Cone!
Oops, I just watched the Build 87 release video that covered it.
Let the record show that Position Metrics were already available in Build 86 4 days ago!,
Let the record show that Position Metrics were already available in Build 86 4 days ago!,
Your Response
Post
Edit Post
Login is required