Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Enter only once per indicator swing line
Collapse
X
-
Enter only once per indicator swing line
A strategy I’m trying to develop involves price crossing the swing indicator, and entering after that. The problem arises where it might cross 5 times, and if it hits my stop or target it’ll just keep entering. I’ll get 2-4 losses sometimes instead of just one because of this. Is there a way to have it only enter once per new swing line? Thank youTags: None
-
Hello ehidri89,
Thank you for your note.
There are some handy methods that help to refine your conditions based on things such as the number of bars since an entry, exit, or since a condition evaluated to true. You should be able to add to your entry condition so that it checks for one of these items in order to prevent multiple entries from occurring within a bar or range of bars. Here are the help guide sections for each of the methods mentioned:
BarsSinceEntryExecution() - https://ninjatrader.com/support/help...yexecution.htm
BarsSinceExitExecution() - https://ninjatrader.com/support/help...texecution.htm
Most Recent Occurrence - https://ninjatrader.com/support/help...urence_mro.htm
Please let us know if we may be of further assistance.
-
Thank you for your response. I added the barssinceexitexecution and that did help.
Another question while were on the topic is how do get the swing indicator lines to not stay on the charts as long?
They seem to hang around and then trades are being taken from lines way in the past.
Comment
-
Hello ehidri89,
Thank you for your reply.
I don't think I fully understand what you are requesting. Is there a part of your logic that could be resulting in trades taken based on past lines? Removing the lines from a chart visually should have no effect on how the trades are calculated. I recommend adding Print() statements to your script to better understand the behavior of your strategy. This could offer more information about what is causing unexpected trades to be taken and then you could adjust your logic to prevent those unexpected trades from happening. For more information about using prints to debug your scripts:
Feel free to reach out with any additional questions or concerns.
Comment
-
As the image above shows, I am having the strategy buy as price crosses above swing lows and sell as price crosses below swing highs. Some of those swing lines from the Swing indicator seem to stay on longer than others and therefore trades are being taken that shouldn't be as it is still using that swing line from way back. Is there a way for the prior swing lines to make them not show anymore after a certain amount of time has passed or after so many trades?
Comment
-
Hello ehidri89,
Thank you for your reply.
I appreciate the image, although that does not demonstrate your strategy's logic and why it is potentially taking trades for the same entry conditions more than once. What is the condition for your entry MyEntry? What are the results in the NinjaScript Output window after adding Print() statements to your script? If you are able to provide an example where the entry condition is being met twice or where trades are being taken based on the same swing line, that will help us to understand how/why the strategy is using that entry condition twice. Then we can figure out a way to adjust the logic in order to prevent that from happening.
I look forward to your reply.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
56 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
133 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
73 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment