Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple Ninjascript question

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

    Simple Ninjascript question

    I am trying to check for the following conditions

    if
    ((Volume[0] > Volume[1]) && (Volume[1] > Volume [2]))
    if ((High[0] > High[1]) && (High[1] > High[2]))

    This works but is there a way to combine the test so that all conditions can be evaluated in one if statement? I have tried various combinations of brackets but nothing seems to work

    #2
    Hi MicroAl,

    Yes you can combine them....


    Code:
    if ((Volume[0] > Volume[1]) && (Volume[1] > Volume [2]) && (High[0] > High[1]) && (High[1] > High[2]))
    TimNinjaTrader Customer Service

    Comment


      #3
      Or:

      if (Volume[0] > Volume[1] && Volume[1] > Volume [2] && High[0] > High[1] && High[1] > High[2])
      eDanny
      NinjaTrader Ecosystem Vendor - Integrity Traders

      Comment


        #4
        Simple Ninjascript question

        Thanks guys tried for ages but could not get it to work. I have now tried adding three statements in the code block following the if statement:-
        {
        BarColor = Color.Gold;
        DrawTriangleUp(CurrentBar.ToString(),
        true, 0, High[0] + TickSize, Color.Red);
        DrawTriangleDown(CurrentBar.ToString(),
        true, 0, Low[0] - TickSize, Color.Red);
        }

        However I cannot get Ninja to draw both the down and the up triangles at the same time. In the above example the Down triangles are drawn only. If I comment out this line the up triangles are drawn - Any ideas?

        Comment


          #5
          It should work. Try again.

          if (Volume[0] > Volume[1] && Volume[1] > Volume [2] && High[0] > High[1] && High[1] > High[2])


          Regards,
          Nirmala

          _________________
          Trading

          Comment


            #6
            Simple Ninjascript question

            Opps should have been more clear. I tried for ages myself but the supplied answer on the condition test works fine. What I cannot get to work now is for ninja to implement the code contained in the {} below. It only seems to draw a triangle down and not an up triangle. I cannot see why all three code lines are not implemented.

            Comment


              #7
              Try: (this is untested)

              DrawTriangleUp("up" + CurrentBar, true, 0, High[0] + TickSize, Color.Red);
              DrawTriangleDown("dwn" +CurrentBar,
              true, 0, Low[0] - TickSize, Color.Red);

              You were reusing the same object name, you need to make them different....and you don't need the ToString part.


              Hope that helps...
              Last edited by mountainclimber; 05-07-2010, 10:40 AM.

              Comment


                #8
                Simple Ninjascript question

                Thanks Mountainclimber I copied the examples from the help guide and did not notice that I needed different tags -Duh.

                Comment


                  #9
                  No, worries. Minor oversights are 95% of the mistakes I (and everyone else I have talked to) make in programming. Sometimes it takes a fresh pair of eyes.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  670 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  379 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  111 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  575 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  582 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X