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

Stops and Targets

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

    Stops and Targets

    Hi, Ninja-Newbie here...

    I'm working in the Strategy Builder and trying to create rules for stops and targets. It works just fine if I add a simple value for currency, or ticks, but if I try to add anything more complex the strategy will not allow me to click the "Enabled" box for testing. I can right-click and "Enable" the strategy, but it does not return any trades or backtesting analysis.

    For example I tried setting ATR*2 as a stop value. I also tried things like setting the low -1 tick of the previous bar... Basically anything other than a straight integer or double value will not allow me to enable the strategy.

    Any ideas why this may occur?

    #2
    Hello joeybucks,

    Welcome to the forums.

    Could you open the New -> NinjaScript Output window and then try to enable the strategy. Are you seeing an error when starting it?

    If so could you provide the error?

    If there is no error, could you provide the strategy either on the forum or emailed in at platform support [at] ninjatrader.com?


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Here is the error I'm receiving from the Output window:

      "Error on calling 'OnStateChange' method: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."


      Here is an example of the code:

      SetStopLoss(@"LE1", CalculationMode.Price, (Low[1] + (-1 * TickSize)) , false);
      SetProfitTarget(@"LE1", CalculationMode.Price, (Position.AveragePrice + ((ATR(14)[1] * 2) )) );

      Thanks for your help.

      Joe

      Comment


        #4
        Hello,

        Thank you for the reply.

        Could you please export the strategy and send it to platform support [at] ninjatrader.com for further review?

        Please include the following ticket number with your email: 1735977

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sightcareclickhere, Today, 01:55 PM
        0 responses
        1 view
        0 likes
        Last Post sightcareclickhere  
        Started by Mindset, 05-06-2023, 09:03 PM
        9 responses
        258 views
        0 likes
        Last Post ender_wiggum  
        Started by Mizzouman1, Today, 07:35 AM
        4 responses
        18 views
        0 likes
        Last Post Mizzouman1  
        Started by philmg, Today, 01:17 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by cre8able, Today, 01:01 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X