Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Position Sizing During Backtest
Collapse
X
-
Ok, just sent. Thanks so much for your prompt attention. Your support is top notch!
-
Too bad, sure please send it over to support at ninjatrader dot com to my Attn.
Thanks,
Leave a comment:
-
It's not working Bertrand. I forgot to remove the hardcoded number that we put in there... LOL. Can you take a look at this code?
Leave a comment:
-
Since the hardcoded entry is working out fine, the issue is to be found in your code - are you using a public property for positionsize as well here? If you send your script to support we could give it a run here as well.
Leave a comment:
-
Here's the output from the Print() statements of what I just ran. As you can see, the positionSize variable is being populated correctly:
My account size is: 9814.79010000007
My risk amount is: 1.06682501086957
My first position size is: 10668.2501086957
My final position size is: 10668
Leave a comment:
-
If you directly enter your position size needed hard-coded in the EnterLong() for a test - would it then use the qty specified?
Leave a comment:
-
trend747, if you startup the strategy by what are you then defining position size, ByDefaultQuantity or ByStrategy?
Leave a comment:
-
Position Sizing During Backtest
I know it's not officially supported, but I was told that you could use the Performance class to do position sizing for backtests.
Check out this code:
All of those print statements was me testing my code. Basically, the final position size shows the correct position size -- let's say, for example, 11980 units.Code:if (Demo == true && Realtime == false) { //Print("My account size is: " + (Performance.AllTrades.TradesPerformance.Currency.CumProfit + AccountSize)); double myRiskAmount = ((Performance.AllTrades.TradesPerformance.Currency.CumProfit + AccountSize) * (RiskPercentage * .01) / SL); //Print("My risk amount is: " + myRiskAmount); double myPositionSize = (myRiskAmount * 10000); //Print("My test position size is: " + myPositionSize); int PositionSize = (int)myPositionSize; //Print("My final position size is: " + PositionSize); }
Then this is my entry code:
But it still enters whatever is specified in the parameters... I don't understand that... I mean, it's in the code... it should work.Code:if (Close[0] > Close[1]) { EnterLong(PositionSize); }Last edited by trend747; 07-13-2011, 09:29 PM.Tags: None
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CaptainJack, 05-29-2026, 05:09 AM
|
0 responses
310 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 05:09 AM
|
||
|
Started by CaptainJack, 05-29-2026, 12:02 AM
|
0 responses
200 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 12:02 AM
|
||
|
Started by charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
186 views
1 like
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
278 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
229 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|

Leave a comment: