Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter only once per indicator swing line

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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 you
    Attached Files

    #2
    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.

    Comment


      #3
      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


        #4
        Here is an image
        Attached Files

        Comment


          #5
          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


            #6
            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


              #7
              I suppose the swing indicator draws the swing highs/lows based on a numerical value that we can put in. But even when that is changed i notice some still seem to take trades way after a swing line has been already used.

              Comment


                #8
                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
                54 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                130 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                72 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                44 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                49 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X