Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Take long trade on green bar after every red bar pull back

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

    Take long trade on green bar after every red bar pull back

    I am making a strategy where I want to take a long position when a green candle closes above the sma 9 while hma 30 is rising and vice versa for shorts. I have all that figured out and entered into the strategy builder. I need some help on getting the strategy to take a long position when the rules happen each time after a 2 or 3 red candle pullback. I used the SavedBar int but that doesnt seem to work. I have attached a picture of what I am trying to do.
    Attached Files

    #2
    Hello Barrett,

    Thanks for your post.

    I would suggest using a bool to control when you are allowed to enter a long or short trade, and to change EntriesPerDirection and EntryHandling in the Default Properties page of the Strategy Builder to allow entering multiple times in the same direction.

    The bool can start as true, and be set to false when your entry order is submitted. The bool can be reset back to true when you see a pullback, or when the Strategy Position is flat.

    Please see the conditions and actions examples below to see how you can make position checks.

    Conditions - https://ninjatrader.com/support/help...on_builder.htm

    Actions - https://ninjatrader.com/support/help...t8/actions.htm

    As an example, your pullback conditions can be modelled by looking at the last 3 bars to see if 2 bars ago is green (Close[2] > Open[2]), if 1 bar ago is green (Close[1] > Open[1]), and if the current bar is red (Close[0] < Open[0])

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      I understand this but there will be a problem when its 2 green bars right after the red bar before the signal bar. Im not sure how to get past that. Also is there a way I could have the HMA be either rising or flat and falling or flat?

      Comment


        #4
        Hello Barrett,

        The specific entry conditions may need additional logic so they are taken (as an example) if the strategy is already in a position, or if the strategy is flat. Additional checks on other bar price levels can be used to further narrow your entry conditions. The Conditions examples can share how to make position checks if you would like to use that criteria with your entry signals.

        You could consider using the Slope which can be used with an indicator as input to see if the indicator plot is rising or falling. You could also consider using IsRising and IsFalling. Slope, Rising and Falling can be found under Misc in Conditions.

        When building new conditions, it can help to make an action that prints the value you want to use so you can see how you may model your logic.
        JimNinjaTrader Customer Service

        Comment


          #5
          I feel like i am pretty good with builder but Im not sure what you are saying.

          Comment


            #6
            Hello Barrett,

            I understand this but there will be a problem when its 2 green bars right after the red bar before the signal bar. Im not sure how to get past that.
            This would require coming up with logic to differentiate between regular entries, and re-entries, or more simply: "Any action to enter, we control by logic, and if those conditions conflict with other conditions, we will need to think of a way to differentiate these separate cases with stricter logic." The changes involved may be more complicated, but for the idea of separating entries from re-entries, you can consider creating different sets of logic that check: if the strategy is flat: Enter, and: if the strategy is Long: submit our second long entry.

            An example for checking the strategy position can be found here - https://ninjatrader.com/support/help...ionComparisons

            Also is there a way I could have the HMA be either rising or flat and falling or flat?
            I had suggested using Slope or using Rising and Falling to identify if an indicator plot value is rising falling or flat. If the plot is neither Rising or Falling it would be flat.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by RookieTrader, Today, 09:37 AM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by kulwinder73, Today, 10:31 AM
            0 responses
            5 views
            0 likes
            Last Post kulwinder73  
            Started by terofs, Yesterday, 04:18 PM
            1 response
            23 views
            0 likes
            Last Post terofs
            by terofs
             
            Started by CommonWhale, Today, 09:55 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by Gerik, Today, 09:40 AM
            2 responses
            7 views
            0 likes
            Last Post Gerik
            by Gerik
             
            Working...
            X