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

Within A Period

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

    Within A Period

    I am trying to create a condition where the DM- crossed DM+ within X bars.

    Using barsago seems to just return that specific number of bars

    I have this code. How could I change it to say the cross has happened within the last X (9) candles?

    Thanks Stefan

    CrossAbove(DM(DmiPeriod).DiMinus, DM(DmiPeriod).DiPlus, 1)

    #2



    Examples
    // Go short if CCI crossed above 250 within the last bar
    if (CrossAbove(CCI(14), 250, 1))
    EnterShort();

    // Go long if 10 EMA crosses above 20 EMA within the last bar
    if (CrossAbove(EMA(10), EMA(20), 1))
    EnterLong();

    // Go long we have an up bar and the 10 EMA crosses above 20 EMA within the last 5 bars
    if (Close[0] > Open[0] && CrossAbove(EMA(10), EMA(20), 5))
    EnterLong();

    Originally posted by delta20 View Post
    I am trying to create a condition where the DM- crossed DM+ within X bars.

    Using barsago seems to just return that specific number of bars

    I have this code. How could I change it to say the cross has happened within the last X (9) candles?

    Thanks Stefan

    CrossAbove(DM(DmiPeriod).DiMinus, DM(DmiPeriod).DiPlus, 1)

    Comment


      #3
      Thanks I thought

      // Go long we have an up bar and the 10 EMA crosses above 20 EMA within the last 5 bars
      if (Close[0] > Open[0] && CrossAbove(EMA(10), EMA(20), 5))



      That meant it only looked at the 5th bar back I did not realize it was looking at the whole 5 bar period.

      I do not know where the thanks button is otherwise I would send you one

      Comment


        #4
        Originally posted by delta20 View Post
        Thanks I thought

        // Go long we have an up bar and the 10 EMA crosses above 20 EMA within the last 5 bars
        if (Close[0] > Open[0] && CrossAbove(EMA(10), EMA(20), 5))


        That meant it only looked at the 5th bar back I did not realize it was looking at the whole 5 bar period.

        I do not know where the thanks button is otherwise I would send you one
        You cannot see the "THANKS" button that is on the same line as the "QUOTE" button that you used to reply to the post?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by dward123, 01-02-2024, 09:59 PM
        4 responses
        174 views
        0 likes
        Last Post Lancer
        by Lancer
         
        Started by ETFVoyageur, Today, 04:00 PM
        2 responses
        19 views
        0 likes
        Last Post ETFVoyageur  
        Started by AaronKTradingForum, Today, 03:44 PM
        1 response
        13 views
        0 likes
        Last Post AaronKTradingForum  
        Started by Felix Reichert, 04-26-2024, 02:12 PM
        11 responses
        80 views
        0 likes
        Last Post Felix Reichert  
        Started by junkone, 04-28-2024, 02:19 PM
        7 responses
        84 views
        1 like
        Last Post junkone
        by junkone
         
        Working...
        X