I'm guessing the answer will be no but thought I'd ask anyway: is there a way to set (or modify) the EnterLongLimit() string name after the actual order has been executed?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
EnterLongLimit()
Collapse
X
-
EnterLongLimit()
The EnterLongLimit() order method allows for a string signalName to be set.
I'm guessing the answer will be no but thought I'd ask anyway: is there a way to set (or modify) the EnterLongLimit() string name after the actual order has been executed?Tags: None
-
Hi Patrick,
Thanks for the reply. I had an idea to get the Order ID from OnExecution and use that value in the signal name (for the entry, stop and profit) as a way of tracking trades.
I wanted to do that because I have a strategy where the same condition set generates multiple open trades and I was having trouble implementing a breakeven strategy using BarsSinceEntry....but I since came up with another solution.
I've actually had so much grief with this that I thought I'd post the solution just in case other users are having the same issue. I kind of thought it would be a common thing but I didn't find a similar issue anywhere and so I had to piece together a solution from several different sources.
So I started by using an integer user variable that incremented if my conditions were met and then passed that count into the signal name like so:
The problem with this approach is the count iterates every time the conditions are met, so if the conditions are met on 2 consecutive bars then at BarsSinceEntry() == 1 the count value will be out of sync by 1 and will no longer reference the initial trade from the first bar. I fixed this with a user defined boolean variable:Code:private int count=0; if (//conditions) { count++; EnterLongLimit("Long"+count); } if (BarsSinceEntry()==1) { //execute code }
Now the code syncs the signal names perfectly. If the conditions were met on the second bar it deducts one from the integer value used to reference the signal name (and if not then it doesn't).Code:if (//conditions) { count++; EnterLongLimit("Long"+count); trigger = true; } else { trigger = false } if (trigger = true) { if (BarsSinceEntry("Long"+(count-1)) == 1) { // execute code } } else if (trigger = false) { if (BarsSinceEntry("Long"+count) == 1) { // execute code } }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
152 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
87 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
131 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
127 views
1 like
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
106 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment