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

Strategy Start Time Greater than End Time

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

  • NinjaTrader_Jim
    replied
    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

    Leave a comment:


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

    Leave a comment:


  • NinjaTrader_Jim
    replied
    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.

    Leave a comment:


  • EC_Chris
    started a topic Strategy Start Time Greater than End Time

    Strategy Start Time Greater than End Time

    I have an issue with strategy start and end time

    Based on this thread
    Support for the development of custom automated trading strategies using NinjaScript.


    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?

Latest Posts

Collapse

Topics Statistics Last Post
Started by bmartz, Today, 09:30 AM
2 responses
11 views
0 likes
Last Post bltdavid  
Started by f.saeidi, Today, 11:02 AM
1 response
3 views
0 likes
Last Post NinjaTrader_BrandonH  
Started by geotrades1, Today, 10:02 AM
4 responses
12 views
0 likes
Last Post geotrades1  
Started by rajendrasubedi2023, Today, 09:50 AM
3 responses
16 views
0 likes
Last Post NinjaTrader_BrandonH  
Started by lorem, Today, 09:18 AM
2 responses
11 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X