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

Coding query

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

    Coding query

    I am trying to create a condition to exit a trade as follows
    Exit position if the price fails to close higher in last 10 days
    any suggestions on how to go about coding this in the condition builder
    Thanks

    #2
    Hi shahroor,

    To work with days is only possible in the condition builder if you plan to apply the strategy to a daily series. To check for highest value over a lookback, there is built in indicator MAX(), in the indicator category.

    For more control - where you apply this script to an intraday series but check daily values requires a multiseries script, working with code. There is a sample to work from in Tools > Edit NinjaScript > Strategy > SampleMultiTimeFrame.

    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I am using the daily timeframe. I tried to build the strategy but ended with multiple errors which I cant understand, could you be please explain what these errors mean
      I have attached a copy for your reference
      Many Thanks
      Attached Files
      Last edited by shahroor; 06-09-2011, 11:14 AM.

      Comment


        #4
        There are issues building the MAX expression. I've attached a screenshots of one way you can build this in the strategy wizard. In one of your conditions you selected Open for period, which is expecting a number input.

        There is also a logic issue here, in that Close can never be greater than MAX(Close, 50)[0]. The close value you're checking is included in the MAX set. For this you can check >= or check for MAX one bar back like my screenshot.

        For getting up to speed with the condition builder, see this page:


        There are a few examples there of common expressions you can build. Start simple at first and click compile each time you create an expression. That way if there are any errors, you can resolve right away rather than adding additional ones.

        I suggest attending our next strategy development webinar. Tuesday, June 14th at 5:30 PM eastern. This webinar walks you through each step of creating a moving average crossover strategy using the wizard.
        Attached Files
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I managed to get it sorted , thanks for your explanation as it is making sense now

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by warreng86, 11-10-2020, 02:04 PM
          5 responses
          1,356 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Perr0Grande, Today, 08:16 PM
          0 responses
          3 views
          0 likes
          Last Post Perr0Grande  
          Started by elderan, Today, 08:03 PM
          0 responses
          5 views
          0 likes
          Last Post elderan
          by elderan
           
          Started by algospoke, Today, 06:40 PM
          0 responses
          10 views
          0 likes
          Last Post algospoke  
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          12 views
          0 likes
          Last Post maybeimnotrader  
          Working...
          X