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

Why NT7 treats the indicator value as Strings?

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

    Why NT7 treats the indicator value as Strings?

    I have some simple code, as follows:

    Code:
    if ( MACD(BarsArray[2],12,26,9)[0]>MACD(BarsArray[2],12,26,9).Avg[0]>0) 
          {
    			bool	trendUp=true;
          }
    The error code is CS0019, stating that a bool and int can not be compared with > .

    Thanks !!

    #2
    Hello wolfcuring,

    Thanks for your post.

    You have two logical evaluations but only 3 variables. You would need to either eliminate one evaluation or add another variable. I'll re-write the two possible ways I can see this:

    1) test that Macd line is greater than the average line
    Code:
    if ( MACD(BarsArray[2],12,26,9)[0] > MACD(BarsArray[2],12,26,9).Avg[0]) 
          {
    	   bool	trendUp = true;
          }
    2) Test that the MACD line is great than the average line and test that the MACD line is greater than 0 and test that the average line greater than 0.

    Code:
    if ( MACD(BarsArray[2],12,26,9)[0] > MACD(BarsArray[2],12,26,9).Avg[0] 
    && MACD(BarsArray[2],12,26,9)[0] > 0 && MACD(BarsArray[2],12,26,9).Avg[0] > 0) 
          {
    	 bool	      trendUp = true;  
          }
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by The_Sec, Yesterday, 03:37 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by vecnopus, Today, 06:15 AM
    0 responses
    1 view
    0 likes
    Last Post vecnopus  
    Started by Aviram Y, Today, 05:29 AM
    0 responses
    5 views
    0 likes
    Last Post Aviram Y  
    Started by quantismo, 04-17-2024, 05:13 PM
    3 responses
    27 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by ScottWalsh, 04-16-2024, 04:29 PM
    7 responses
    36 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X