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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        68 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        39 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        63 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X