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

How to find the previous 20 day high

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

    #16
    ok i added

    Code:
    if (CurrentBars[0] < 300 || CurrentBars[1] < 210)
             return;
    at the beginning of onbarupdate

    Statement is still being printed, but no trades

    Comment


      #17
      Originally posted by markus1000 View Post
      ok i added

      Code:
      if (CurrentBars[0] < 300 || CurrentBars[1] < 210)
               return;
      at the beginning of onbarupdate

      Statement is still being printed, but no trades
      If you want to use such a large number of days for your filter, then your chart will need to have many more days than 200 loaded. How many days are loaded on your chart/strategy?
      Last edited by koganam; 05-10-2013, 08:49 PM. Reason: Corrected capitalization.

      Comment


        #18
        im testing the strategy for several years, and i want to use the minimum of bars necessary to calculate it. But im still not sure why it isnt working, but it's printing the statement though
        Last edited by markus1000; 05-26-2013, 06:33 AM.

        Comment


          #19
          Hello markus1000,

          By Default NinjaTrader will use 256 for the MaximumBarsLookBack to conserve memory inside of your strategy. Here is a link to our Help Guide that goes over this property that you may view.


          I believe this is what you are referring to, otherwise could you give me an example.

          Happy to be of further assistance.
          JCNinjaTrader Customer Service

          Comment


            #20
            my problem is

            Code:
            if(Closes[1][0] > MAX(Closes[1], 200)[1]
            	&& Closes[1][1]  > MAX(Closes[1], 200)[2]
            	&& Closes[1][2] > MAX(Closes[1], 200)[3])
            {
            Print("Three consecutive days are greater than the last 200 days.");
            }
            does print the statement but doesn't produce trades, and i have no idea why.

            Comment


              #21
              Originally posted by markus1000 View Post
              my problem is

              Code:
              if(Closes[1][0] > MAX(Closes[1], 200)[1]
              	&& Closes[1][1]  > MAX(Closes[1], 200)[2]
              	&& Closes[1][2] > MAX(Closes[1], 200)[3])
              {
              Print("Three consecutive days are greater than the last 200 days.");
              }
              does print the statement but doesn't produce trades, and i have no idea why.
              There is no code there to enter a trade.

              Where is your EnterLong command ?

              Comment


                #22
                the code is incorporated into a strategy that is working without it


                Lets say i have a simple strategy, that is entering trades when RSI >90 (just an example).
                But i only want to trade on days after

                "Three consecutive days are greater than the last 200 days, or 3 new 200 day high in a row"
                Last edited by markus1000; 05-26-2013, 08:55 AM.

                Comment


                  #23
                  Originally posted by markus1000 View Post
                  the code is incorporated into a strategy that is working without it


                  Lets say i have a simple strategy, that is entering trades when RSI >90 (just an example).
                  But i only want to trade on days after

                  "Three consecutive days are greater than the last 200 days, or 3 new 200 day high in a row"
                  Show us how you would write the code for that simple strategy. (Let your real secret-sauce remain in its bottle). If we can see that, and your code still triggers no trades, maybe we may be able to take a shot at seeing why.

                  Sometimes it is hard to figure things out in a code vacuum. For all we know, your combined conditions never trigger. The code that you are showing for "Printing" to the Output Window, is handling only one condition: the one about 200-day MAX.
                  Last edited by koganam; 05-26-2013, 05:04 PM. Reason: Corrected spelling.

                  Comment


                    #24
                    @koganam

                    yes thats right, code snipets are harder to interpret, i attached a simple strategy, just leave everythign in the strategy analyzer as default (close at the end of day, ...)

                    when i include the


                    Code:
                    if(Closes[1][0] > MAX(Closes[1], 200)[1]
                    	&& Closes[1][1]  > MAX(Closes[1], 200)[2]
                    	&& Closes[1][2] > MAX(Closes[1], 200)[3])
                    {
                    Print("Three consecutive days are greater than the last 200 days.");
                    }
                    no trades, without it i have a lot of trades
                    Attached Files

                    Comment


                      #25
                      What is THAT doing there?

                      That would explain everything.

                      Code:
                      		if(Closes[1][0] > MAX(Closes[1], 200)[1]
                      	&& Closes[1][1]  > MAX(Closes[1], 200)[2]
                      	&& Closes[1][2] > MAX(Closes[1], 200)[3]
                      	
                      	
                      	)
                      	{Print("Three consecutive days are greater than the last 200 days.");}
                      
                      [SIZE="7"][COLOR="Red"][I][B]{}{return;}[/B][/I][/COLOR][/SIZE]
                      
                      
                      
                      ?
                      Originally posted by markus1000 View Post
                      @koganam

                      yes thats right, code snipets are harder to interpret, i attached a simple strategy, just leave everythign in the strategy analyzer as default (close at the end of day, ...)

                      when i include the


                      Code:
                      if(Closes[1][0] > MAX(Closes[1], 200)[1]
                      	&& Closes[1][1]  > MAX(Closes[1], 200)[2]
                      	&& Closes[1][2] > MAX(Closes[1], 200)[3])
                      {
                      Print("Three consecutive days are greater than the last 200 days.");
                      }
                      no trades, without it i have a lot of trades

                      Comment


                        #26
                        its there to make me look stupid

                        it should be

                        Code:
                        {Print("Three consecutive days are greater than the last 200 days.");}
                        
                        else {return;}

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by GLFX005, Today, 03:23 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post GLFX005
                        by GLFX005
                         
                        Started by XXtrader, Yesterday, 11:30 PM
                        2 responses
                        11 views
                        0 likes
                        Last Post XXtrader  
                        Started by Waxavi, Today, 02:10 AM
                        0 responses
                        6 views
                        0 likes
                        Last Post Waxavi
                        by Waxavi
                         
                        Started by TradeForge, Today, 02:09 AM
                        0 responses
                        11 views
                        0 likes
                        Last Post TradeForge  
                        Started by Waxavi, Today, 02:00 AM
                        0 responses
                        2 views
                        0 likes
                        Last Post Waxavi
                        by Waxavi
                         
                        Working...
                        X