• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Basic programming question

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

    Basic programming question

    Hello, new to Ninjascript. I have a question. I am trying to paint the bars a color when 3 parts of the macd are above the zero line. (macd, avg, diff), or when two are above and one is below, etc. I use barcolor = Color.Red and I can get it to work if I only program for one of the variables. My challenge is getting the coding correct when I want all three variables (mulitple conditions in other words). I am doing something wrong. Using "and" to add multiple conditions doesnt seem to work.
    For example:
    if A > 0 and
    B > 0 and
    C < 0
    BarColor = Color. Red ;
    this doesnt seem towork. I am probably messing up with the basic coding. Help...lol.

    #2
    You would need to do something like:

    Code:
    if (MACD(12, 26, 9).Macd[0] > 0 && MACD(12, 26, 9).Avg[0] > 0 && MACD(12, 26, 0).Diff[0] > 0)
        BarColor = Color.Red;
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks Ray, but still have a problem

      Ray, you are awesome. I used the &&; however, I am still getting an error.
      "Cannot apply indexing with [] to an expression of type 'method group'

      here is my code:
      if (MACD(12,26,9).MACD[0] > 0 && MACD(12,26,9).Diff[0] > 0 && MACD(12,26,9).Avg[0] > 0)
      BarColor = Color.Red ;


      Comment


        #4
        I edited my original post. Changed the MACD[0] to Macd[0].
        RayNinjaTrader Customer Service

        Comment


          #5
          thanks, that did it...I should have caught that

          Appreciate the help, you guys are great. I should have caught that as well. But we got it..thanks a million.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by dadarara, Yesterday, 06:38 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by jvanelli, Today, 01:19 PM
          1 response
          2 views
          0 likes
          Last Post jvanelli  
          Started by TrendFollowingCapital, Today, 05:45 AM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Atilla, Today, 04:26 AM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by FelixMMM, Today, 04:11 AM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X