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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        646 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        367 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X