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

Previous Close Extended Line

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

    Previous Close Extended Line

    I would like to extend the close line on the PriorDayOHLC indicator until crossed by price... same as the extended naked levels in the volume profile indicator. How's the best way to proceed?

    protected override void OnBarUpdate()
    {
    if (!Bars.BarsType.IsIntraday)
    return;

    // If the current data is not the same date as the current bar then its a new session
    if (currentDate != sessionIterator.GetTradingDay(Time[0]) || currentOpen == 0)
    {
    // The current day OHLC values are now the prior days value so set
    // them to their respect indicator series for plotting
    priorDayClose = currentClose;
    if (ShowClose) PriorClose[0] = priorDayClose;

    // Initilize the current day settings to the new days data
    currentClose = Close[0];

    currentDate = sessionIterator.GetTradingDay(Time[0]);
    }
    else // The current day is the same day
    {
    // Set the current day OHLC values

    currentClose = Close[0];

    if (ShowClose) PriorClose[0] = priorDayClose;
    }
    }

    #2
    Hello rcmcd,

    You could choose to draw a line from the last bar of that session to the current bar at the price of the close.

    If you are wanting to modify the logic in the script, the condition set with sessionIterator.GetTradingDay() is when things are being reset. You could choose to not reset things.

    // If the current data is not the same date as the current bar then its a new session
    if (currentDate != sessionIterator.GetTradingDay(Time[0]) || currentOpen == 0)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello rcmcd,

      You could choose to draw a line from the last bar of that session to the current bar at the price of the close.

      If you are wanting to modify the logic in the script, the condition set with sessionIterator.GetTradingDay() is when things are being reset. You could choose to not reset things.

      // If the current data is not the same date as the current bar then its a new session
      if (currentDate != sessionIterator.GetTradingDay(Time[0]) || currentOpen == 0)
      How do I choose to not reset things?

      Comment


        #4
        Hello rcmcd,

        You can replace that if statement and replace this with your custom logic on when you want to reset.
        You can also duplicate the plots if you want the originals to remain, and choose to reset the duplicate plots at later times or not at all.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello rcmcd,

          You can replace that if statement and replace this with your custom logic on when you want to reset.
          You can also duplicate the plots if you want the originals to remain, and choose to reset the duplicate plots at later times or not at all.
          This exceeds my limited ability. Can you reference an existing indicator I can review the code?

          Comment


            #6
            Hello rcmcd,

            The help guide has an example of drawing a line.



            I'm not aware of any scripts that have this specific custom logic.

            Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.

            That said, I am happy to answer any questions you may have about NinjaScript if you decide to code this yourself.

            You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Salahinho99, 05-05-2024, 04:13 AM
            7 responses
            55 views
            0 likes
            Last Post Salahinho99  
            Started by knighty6508, 05-10-2024, 01:20 AM
            4 responses
            26 views
            0 likes
            Last Post knighty6508  
            Started by OllieFeraher, 05-09-2024, 11:14 AM
            6 responses
            19 views
            0 likes
            Last Post OllieFeraher  
            Started by PaulMohn, 05-02-2024, 06:59 PM
            2 responses
            44 views
            0 likes
            Last Post PaulMohn  
            Started by ETFVoyageur, Today, 02:10 AM
            0 responses
            19 views
            0 likes
            Last Post ETFVoyageur  
            Working...
            X