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

Time

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

    Time

    Can someone tell me how in heck the code below the if flat and cmeRth=0 code could be executing before 850am.

    Code:
    protected override void OnBarUpdate()
    		{
    			
    			
    			//PrintWithTimeStamp("cond2 = " + cond2.ToString ());
    			//PrintWithTimeStamp("cmeRth = " + cmeRth.ToString ()); 
    			cond2 = (CrossAbove( bClose(BarsArray[1],bCloseMult), EMA(Highs[1],bCloseSmaLen)[0],1) ? 1 : 0 ) ; 
    			
    			limitPrice = Instrument.MasterInstrument.Round2TickSize(Klose(BarsArray[1],1,1,1,1)[0]) - 
    						(Instrument.MasterInstrument.Round2TickSize(GMA(BarsArray[1],myPriceRangeLen)[0] * myPriceRangeFactor)); 
    			cmeRth = ( ToTime(Time[0]) > 85000 && ToTime(Time[0]) < 144500 ? 1:0); 
    			//if (ToTime(Time[0]) < ToTime(08,50,00)) return; 
    			
    			
    			if (BarsInProgress == 1)
    			{
    		
    		//PrintWithTimeStamp("cme = " + cmeRth.ToString ()); 
    			
    			
    		#region Long Entry
    	
    			if (Position.MarketPosition == MarketPosition.Flat && cmeRth == 1 )
    Last edited by neb1998; 11-13-2011, 10:12 PM.

    #2
    neb1998, on what timeframe are you running this code? Tick or time based?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by neb1998 View Post
      Can someone tell me how in heck the code below the if flat and cmeRth=0 code could be executing before 850am.
      There must be some mistake: I do not see any such line in your code.

      Comment


        #4
        Bertrand, i am running on tick within market replay.

        COBC = true

        Comment


          #5
          Then that could be the case neb1998, the tick based intervals would not exactly resolve to an integer timestamp, the bars would close whenever the building logic dictates - you would need to reformulate your time logic to take this into consideration.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Can you recommend a starting point, i know what you mean now since integers only work to the minute using ToTime. Will i just need to use regular c# time functions?

            Comment


              #7
              Hi neb1998, they would work down to the second -

              'Integer representation of time is in the following format Hmmss where 7:30 AM would be 73000 and 2:15:12 PM would be 141512.'

              But you would not know when the bar exactly ends on tick based charts, so try defining a time region and then return out of the calcs once the first occurrence evaluated 'true'.
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Max238, Today, 01:28 AM
              2 responses
              26 views
              0 likes
              Last Post NinjaTrader_ChristopherJ  
              Started by Shansen, 08-30-2019, 10:18 PM
              25 responses
              949 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by JonesJoker, 04-22-2024, 12:23 PM
              8 responses
              41 views
              0 likes
              Last Post JonesJoker  
              Started by timko, Today, 06:45 AM
              0 responses
              3 views
              0 likes
              Last Post timko
              by timko
               
              Started by Waxavi, 04-19-2024, 02:10 AM
              2 responses
              39 views
              0 likes
              Last Post poeds
              by poeds
               
              Working...
              X