• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Start Time Greater than End Time

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

    Strategy Start Time Greater than End Time

    I have an issue with strategy start and end time

    Based on this thread
    https://ninjatrader.com/support/foru...ad.php?t=57715

    I am using this code

    Code:
    if(StartTime<StopTime
    					&& ToTime(Time[0]) >= (StartTime * 100) 
    					&& ToTime(Time[0]) <= (StopTime * 100))
    					
    					trade=true;
    
    				else if (StartTime>StopTime)
    				{
    					if ((ToTime(Time[0]) >= (StartTime*100) && ToTime(Time[0]) <= 235959) || ToTime(Time[0]) < (StopTime * 100))
    					
    					trade=true;	
    				}		
    				
    				else
    					trade=false;
    Inputs for start and end time are:

    Code:
    				StartTime = 1500;
    				StopTime = 1230;

    So the strategy crosses over sessions.

    It seemed like it worked, but it is not working anymore. This has been a real headache, is there a simpler way to code this?
    -EC_Chris-
    NinjaTrader Ecosystem Vendor - Emergent Cybernetics

    #2
    Hello EC_Chris,

    Thanks for opening the thread.

    I suggest to add debug prints to your code so you can see if this trade bool is getting set appropriately, or if there is another part of the logic that is preventing your orders from submitting.

    I have created a demonstration showing how debugging prints can be used with the Strategy Analyzer to analyze the strategy logic.

    Demo: https://www.screencast.com/t/nDBZkW9s

    Additional tips on debugging can be found here: https://ninjatrader.com/support/foru...ead.php?t=3418

    Please let me know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Same issue, I just reset strategy on start of each interval. Like time 1 to 160000 or 170000 to 240000

      Comment


        #4
        Hello Kubera2024 and EC_Chris,

        I have included an export for my demonstration video yesterday. This can be tested in the Strategy Analyzer and the prints that show if the filter "trade" becomes true or false can be observed in the NinjaScript Output window.

        For the thread's reference, additional examples on time checks can be seen in the sample here: https://ninjatrader.com/support/foru...ead.php?t=3226

        Please let us know if we can be of further assistance.
        Attached Files
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by RB104, Today, 06:06 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by jtrading82, 05-25-2018, 09:59 AM
        9 responses
        977 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by syxforex, Today, 12:11 AM
        2 responses
        15 views
        0 likes
        Last Post syxforex  
        Started by aslane, Today, 02:31 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by stoner, 10-16-2019, 01:38 PM
        5 responses
        51 views
        0 likes
        Last Post sledge
        by sledge
         
        Working...
        X