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

I want a "Cross" condition to be valid for more than one bar

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

    I want a "Cross" condition to be valid for more than one bar

    Question:

    I have been running my ninja script for the past 7 days. The first condition is a Move. Ave cross, then some RSI, ADX, etc ... conditions.

    My question is if the moving average condition "crosses", but the other
    conditions have NOT been met (yet), how long will the first condition stay
    "True" to allow the additional conditions time to happen and trigger the trade ?

    If the second or third condition takes 5 more minutes, I still want the
    trade to execute. I am wondering is there a maximum length of time the "Cross Over" and "Cross Under" conditions are valid? (I would prefer not to use the ">" and "<" conditions, as the resutls are much less).
    Answer:

    The CrossAbove() and CrossBelow() methods have a signature such as:

    CrossAbove(series1, series2, lookBackPeriod)

    Where "lookBackPeriod" sets the number of bars where the cross must have occured within for the method to return a true value.

    Therefore, if you want to check if the Cross of two MA's occured within the last three bars, you would write:

    if (CrossAbove(SMA(10), SMA(20), 3))
    // Do something
    RayNinjaTrader Customer Service

    #2
    Hello Ray,
    I what to use the CrossAbove of two MA's. One SMA using a 5 period close and the other SMA using a 5 period open. How would I do that based on your example below?

    if (CrossAbove(SMA(10), SMA(20), 3))
    // Do something

    Would it be something like this?:
    if (CrossAbove(SMA(5 close), SMA(5 open), 1))
    // Do something

    Thanks

    Comment


      #3
      if (CrossAbove(SMA(Close,5), SMA(Open,5), 1))
      // Do something

      Should do it.

      Take a look at the strategy tutorial .. http://www.ninjatrader-support.com/H...helpguide.html

      In particular .. step 3. See the box in the diagram called InputSeries - 'Default Input' ?

      YOu can click that, and then refer to any price/indicator you want.. For example, Close, Open, Typical .. or even another indicator.

      Very powerful.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by tradebot, Today, 01:25 PM
      2 responses
      7 views
      0 likes
      Last Post tradebot  
      Started by cmtjoancolmenero, Today, 02:31 PM
      0 responses
      2 views
      0 likes
      Last Post cmtjoancolmenero  
      Started by merc410, Today, 03:41 AM
      4 responses
      27 views
      0 likes
      Last Post merc410
      by merc410
       
      Started by Graci117, Yesterday, 11:40 PM
      2 responses
      17 views
      0 likes
      Last Post Graci117  
      Started by Taddypole, Today, 02:25 PM
      0 responses
      1 view
      0 likes
      Last Post Taddypole  
      Working...
      X