(Average Winning Trade * Winning Percentage) - (Average Losing Trade * Losing Percentage)
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Calculate Positive Expectancy
Collapse
X
-
Calculate Positive Expectancy
How would you use the Performance object to calculate Postive Expectancy?
(Average Winning Trade * Winning Percentage) - (Average Losing Trade * Losing Percentage)Last edited by mgbloomfield; 03-01-2009, 03:15 AM.Tags: None
-
Addition, Substraction and Multiplication do work but Division does not work for me. Why?
private int intWinningTrades = 4;
private int intAllTrades = 10;
private float fltWinningPercent = 0;
protected override void Initialize()
{
....
ClearOutputWindow();
fltWinningPercent = intWinningTrades / intAllTrades; // fltWinningPercent should be 0.40, not 0
CalculateOnBarClose = true;
....
}
protected override void OnBarUpdate()
{
Print ("fltWinningPercent: " + fltWinningPercent.ToString()); // Look at Output window for result
}
In the output window, I get 0, instead of 0.40
-
Thanks, that was a "duh" moment for me.Originally posted by Anagoge View PostC# is doing an integer division because both variables on the right hand side are integers. You can cast the int to a float like this to force a floating point division:
fltWinningPercent = (double) intWinningTrades / intAllTrades;
It works now.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
59 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
143 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
161 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
||
|
Started by CarlTrading, 05-10-2026, 08:12 PM
|
0 responses
97 views
0 likes
|
Last Post
by CarlTrading
05-10-2026, 08:12 PM
|
||
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
276 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|

Comment