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

Bars ago

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

    Bars ago

    Hi
    I am having trouble finding an answer to a simple problem - or definition.

    I want to use an event that may have occured within the last n bars such as EMA(20) crossed over EMA(200) within the last 4 bars. I have 3 events which I need to have occured within the last 3-4 bars to satisfy a trade condition. I cannot get the syntax right!

    I would be grateful for help
    Thanks
    Karl

    #2
    Hello,

    If you're checking for CrossAbove() or CrossBelow, the lookback period will be built into this method.

    However if you have other conditions which are not CrossAbove/Below, you would need to use a method like CountIf() to determine if this condition has happened recenlty.

    CountIf() - http://www.ninjatrader.com/support/h...ml?countif.htm


    If you're having trouble with the syntax, please post a snippet so I can look into.
    Last edited by NinjaTrader_Matthew; 10-13-2011, 09:37 PM.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Bars ago

      Thanks Matthew, you folk are great with quick responses. I will look at the ref and if necessary take the suggested course if I get stuck.
      Karl

      Comment


        #4
        Bars ago

        Hi Matthew, I will gratefully take your suggestion:

        My strategy for a long trade requires that on a particular event happening, the drawTrend line of the d9ParticleOscillator must have crossed the 0 line from below; the rising DM+ of the ADX has crossed the DM- ; and the rising SMA(1) has crossed the SMA(3). These things occur in no particular sequence but must have all occurred within the last 3 or 4 bars (user input) for the conditions for the trade to have been met.

        I am trying to build a strategy but my NinjaScript/C+ coding skills are very primative at this stage. I am using the Wiz but that is limited. Your help would be much appreciated.

        Thanks Karl

        Comment


          #5
          Hello scartree,

          Unfortuantley you will not be able to create this in the strategy wizard. You would need to use custom programming and use the CountIf() method to check this.

          You can still use your Strategy Wizard to create the initial conditions. Once this is completed, you can 'view code' to look at the syntax for these conditions and then copy these into a new strategy you are custom coding. Once you've done this, you can use methods like CountIf() to check that these conditions were true X bars ago.
          MatthewNinjaTrader Product Management

          Comment


            #6
            I have used the Wiz but as you say, it does not go far enough. It lets me have the various crossings as conditions but as events 'n bars' ago. This seems to work if the event occurred on a specific bar but not any bar within the last 3 or 4 bars. I think I get what you are saying - so back to the drawing board!
            Thanks. Karl

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by GwFutures1988, Today, 02:48 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by ScottWalsh, 04-16-2024, 04:29 PM
            6 responses
            32 views
            0 likes
            Last Post ScottWalsh  
            Started by frankthearm, Today, 09:08 AM
            10 responses
            36 views
            0 likes
            Last Post frankthearm  
            Started by mmenigma, Today, 02:22 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by NRITV, Today, 01:15 PM
            2 responses
            10 views
            0 likes
            Last Post NRITV
            by NRITV
             
            Working...
            X