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

Implementing Momentum Check in Strategy Builder Without Custom Code

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

    Implementing Momentum Check in Strategy Builder Without Custom Code

    Hello NinjaTrader Community,

    I am working on an RSI-based momentum strategy using the Strategy Builder and have encountered a challenge that I hope you can help me with. The strategy involves a condition where the current price must be higher than the last price recorded when the RSI crossed a specific level. Here's what I intend to achieve:

    - The strategy should enter a long position only if the current price is higher than the price at the last instance when the RSI crossed above a predefined oversold level (e.g., RSI > 32).
    - This condition aims to confirm the market momentum is in favor of the trade.
    - I would like to implement this logic directly in the Strategy Builder interface without delving into custom scripting.

    I appreciate any advice or guidance you can provide.

    Thank you!


    #2
    Hello Hezi100,

    Thanks for your post.

    You could create your RSI indicator cross above condition in the Strategy Builder window to detect if the RSI indicator crosses above 32.

    In the same Set, you could create a condition that checks if the current Close price (Close[0]) (Price folder > Close > Bars ago set to 0) is greater than the previous Close price (Close[1]) (Price folder > Close > Bars ago set to 1).

    This would mean the Set checks to see if the RSI cross above condition is true and checks to see if the bar is an up bar (green).

    See the help guide documentation below for information about creating indicator to value comparison conditions, crossover conditions, and price comparison conditions.

    Conditions: https://ninjatrader.com/support/help...on_builder.htm
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hello and thank you for the prompt response.

      I appreciate the suggestion, however, it seems there may have been a slight misunderstanding of the specific condition I am trying to implement. I am looking to compare the current close price not just with the previous bar's close but with the close price of the specific bar where the RSI last crossed above the defined level of 32. To elaborate:

      1. When the RSI crosses above 32, I want to record the close price at that exact bar.
      2. For future bars, I want to enter a long position only if the current close price is higher than the close price recorded at the time of the last RSI cross above 32.

      This is to ensure that we are seeing a genuine upward momentum confirmed by a new high since the RSI indicated an oversold condition.

      The standard condition of `Close[0] > Close[1]` would only confirm that the current bar is higher than the immediately preceding bar, which doesn't necessarily satisfy the strategy's criteria.

      Is there a way to implement this more specific condition within the Strategy Builder? Or would this require custom scripting beyond the Strategy Builder's capabilities?

      Thank you again for your assistance!

      Comment


        #4
        Hello Hezi100,

        Thanks for your notes.

        You could create a double variable on the Inputs and Vairables screen called something like 'RSICrossClose'.

        In the Conditions and Actions screen of the Strategy Builder you could create a condition that checks if the RSI indicator (Indicators folder > RSI) crosses above the numeric value 32 (Misc folder > Numeric value) and in the actions section, assign the Close price to the 'RSICrossClose' variable (Misc folder > Set RSICrossClose > select RSICrossClose field > Price folder > Close). This will assign the Close price to the variable when the RSI cross above condition occurs.

        Then in a separate Set you could create a condition that checks if the Close price (Price folder > Close > Bars ago set to 0) is greater than the RSICrossClose variable (User variables folder > RSICrossClose) and call your entry order method to place an order.

        See the help guide documentation below for more information.

        Strategy Builder Screens: https://ninjatrader.com/support/help...er_screens.htm
        Conditions: https://ninjatrader.com/support/help...on_builder.htm
        Actions: https://ninjatrader.com/support/help...t8/actions.htm
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Hello again, and thank you for the continued support.

          I've followed the instructions to create a double variable named 'RSICrossClose' to store the closing price when the RSI crosses above 32. Your guidance on setting the conditions and actions in the Strategy Builder was very clear, and I've set up the initial RSI cross condition as suggested.

          However, I think there might be a misunderstanding regarding the specific entry condition I am looking to implement. I would like to clarify the following points:
          1. Historical Price Comparison: The strategy should not just enter a long position when the RSI crosses above 32. It should only do so if the current close price, at the moment of the RSI crossing above 32, is higher than the close price from the previous instance of the RSI crossing above 32.
          2. Storing the Previous RSI Cross Price: The 'RSICrossClose' variable successfully captures the close price at the time of the RSI crossing above 32. However, for the next RSI cross, I need to compare the current close price with the 'RSICrossClose' value from the previous RSI cross. In other words, I need to hold onto the 'RSICrossClose' value across two different RSI crosses to compare the two prices.

          To reiterate, the entry logic should be:
          • Detect the RSI crossing above 32 and store the close price at that bar in 'RSICrossClose'.
          • Wait for the next RSI cross above 32.
          • At this new cross, check if the current close price is greater than the 'RSICrossClose' stored from the last cross.
          • If the condition is true (indicating higher highs and thus positive momentum), then initiate a long entry.

          Could you please advise on how to modify the existing conditions or suggest a new setup to achieve this through the Strategy Builder? Is there a feature within the Builder that allows for this sort of historical price tracking and comparison?

          Thank you once again for your assistance!

          Best regards, Hezi

          Comment


            #6
            Hello Hezi100,

            Thanks for your notes.

            This would require unlocking the strategy from the Strategy Builder and manually programming your own custom logic into the script.

            In an unlocked script, you could use a custom Series<double> variable called 'RSICrossClose' to save the Close price of the bar when the RSI crosses above 32. You could consider creating an int variable named something like 'RSICrossoverBar' to save the CurrentBar to the int variable when the RSI crosses above 32.

            The CurrentBar could be subtracted from the int variable (RSICrossoverBar) to get the barsAgo value which would be saved into another int variable named something like 'RSIBarsAgo'. This other variable would be used to pass into the custom Series to get the previous RSICrossClose price to use in a condition.

            Then you could create a condition that checks if the RSI crosses above 32 and checks if the current close price is greater than the previous RSICrossClose price by passing the barsAgo into the custom Series (RSICrossClose[RSIBarsAgo].

            For example, say the first crossover occurs on bar 10. The Close price would be saved to the Series<double> variable and the CurrentBar would be saved to an int variable. Then, you would subtract CurrentBar from the int variable 'RSICrossoverBar' to get the barsAgo value and save that value to an int variable called something like 'RSIBarsAgo'. Then in your other condition, you would check for the RSI crossover condition and check if the Close price is greater than RSICrossClose[RSIBarsAgo] (the previous RSI Crossover Close price) and place your entry order.

            See the help guide documentation below for more information.

            Series<T>: https://ninjatrader.com/support/help...t8/seriest.htm
            CurrentBar: https://ninjatrader.com/support/help...currentbar.htm

            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by llanqui, Today, 03:53 AM
            0 responses
            6 views
            0 likes
            Last Post llanqui
            by llanqui
             
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            10 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            15 views
            0 likes
            Last Post AaronKoRn  
            Started by carnitron, Yesterday, 08:42 PM
            0 responses
            11 views
            0 likes
            Last Post carnitron  
            Started by strategist007, Yesterday, 07:51 PM
            0 responses
            14 views
            0 likes
            Last Post strategist007  
            Working...
            X