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 argusthome, 03-08-2026, 10:06 AM
        0 responses
        61 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        40 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        21 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        23 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        51 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X