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

Is there an easier way to say this

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

    Is there an easier way to say this

    I want to make a triangle appear on a crossup by +DMI of 25 but only if first there was no crossup of 20 on any of the prior 4 bars.

    The only way I can figure the restriction is like this, but is there a more concise way than stating the value needed to be above 20 the last 5 bars (in order to be sure it didnt crossup on that 4th bar back) by writing it for 1 bar back at a time like in red bold below?

    if (CrossAbove(DiPlus, 25,1)&& DiPlus[1]<=25 && DiPlus[0]>=DiMinus[0]
    && DiPlus[
    1]>20 && DiPlus[2]>20 && DiPlus[3]>20 && DiPlus[4]>20 && DiPlus[5]>20 )

    #2
    simpletrades, you could simplify this if needed with CountIf() - http://www.ninjatrader-support.com/H...6/CountIf.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      simpletrades, you could simplify this if needed with CountIf() - http://www.ninjatrader-support.com/H...6/CountIf.html
      thanks, but if i want to draw an ArrowUp instead of make an entry
      would it just read
      DrawTriangleUp("di+25up" + CurrentBar, false, 0, DiPlus[0]-(1*dist),Color.Lime);

      instead of EnterLong(); like in the example?
      Examples
      // If in the last 10 bars we have had 8 up bars then go long

      if(CountIf(delegate {return Close[0] > Open[0];}, 10) > 8) EnterLong();
      Last edited by simpletrades; 11-06-2009, 08:14 AM.

      Comment


        #4
        Sure, you could also draw your triangle as this returns true instead of submitting an entry order, this is just an example how to use the syntax.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by TraderBCL, Today, 04:38 AM
        2 responses
        7 views
        0 likes
        Last Post TraderBCL  
        Started by martin70, 03-24-2023, 04:58 AM
        14 responses
        105 views
        0 likes
        Last Post martin70  
        Started by Radano, 06-10-2021, 01:40 AM
        19 responses
        606 views
        0 likes
        Last Post Radano
        by Radano
         
        Started by KenneGaray, Today, 03:48 AM
        0 responses
        4 views
        0 likes
        Last Post KenneGaray  
        Started by thanajo, 05-04-2021, 02:11 AM
        4 responses
        471 views
        0 likes
        Last Post tradingnasdaqprueba  
        Working...
        X