Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

No entries at certain times

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

    No entries at certain times

    Hi, I have the following:

    if(ToTime(Time[0]) >= 170000 || ToTime(Time[0]) <= 154500)
    {
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    if (Condition)
    {
    EnterLong();
    }

    How do I add to the script if I do not want to enter any positions during 12am – 2am nor 6am – 8am and if there are any positions prior to 12am or 6am to exit based on the strategy instead of exiting at that given time.
    Thanks

    #2
    Hello 2Look4me,

    Thanks for your post.

    You could check something like the following to check that you are within your desired time frame and call ExitLong/ExitShort to exit positions if the strategy is not flat.

    Code:
    if (Time[0] >= 0 && ToTime(Time[0]) <= 20000))
    {
        if (Position.MarketPosition != MarketPosition.Flat)
        {
            ExitLong();
            ExitShort();
        }
    }
    Similarly, you can make time checks to check if the time is between 6am and 8am with a check like the following and perform your same logic to exit if you are not flat.

    Code:
    if (Time[0] >= 60000 && ToTime(Time[0]) <= 80000))
    You can then use else statements with these checks for when trading should occur outside of these time checks.

    Please let us know if we can be of further assistance.

    Comment


      #3
      Jim, thanks for the prompt reply. It seems like your suggestion is to exit the position outright. Is there a function/command/script that will not allow entries based on the strategy at those given times of 12a-2am and 6a-8am, but will allow "Exits" based on the strategy if the entry happened before 12am or 6am?

      Comment


        #4
        Hello 2Look4me,

        There would not be built in method for this. This would involve building logic using time checks to control when your strategy should do certain actions. You could set some bool variables in your script to control when "AllowEntries" should be set to true/false and when "AllowExits" should be set to true/false. You could then use those bools to control your logic throughout your script.

        Alternatively, you can write your script so your desired actions take place within your time checks.

        Please let me know if you have any questions.

        Comment


          #5
          Thanks for you suggestions.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          557 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X