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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    164 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    318 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    246 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    350 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X