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

Missing the plot

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

    Missing the plot

    (1) I tried the following (add a condition within bracket ) but failed to have the first session plotted.

    {
    if (ToTime(Time[0]) < ToTime(8, 30, 0) || (ToTime(Time[0]) > ToTime(9, 0, 0)))
    return;

    startDateTime1d = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 8, 30, 0);
    endDateTime1d = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 9, 00, 0);

    int startBarsAgo1d = GetBar( startDateTime1d);
    int endBarsAgo1d = GetBar( endDateTime1d);

    double highestHigh1d = MAX(High, startBarsAgo1d - endBarsAgo1d)[endBarsAgo1d];
    double lowestLow1d = MIN( Low, startBarsAgo1d - endBarsAgo1d)[endBarsAgo1d];

    h1d.Set (highestHigh1d);
    l1d.Set ( lowestLow1d);
    }



    {
    if (ToTime(Time[0]) > ToTime(8, 30, 0))
    return;

    startDateTime1c = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 8, 00, 0);
    endDateTime1c = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 8, 30, 0);

    int startBarsAgo1c = GetBar( startDateTime1c);
    int endBarsAgo1c = GetBar( endDateTime1c);

    double highestHigh1c = MAX(High, startBarsAgo1c - endBarsAgo1c)[endBarsAgo1c];
    double lowestLow1c = MIN( Low, startBarsAgo1c - endBarsAgo1c)[endBarsAgo1c];

    h1c.Set (highestHigh1c);
    l1c.Set ( lowestLow1c);
    }


    (2) If I switch the two brackets (ie write the code for h1c/l1c first),then the first session was plotted but not the second session. Advice needed.Thanks.
    Attached Files

    #2
    Hello,

    What are the conditions for the brackets ( " { } " )?

    The "return" part of the code ends the block of code and restarts iteration, that, in my opinion, could be it.
    DenNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mishhh, 05-25-2010, 08:54 AM
    19 responses
    6,189 views
    0 likes
    Last Post rene69851  
    Started by gwenael, Today, 09:29 AM
    0 responses
    1 view
    0 likes
    Last Post gwenael
    by gwenael
     
    Started by Karado58, 11-26-2012, 02:57 PM
    8 responses
    14,829 views
    0 likes
    Last Post Option Whisperer  
    Started by Option Whisperer, Today, 09:05 AM
    0 responses
    1 view
    0 likes
    Last Post Option Whisperer  
    Started by cre8able, Yesterday, 01:16 PM
    3 responses
    11 views
    0 likes
    Last Post cre8able  
    Working...
    X