Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry Only During Specific Times

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

    Entry Only During Specific Times

    I want to enter trades based on an indicator during certain times only. I get the following to work just fine, but only for one time at a time.

    if (Rising(CCI(10)) == true
    && ToTime(Time[0]) >= 13000 && ToTime(Time[0]) <= 60000)

    The problem comes when I do this,

    if (Rising(CCI(10)) == true
    && ToTime(Time[0]) >= 13000 && ToTime(Time[0]) <= 60000
    && ToTime(Time[0]) >= 70000 && ToTime(Time[0]) <= 73000
    && (oTime(Time[0]) >= 80000 && ToTime(Time[0]) <= 83000
    && ToTime(Time[0]) >= 90000 && ToTime(Time[0]) <= 110000)

    I get no trades, I even tried this,

    if (Rising(FisherTransform(10)) == true
    && (ToTime(Time[0]) >= 13000 && ToTime(Time[0]) <= 60000)
    && (ToTime(Time[0]) >= 70000 && ToTime(Time[0]) <= 73000)
    && (ToTime(Time[0]) >= 80000 && ToTime(Time[0]) <= 83000)
    && (ToTime(Time[0]) >= 90000 && ToTime(Time[0]) <= 110000))

    Still no luck. Without having to have 14 conditions I would like the latter to work, I still have more times and need to add Falling. Thanks in advanced.

    #2
    Originally posted by Hammerhorn View Post
    I want to enter trades based on an indicator during certain times only. I get the following to work just fine, but only for one time at a time.

    if (Rising(CCI(10)) == true
    && ToTime(Time[0]) >= 13000 && ToTime(Time[0]) <= 60000)

    The problem comes when I do this,

    if (Rising(CCI(10)) == true
    && ToTime(Time[0]) >= 13000 && ToTime(Time[0]) <= 60000
    && ToTime(Time[0]) >= 70000 && ToTime(Time[0]) <= 73000
    && (oTime(Time[0]) >= 80000 && ToTime(Time[0]) <= 83000
    && ToTime(Time[0]) >= 90000 && ToTime(Time[0]) <= 110000)

    I get no trades, I even tried this,

    if (Rising(FisherTransform(10)) == true
    && (ToTime(Time[0]) >= 13000 && ToTime(Time[0]) <= 60000)
    && (ToTime(Time[0]) >= 70000 && ToTime(Time[0]) <= 73000)
    && (ToTime(Time[0]) >= 80000 && ToTime(Time[0]) <= 83000)
    && (ToTime(Time[0]) >= 90000 && ToTime(Time[0]) <= 110000))

    Still no luck. Without having to have 14 conditions I would like the latter to work, I still have more times and need to add Falling. Thanks in advanced.
    from what you write, I am going to presume that you wrote the math without ever writing the English. So I will translate to the English and it will then be obvious why you have written a set of conditions that is impossible to ever satisfy.
    (ToTime(Time[0]) >= 13000 && ToTime(Time[0]) <= 60000)
    && (ToTime(Time[0]) >= 70000 && ToTime(Time[0]) <= 73000)
    translates to:
    "If the time of the current bar is after 0130hrs and before 0600hrs and the current bar time is at the same time after 0700hrs ..."

    There is no time that is before 0600hrs and after 0700hrs. That is physically and mathematically impossible. IOW, your condition is never going to be true.

    These kind of logic errors can usually be avoided if you start by writing down your logic in language, before trying to code it.

    Comment


      #3
      I realized the error, in that the condition was not separating them out and was doing exactly what you say, but I am just now realizing my mistake, &&. Very rusty on writing script (ten years or more), can I use OR in place of &&? Will I get my goal of not having to write a condition for each time frame?

      Comment


        #4
        Originally posted by Hammerhorn View Post
        I realized the error, in that the condition was not separating them out and was doing exactly what you say, but I am just now realizing my mistake, &&. Very rusty on writing script (ten years or more), can I use OR in place of &&? Will I get my goal of not having to write a condition for each time frame?
        A logical "OR" should work.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        656 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        371 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        579 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X