Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Can Anyone Compile This and Send Back As Script File?

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

    Can Anyone Compile This and Send Back As Script File?


    double PrevDayClose
    ()
    {

    double _prevclose = 0;

    try
    {
    DateTime _prevday = Time[0].AddDays(-1);

    // make sure prior day is always mon-fri never sat or sun

    if (Time[0].DayOfWeek == DayOfWeek.Monday)
    _prevday = Time[0].AddDays(-3);

    if (
    Time[0].DayOfWeek == DayOfWeek.Sunday)
    _prevday = Time[0].AddDays(-2);

    _prevclose = Close[0][GetBar(new DateTime(_prevday.Year, _prevday.Month, _prevday.Day, 16, 15, 0); // where 16,15,0 means 4:15:00pm based on local PC time

    }
    catch(
    Exception e)
    {
    Print (
    e.ToString()); // just incase index is exceeded somewhere
    }


    return
    _prevclose;

    }

    #2
    I stripped it down a bit, this compiles well now -

    Code:
     
    DateTime _prevday = Time[0].AddDays(-1); 
    // make sure prior day is always mon-fri never sat or sun 
    if (Time[0].DayOfWeek == DayOfWeek.Monday) 
    _prevday = Time[0].AddDays(-3); 
    if (Time[0].DayOfWeek == DayOfWeek.Sunday) 
    _prevday = Time[0].AddDays(-2); 
    double _prevclose = Closes[0][GetBar(new DateTime(_prevday.Year, _prevday.Month, _prevday.Day, 16, 15, 0))]; // where 16,15,0 means 4:15:00pm based on local PC time
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by benmarkal, Yesterday, 12:52 PM
    3 responses
    22 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by helpwanted, Today, 03:06 AM
    1 response
    18 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    11 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    6 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    244 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Working...
    X