Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Newb Strategy dev question about conditions

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

    Newb Strategy dev question about conditions

    I'm new to ninjascript, but not c, so I do have some programming background that is IMMENSLY helping with learning ninjascript.

    I'm trying to create a strategy utilizing values from several different indicators. Basically, I go through and check whether or not my indicators meet certain conditions. For the most part, the ninjascript strategy wizard works just fine for this. I don't really have to venture into the code at all.

    HOWEVER, I can't seem to check conditions when it comes to colors drawn by an indicator. My problems come with Heikin-Ashi Candlestick Oscillator and Heikin-Ashi. I want to check if the color of a bar from Heikin-Ashi in one lookback period matches the color of HACO from another lookback period. But I'm unsure how I go about that. Setting them equal didn't cut it.

    I looked through the indicator code. For instance, HACO has a binary value "Result" that is positive when in an uptrend. But accessing this through my strategy with (HACO(9, 9).Result[0] == 1) DOESN'T work/trigger.

    How can I access variables from an indicator in my strategy? Example code testing what color a Heikin-Ashi bar is would help big time.


    Thanks for your help!

    #2
    Welcome to our forums silentline3x - I would believe your way of accessing the result of your custom indicator is correct - could you perhaps export the strategy you so far created so I can take a look here?

    Comment


      #3
      As it turns out, HACO has a result variable of 1/0. So I can just check for equivalence to 1. I originally said that didn't work...it does. But my problem still lies in Heiken Ashi. I can't determine what color a bar is. So this is my "check" section so far:

      // Condition set 1
      if (HACO(34, 34).Result[0] == 1
      && HeikenAshi().BarColor == BarColorUp
      && CrossAbove(Median, TSSuperTrend(14, TradingStudies.NinjaScript.Utility.MovingAverageTy pe.TEMA, 2.618, 14, TradingStudies.NinjaScript.Utility.SuperTrendMode. Adaptive).UpTrend, 1))


      I'm trying to check if the HeikenAshi study is giving the result of an uptrending bar or a downtrending bar. Is HeikenAshi().BarColor == BarColorUp the way you would do this?

      If I run the strategy, and then run a heiken ashi indicator alongside it, the strategy triggers at point where heiken ashi is not "barColorUp"...

      is my code correct?

      Comment


        #4
        silentline3x, unfortunately it is not possible to get a bar's color (no matter the bar type). However, this can easily be figured out because if the close of a bar is higher than the open, then it is an up bar, which you've set the color for (default is green). Likewise, if the close is lower than the open, it is a down bar, so you can run the calculations on that.
        AustinNinjaTrader Customer Service

        Comment


          #5
          aha! Thanks for the reply.

          Makes me rethink using that as a condition,though....it probably wouldn't be that great of a filter.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          646 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          367 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          570 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X