The trade performance summary is showing an ulcer of 0.01, but calculated by hand using the equation I'm getting 3775.
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Understanding Ulcer Index
Collapse
X
-
Understanding Ulcer Index
I'm trying to calculate Ulcer Index by hand using the equations provided on the Statistics Definition page, but I'm not getting the same values.
The trade performance summary is showing an ulcer of 0.01, but calculated by hand using the equation I'm getting 3775.
Tags: None
-
Hello nnwakaihe,
SQRT(Summation((cumulative currency profit - maximum realized currency profit) ^2 ) / Total # of trades)
May I see the math work you are doing to calculate this by hand?
Jim has a similar script demonstrating calculating the R2.
Chelsea B.NinjaTrader Customer Service
Comment
-
Chelsea B,
I am doing the math with excel. Maybe I am mixing up what each variable means.
Please correct me if I am wrong:
cumulative currency profit is the cumulative profit after each trade
maximum realized currency profit is the max profit realized throughout a given set of trades.
Comment
-
Hello nnwakaihe,
This is Jim responding on behalf of Chelsea who is out of the office at this time.
Cumulative Currency Profit is the cumulative profit in currency after each trade, yes.
Maximum Realized Currency Profit is the maximum profit in currency seen from all trades.
Summary Display in the Strategy Analyzer shows this value as a percentage (as that is how it is most meaningful,) regardless if you have Currency, Pips, Ticks, Points, selected in the Strategy Analyzer's Display Selector. If you want to view an overall result for Currency, Pips, Ticks, Points, you may view the Analysis Display, and select a Period of Yearly, and then add Ulcer to the grid by right clicking and selecting Properties. (This assumes the backtest was less than 1 year in length.)
Cumulative Percent Profit can be calculated as: (1.0 + [Cumulative Percent Profit]) * (1.0 + [Profit as Percent from trade]) - 1;
Maximum Realized Percent Profit can be calculated as the maximum [Cumulative Percent Profit]] of all trades.
This detail should help to follow the Statistics Definitions formula from the Help Guide to get the same result the Strategy Analyzer displays.
JimNinjaTrader Customer Service
Comment
-
Hello nnwakaihe,
I don't want you to think I'm ignoring you. I'm just doing the math on each trade in a trade collection for the SampleMACrossover and it's busy work that takes some time. I'm also having to be mindful of response time with other inquiries.
i.e. i'm at the third trade out of 14.
(1.0 + [Cumulative Percent Profit]) * (1.0 + [Profit as Percent from trade]) - 1
Trade number Market pos. Qty Entry price Exit price Entry time Exit time Entry name Exit name Profit Cum. net profit
1 Short 1 14633.25 14659.50 10/11/2021 9:00:00 PM 10/12/2021 12:00:00 PM Sell short Close position -0.18% -0.18%
(1.0 + 0) * (1.0 + -.0018) - 1
1 * .9982 - 1
cumProfitPercent: -0.0018
topPercent: -0.0018
( (1 + -0.0018) / (1 + -0.0018) - 1) ^ 2
( 0.9982 / 0.9982 - 1) ^ 2
performancePercentUlcer: 0
(0 / 1) ^ 1/2 (sqr root)
0
Trade number Market pos. Qty Entry price Exit price Entry time Exit time Entry name Exit name Profit Cum. net profit
2 Long 1 14659.50 14597.25 10/12/2021 12:00:00 PM 10/12/2021 3:00:00 PM Buy Exit on session close -0.42% -0.60%
(1.0 + -0.0018) * (1.0 + -.0042) - 1
.9982 * .9958 - 1
cumProfitPercent: -0.00599244
topPercent: -0.0018
( (1 + -0.00599244) / (1 + -0.0018) - 1) ^ 2
( 0.99400756 / 0.9982 - 1) ^ 2
performancePercentUlcer: 0.99161764
(0.99161764 / 1) ^ 1/2 (sqr root)
0.9958
Trade number Market pos. Qty Entry price Exit price Entry time Exit time Entry name Exit name Profit Cum. net profit
3 Short 1 14608.50 14713.00 10/12/2021 6:00:00 PM 10/13/2021 7:00:00 AM Sell short Close position -0.72% -1.31%
(1.0 + -0.00599244) * (1.0 + -.0072) - 1
0.99400756 * 0.9928 - 1
cumProfitPercent: -0.010167271752
topPercent: -0.0018
( (1 + -0.010167271752) / (1 + -0.0018) - 1) ^ 2
( 0.989832728248 / 0.9982 - 1) ^ 2
performancePercentUlcer: 0.0000702639591696
(0.0000702639591696 / 1) ^ 1/2 (sqr root)
0.9958Chelsea B.NinjaTrader Customer Service
Comment
-
Hello nnwakaihe,
Thanks for your patience.
Our lead got some inside help from our development that can provide some output to see these calculations.
Unfortunately, I cannot provide the code to produce this as it is part of the proprietary NinjaTrader core code, but the output does allow you to track the progression of the values.
I can say that the trade profit in percent, needed for these calculations, can be retrieved from the SystemPerformance collection.
SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count-1].ProfitPoints
Attached is the full output saved to a text file.
The key focus is the last trade:
Trades: 12
Cumulative percent profit: -0.0162785218688896 Percent profit from trade: 0.000203685134118827
(1.0 + Cumulative percent profit) * (1.0 + Percent profit from trade) - 1: -0.016078152427681 (new Cumulative percent profit)
Maximum realized percent profit : 0.00210536466201661
(1.0 + Cumulative percent profit) / (1.0 + Maximum realized percent profit) - 1) ^ 2: 0.00179784142525246
SQRT((1.0 + Cumulative percent profit) / (1.0 + Maximum realized percent profit) - 1) ^ 2 / trades): 0.0122401028905413Last edited by NinjaTrader_ChelseaB; 11-03-2021, 11:20 AM.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by warreng86, 11-10-2020, 02:04 PM
|
5 responses
1,356 views
0 likes
|
Last Post Today, 09:26 PM | ||
Started by Perr0Grande, Today, 08:16 PM
|
0 responses
3 views
0 likes
|
Last Post
by Perr0Grande
Today, 08:16 PM
|
||
Started by elderan, Today, 08:03 PM
|
0 responses
5 views
0 likes
|
Last Post
by elderan
Today, 08:03 PM
|
||
Started by algospoke, Today, 06:40 PM
|
0 responses
10 views
0 likes
|
Last Post
by algospoke
Today, 06:40 PM
|
||
Started by maybeimnotrader, Today, 05:46 PM
|
0 responses
12 views
0 likes
|
Last Post Today, 05:46 PM |
Comment