Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PriorDay for Gaps

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

    PriorDay for Gaps

    I've been reading and researching the site about this but I'm having a hard time since I'm not a real programmer.

    From what I understand, I need to first run this code to see what day it is:

    {
    /* If the day is Monday, and we want the value from Friday, we must subtract 3 days from the current date.
    If the day is Tuesday-Friday, just subtract one day. */
    if (Time[0].DayOfWeek == DayOfWeek.Monday)
    timeOfInterest = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day - 3, 9, 30, 0);
    else
    timeOfInterest = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day - 1, 9, 30, 0);
    }

    Now I just want it run go short if the open is greater than previous close:


    if (ToTime(Time[0]) == ToTime(9, 30, 0)
    && (ShowClose && ToDay(DateTime.Today) == ToDay(Time[0].Date)) PriorClose.Set(priordayClose);
    && Open[0] > PriorDayOHLC().PriorClose[1])
    {
    EnterShort(DefaultQuantity, "");
    }

    This doesn't seem to work as there are a lot of errors. Am I going down the right path? I just want to trade off a gap, I can figure out all of the other details but I can't get the model to pull up the right data.

    Thanks

    #2
    Hello,

    Thanks for your note.

    What kind of errors?

    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #3
      i've attached a screen pic
      Attached Files

      Comment


        #4
        Hello,

        Yes your missing a bunch of needed code to make this code compile.

        Unfortunately this is more general programming type stuff then NinjaScript support.

        However if you post your full code on the forums here I can give it a quick debug to find the missing things you need.
        BrettNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        89 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        131 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X