- ago
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?
6
1,150
Solved
25 Replies

Reply

Bookmark

Sort
- ago
#1
No, adding custom fields to the Positions tab is not supported.
0
- ago
#2
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).
0
- ago
#3
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.
0
MIH8
- ago
#4
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
1
- ago
#5
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.
0
- ago
#6
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!
1
- ago
#7
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.
1
- ago
#8
I'm under impression that topic starter wants to beef up the Positions tab, that's why I didn't suggest the Formula Scorecard.
0
- ago
#9
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.
0
- ago
#10
@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)
0
- ago
#11
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.
0
- ago
#12
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.
0
- ago
#13
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).
0
Glitch8
 ( 10.84% )
- ago
#14
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.
0
- ago
#15
Great. Thank you!
0
- ago
#16
I'm late to the party.

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).
0
Glitch8
 ( 10.84% )
- ago
#17
I'm working on this one now for Build 86. We'll introduce a new base class, PositionScoreCard.
0
Glitch8
 ( 10.84% )
- ago
#18
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
2
Best Answer
- ago
#19
I'm doing something like this now, but with the PlaceTrade Transaction operation assigning a value to the Position Tag like so
CODE:
   //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);
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}.

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.
0
- ago
#20
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.
0
- ago
#21
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....
0
- ago
#22
Great! Looking forward to it (in case you do manage to squeeze it in between your many projects).

Thank you!
0
Cone8
 ( 7.84% )
- ago
#23
Ready in Build 87!
0
Glitch8
 ( 10.84% )
- ago
#24
You're a Build late, Cone!
0
Cone8
 ( 7.84% )
- ago
#25
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!,
0

Reply

Bookmark

Sort