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

Question regarding parameters for Draw.Line

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

    Question regarding parameters for Draw.Line

    I would like to code an indicator which would draw a line which starts of at the start of the current trading day and ends at the close of the actual trading day. I tried to set the parameters of the Draw.Line as follows but there was an error with the sessioniterator part. I have written the relevant time parameters in bold.

    Draw.Line(this, "line1", false, new DateTime(Time[Bars.BarsSinceNewTradingDay].Year, Time[Bars.BarsSinceNewTradingDay].Month, Time[Bars.BarsSinceNewTradingDay].Day, 7, 00, 0),
    j , new DateTime(sessionIterator.ActualTradingDayEndLocal),
    j , Brushes.Brown, DashStyleHelper.Dot , 2);

    Could you please advise me on what is wrong with my use of the session iterator to find the time when the trading day ends or alternatively, if there is a better way to code for the objective I am trying to accomplish, please let me know. Thanks in advance.

    #2
    Hello mbesha,

    Thank you for writing in.

    There is an issue with beta 10 where Draw objects will not initially draw anything until historical data has been reloaded if using an overload that takes in a DateTime parameter. This has been rectified and will be in beta 11.

    As a way to get around this, you can utilize Bars.GetBar() to obtain a barsAgo value for where to draw your line.

    For example:

    Code:
    Draw.Line(this, CurrentBar.ToString(), 0, Close[0], CurrentBar - Bars.GetBar(sessionIterator.ActualTradingDayEndLocal), Close[0], Brushes.Blue);
    More about Bars.GetBar() can be found here: http://ninjatrader.com/support/helpG...us/?getbar.htm

    Alternatively, to do this with DateTime objects:
    Code:
    Draw.Line(this, CurrentBar.ToString(), true, sessionIterator.ActualSessionBegin, Close[0], sessionIterator.ActualTradingDayEndLocal, Close[0], Brushes.Blue, DashStyleHelper.Dash, 5);
    Just make sure you are reloading historical data (right-click chart -> select Reload All Historical Data) in order for the line to appear in beta 10 due to the issue stated at the beginning of the post.

    Make sure you are doing this within an if (Bars.IsFirstBarOfSession) check and that you have called GetNextSession() to calculate the next session:
    Code:
    if (Bars.IsFirstBarOfSession)
    {
         sessionIterator.GetNextSession(Time[0], true);
    
         // logic
    }
    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by geddyisodin, Yesterday, 05:20 AM
    7 responses
    45 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by gbourque, Today, 06:39 AM
    2 responses
    5 views
    0 likes
    Last Post gbourque  
    Started by cre8able, Yesterday, 07:24 PM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by cocoescala, 10-12-2018, 11:02 PM
    6 responses
    939 views
    0 likes
    Last Post Jquiroz1975  
    Started by cmtjoancolmenero, Yesterday, 03:58 PM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X