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 ETFVoyageur, 04-30-2024, 02:04 PM
    13 responses
    108 views
    0 likes
    Last Post ETFVoyageur  
    Started by Skifree, Today, 11:21 AM
    1 response
    2 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
    52 responses
    5,265 views
    0 likes
    Last Post olivierh  
    Started by ssijbabu, 10-07-2012, 07:10 AM
    6 responses
    4,430 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by iceman2018, Today, 10:39 AM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Erick  
    Working...
    X