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

I want to compare the Close[0] relative to a custom MA line

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

    I want to compare the Close[0] relative to a custom MA line

    tried this:-

    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]
    if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] ((Close[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]] > draftMA1(Close,[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]5[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])))
    {
    EnterLong();
    }
    [/SIZE][/FONT][/SIZE][/FONT]
    Got this error:-
    Operator '>' cannot be applied to operands of type 'double' and NinjaTrader.Indicator.draftMA1'

    #2
    Hi kaywai,

    I am not familiar with the draftMA1 indicator, but it is likely you need a barsAgo reference, so something like...

    if (Close[0] > draftMA1(Close,5)[0])
    TimNinjaTrader Customer Service

    Comment


      #3
      that removed the error! Thx Tim!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Christopher Leggit, 02-15-2024, 09:00 AM
      3 responses
      45 views
      0 likes
      Last Post rdtdale
      by rdtdale
       
      Started by DavidHP, Today, 07:56 AM
      0 responses
      1 view
      0 likes
      Last Post DavidHP
      by DavidHP
       
      Started by Aviram Y, 08-09-2023, 09:04 AM
      10 responses
      298 views
      0 likes
      Last Post MrHump
      by MrHump
       
      Started by jpapa, Today, 07:22 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by kevinenergy, 02-17-2023, 12:42 PM
      116 responses
      2,758 views
      1 like
      Last Post kevinenergy  
      Working...
      X