Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time of Day Script

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

    Time of Day Script

    Can anyone tell me why the upper part of the script below would place a trade before 9:38 AM - Thanks


    // Bollinger Cross Below Lower Band Bear Zone

    if ((Times[0][0].TimeOfDay >= new TimeSpan(9, 38, 0))
    && (Times[0][0].TimeOfDay <= new TimeSpan(15, 20, 0)))
    {
    }
    // need an input for spread amount to replace the 16 cents or ticks SPREAD IN TICKS
    // if ((GetCurrentAsk(0) - 0.16) <= GetCurrentBid(0))
    // {
    // }

    if ((CrossBelow(Close, Bollinger1.Lower, 1))
    && (Bollinger1.Upper[1] > Bollinger1.Upper[2])
    && (UseBollingerCross == true))
    {
    if (AttachATM == true)
    CreateUniqueATMStrategy((int)Signals.BollingerShor t);
    else if (Position.MarketPosition != MarketPosition.Long)
    EnterShort(Convert.ToInt32(DefaultQuantity));
    }


    ****************************

    my thinking is the IF needs to be removed and replaced with &&

    if ((CrossBelow(Close, Bollinger1.Lower, 1))

    ***********************************

    i was really hoping to place the timeofday and the GetCurrentAsk part into the script only once instead of at every conditional part

    thanks

    #2
    Hello DTSSTS,

    The time filter is a separate condition and there is no action for this condition.

    The condition with the CrossBelow is evaluated separately from the time condition and can evaluate as true at any time.

    Either add the time conditions to the same condition set as the CrossBelow, or nest the condition set with CrossBelow within the curly braces of the time conditions set.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    71 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    43 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    25 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    28 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    56 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X