Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

why wont this profit target compile?

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

    why wont this profit target compile?

    protected override void OnBarUpdate()
    {
    SetProfitTarget("", CalculationMode.Ticks, 10/10*ATR(25));

    #2
    Hello James 377,

    This is the error message I get when attempting to compile.

    Operator '*' cannot be applied to operands of type 'int' and 'NinjaTrader.Indicator.ATR' CS0019 - click for info 56 47

    Calculation Mode.Ticks requires an integer, and the value you're inputting is a DataSeries.

    What is it you're looking to do?
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      why is it a series?

      looking to set a profit target which takes a profitfactor and divides by 10 then multiplies by ATR(25). so i can give it a number like 25 which will be 2.5*ATR(25)

      Comment


        #4
        ATR() is a series. To reference a specific value, you need the index [ ] assigned to it.

        You should be able to use:
        SetProfitTarget("", CalculationMode.Ticks, 10/10*ATR(25)[0]);

        The following help guide article on basic NinjaScript syntax may be useful for you.
        http://www.ninjatrader-support.com/HelpGuideV6/BasicSyntax.html
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        14 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        119 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        172 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        88 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        131 views
        0 likes
        Last Post cmoran13  
        Working...
        X