Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

problem with strategy seeing dates and times

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

    problem with strategy seeing dates and times

    Hello Kate,


    I'm trying to create parameters for days and times to trade within NinjaScript. I'd like to enter:

    - On Sundays AND after 3:30pm - shown on lines 265-267, OR
    - On Mondays thru Friday before 12:00p - shown on lines 268-274
    - Then I have my Buy Entry criteria beneath this - shown on lines 275-291
    - My Long Entry command is shown on line 293

    My indicators are entering and exiting trades correctly. However, I'm having problems with the strategy seeing my days and times correctly. For example, the strategy is entering in trades on Monday thru Friday AFTER 12:00p, but based on lines 268-274, I shouldn't enter in trades after 12:00p on Mon-Fri. I think my parentheses are off, but am unsure where I'm going wrong. Can you please take a look and tell me where I'm going wrong?


    #2
    Hello Ttrade12,

    I have moved this post into its own thread since it was not directly related to the original poster's question and the thread was quite old.

    Your conditions appear to be set up correctly, I would recommend debugging the script to further diagnose the behavior.

    To understand why the script is behaving as it is, such as placing orders or not placing orders (or drawing objects or other actions) when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar.

    This will print to the output window. Backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

    Output from prints will appear in the NinjaScript Output window.
    NT8: New -> NinjaScript Output

    The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very helpful to include labels and operators in the print to understand what is being compared in the condition sets.

    Below I am providing a link to videos that demonstrate adding prints to a script to get further information about the behavior of the script.
    NT8 —


    If you are using the Strategy Builder in NinjaTrader 8, you can also build prints in the Actions window under Misc -> Print.
    NT8 Strategy Builder —


    It is also helpful to set TraceOrders to true in State.Configure as well as print the order object in OnOrderUpdate().
    TraceOrders will output to the NinjaScript Output window a message when orders are being submitted, ignored, cancelled, or rejected.
    Printing the order object in OnOrderUpdate() will allow you to track the progression of the order from submitted, to working, to filled, cancelled, or rejected.
    These tools will let you know what happens to the order.
    TraceOrders - https://ninjatrader.com/support/help...raceorders.htm
    OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm

    I'm also including a link to a forum post with further suggestions on debugging a script.


    Save the output from the output window to a text file. Let me know if you need assistance creating a print or enabling TraceOrders.

    I am happy to assist with analyzing the output from prints and TraceOrders.​

    Comment


      #3
      Thanks, Gaby. I'll work on this.

      Comment


        #4
        Hi Gaby,

        I was able to figure out what was wrong by stripping my code and taking it line by line. Thanks for the resources!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Josephina55, Yesterday, 06:30 PM
        0 responses
        6 views
        0 likes
        Last Post Josephina55  
        Started by mathfrick2023, 05-08-2025, 12:51 PM
        8 responses
        68 views
        0 likes
        Last Post Yogaman
        by Yogaman
         
        Started by several, 04-22-2025, 05:21 AM
        2 responses
        243 views
        0 likes
        Last Post Lukasxgtx  
        Started by cherkoul, 06-12-2025, 11:21 PM
        0 responses
        16 views
        0 likes
        Last Post cherkoul  
        Started by NTEducationTeam, 06-12-2025, 02:30 PM
        0 responses
        26 views
        0 likes
        Last Post NTEducationTeam  
        Working...
        X