Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Doubling position size. Help Needed.
Collapse
X
-
Doubling position size. Help Needed.
Can some one please help me figure out how to build a strategy that doubles position size after each lose. I already have a strategy and all I need to do is add another setting to it. Basically I just want to enter a position long and if I on the next trade I exit with a lose then double my position on the next entry and so on. So add a position size logic that always doubles current position (martingale style). Always loser sequence will be as follows; +1 -2 +4 -8 +16 -32 +64 etc.Tags: None
-
Hi relogical,
There's lots of ways you could do this. You'll just need to update an order quantity variable when there's a losing trade. You could work with TradePerformance class to get PnL for the last closed trade. Help for using this class is available in the following reference sample:
This can be simple or complex depending on your experience working with advanced event handlers and IOrder (to check for exit execution and update your variable then).
A simple implementation that works with a conditional exit could look like this:
Code:if (exitConditions) { if (Position.GetProfitLoss(Close[0], PerformanceUnit.Points) < 0) //Gets unrealized PnL at time of exit. customQuantity *= 2; ExitLong(); } EnterLong(customQuantity);
Ryan M.NinjaTrader Customer Service
-
if(Performance.AllTrades.Count - 1 > 0 && Position.GetProfitLoss(Close[0], PerformanceUnit.Points)< 2.5 ){
OrderQuantity = Position.Quantity + AddPositionAtReversal ;
}
where you get the current position size from Position.Quantiy and the variable AddPositionAtReversal, then pass the OrderQuantity to EnterLong() or EnterShort()
you can write some code to change the size of the AddPositionAtReversal based on the consolidation condition.
you can go like 1, -2, +3 , -4 , +5 which I found is safer.
if your pocket is deep, you can play aggresive martingale.
Comment
-
I tried searching with no luck. Does anyone know if there is a sample strategy that includes a martingale system? I don't have a lot of experience with coding and I would like to see what a functioning version looks like, so I can try to add it to my strategy. Any help would be greatly appreciated.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by RideMe, 04-07-2024, 04:54 PM
|
7 responses
37 views
0 likes
|
Last Post Today, 03:17 PM | ||
Started by junkone, Today, 02:19 PM
|
2 responses
24 views
1 like
|
Last Post Today, 03:15 PM | ||
Started by strategist007, Yesterday, 07:51 PM
|
1 response
19 views
0 likes
|
Last Post Today, 02:37 PM | ||
Started by AaronKTradingForum, Today, 02:37 PM
|
0 responses
6 views
0 likes
|
Last Post Today, 02:37 PM | ||
Started by DJ888, 04-26-2024, 10:57 PM
|
1 response
12 views
0 likes
|
Last Post Today, 02:35 PM |
Comment