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

two start times and end times in strategy

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

    two start times and end times in strategy

    i'm trying to have two times in my strategy but its not working. it works with one. i'm trying to do a morning session and an afternoon session. i get a ton of losses during lunch. so, i'm trying to take that part of the day out. any suggestions?
    Attached Files

    #2
    Hello SteveReiza,

    Thank you for your post.

    To set multiple time filters, you will need to use multiple condition groups. I suggest creating a bool variable on the Inputs and Variables screen. You could call it something like "TimeForTrades" and set the default value to false. Then, in one of your condition sets you will select "If any" of the following conditions are true. Next, click group and create a condition group that checks "if all" are true for the start/end times. This would be similar to the time filter condition group in the example at the very bottom of this page:


    After that, create a second condition group with your other time filter for the other portion of the day when you'd like to allow trades. Once both time filter condition groups are created, set the action to change TimeForTrades to be true.

    You will also need to create a separate set that checks if it is not within the desired time filters and, if so, set the TimeForTrades bool to false.

    Finally, in any of your condition sets that result in trades you will need to add a check that TimeForTrades is true in your condition. Here is an example video that checks if it is between 10am-12pm or 2pm-4pm, and if so it sets the bool to true. If it is greater than 4pm, less than 10am, or between 12pm-2pm it sets the bool to false. Then, my condition to enter a long position checks if TimeForTrades is true and if the price is greater than the SMA(14) indicator. This is just an example that could be modified to suit your own needs:


    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      awesome, alright thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by LiamTwine, Today, 08:10 AM
      0 responses
      2 views
      0 likes
      Last Post LiamTwine  
      Started by Balage0922, Today, 07:38 AM
      0 responses
      5 views
      0 likes
      Last Post Balage0922  
      Started by JoMoon2024, Today, 06:56 AM
      0 responses
      6 views
      0 likes
      Last Post JoMoon2024  
      Started by Haiasi, 04-25-2024, 06:53 PM
      2 responses
      19 views
      0 likes
      Last Post Massinisa  
      Started by Creamers, Today, 05:32 AM
      0 responses
      6 views
      0 likes
      Last Post Creamers  
      Working...
      X