Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry condition based on previous bars

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

    Entry condition based on previous bars

    The condition to enter is simple:

    Long condition:
    If RSI crosses above the oversold line, wait for the RSI to cross above the oversold line a 2nd time as long as the RSI has not crossed above the 50 line while waiting for the 2nd cross.

    I think it would need be set up as..

    RSI crosses above oversold line in past 50 bars (set a Bool to true)
    RSI has not crossed above 50 line in past 50 bars (another bool to true)
    RSI crosses above oversold line

    Rather lost on how to accomplish this and any assistance is very much appreciated!

    #2
    Hello Akotic,

    Add a bool.

    In a condition set select Indicator -> RSI on the left, Crossabove in the center with lookback period set to 50, on the right Numeric Value -> set to 70.

    For the action set the bool to true.

    Add another bool.

    In a condition set select Indicator -> RSI on the left, Crossabove in the center with lookback period set to 50, on the right Numeric Value -> set to 50.

    For the action set the bool to true.

    Require the bool to be false in the condition to know the cross has not occured.

    In the last condition select Indicator -> RSI on the left, Crossabove in the center with lookback period set to 1, on the right Numeric Value -> set to 70.

    Below is a link to a forum post with helpful resources on getting started with NinjaScript and C#.

    Please watch the 'Automate Your Trading with NinjaTrader's Strategy Builder' training video.
    https://ninjatrader.com/support/foru...pts#post786040

    Also, below is a link to an example that uses bools.
    Hi, To improve a strategy, I would like the condition to enter a trade to be triggered only after a second crossing happens. Meaning, for instance we have a sthocastics crossing, but the strategy would only trigger when a crossing between 2 emas happen. Would the looking back N bars work? Can it be done within the builder
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the answer! Will the bools automatically reset themselves after everything matches and a trade is opened? Or how will that work?

      Comment


        #4
        Hello Akotic,

        The bools would have to be reset with logic. In the example I've chosen to do this when the opposite condition is true in Set 1. You could choose to reset when IsFirstTickOfBar is true, or when First bar of session is true, or when the condition is the reverse.. It depends on when you want to be able to trigger the action again.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        88 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        134 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        119 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        67 views
        0 likes
        Last Post PaulMohn  
        Working...
        X