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 DJ888, Yesterday, 10:57 PM
    0 responses
    6 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    158 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    7 views
    0 likes
    Last Post Belfortbucks  
    Started by zstheorist, Yesterday, 07:52 PM
    0 responses
    7 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    151 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Working...
    X