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

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 traderzoso, 12-27-2020, 05:19 PM
        6 responses
        229 views
        0 likes
        Last Post lekor
        by lekor
         
        Started by ETFVoyageur, 05-18-2024, 12:45 AM
        4 responses
        26 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by Skifree, Today, 11:47 AM
        4 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by molecool, Today, 01:48 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by ETFVoyageur, Today, 12:26 PM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X