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

Get PrioDayOHLC (Red One) and print it on RTH chart

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

    Get PrioDayOHLC (Red One) and print it on RTH chart

    Hello, I'm wondering if it would be possible :

    Let's say I'm on a RTH chart, where price closes at 21:59:59 and opens at 15:30:00, is it possible to draw a line with the prio day price? (I'd say is the PrioDayOHLC the red one) in that chart? if so, it's possible to get the close candlestick price (if it's green then the close price, if it's red then the close price).

    So the thing is to draw a line (horizontal line) on a RTH chart with the PrioDayOHLC (Red one) and then print to console the close price of the last candle (the one at 21:59:59).

    Thanks in advance.
    Last edited by cmtjoancolmenero; 04-25-2024, 04:00 PM.

    #2
    Hello cmtjoancolmenero,

    Thank you for your post.

    You can use Draw.Line, Draw.HorizontalLine, or Draw.VerticalLine to draw a line using the PriorDayOHLC close value.





    You can print out the value of the PriorDayOHLC's closing value.

    // Prints the value of the prior session close
    double value = PriorDayOHLC().PriorClose[0];
    Print("The prior session close value is " + value.ToString());

    Please let us know if you have any further questions.​
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Gaby View Post
      Hello cmtjoancolmenero,

      Thank you for your post.

      You can use Draw.Line, Draw.HorizontalLine, or Draw.VerticalLine to draw a line using the PriorDayOHLC close value.





      You can print out the value of the PriorDayOHLC's closing value.

      // Prints the value of the prior session close
      double value = PriorDayOHLC().PriorClose[0];
      Print("The prior session close value is " + value.ToString());

      Please let us know if you have any further questions.​
      Thanks for the reply, could you please provide me an example to how to get for instance all of the days loaded and then draw a line in that price? In which method do I have to add it?
      Last edited by cmtjoancolmenero; 04-26-2024, 07:31 AM.

      Comment


        #4
        The problem here is if I'm using a RTH chart and I print PriorDayOHLC() it's not the same on an ETH chart, what I'm asking is if it's possible to get the PriorDayOHLC() from ETH chart and then print it to the chart RTH in the same price.

        Comment


          #5
          Hello cmtjoancolmenero,

          I would recommend that you add an additional data series to the chart using the ETH trading hours and use this as the input series for the indicator or strategy.
          You can choose to make these bars hidden from the chart.
          Below is a link to a video demonstration.
          Get started with the NinjaTrader software for FREE: http://ninjatrader.com/GetStartedThis video demonstrates how to plot an indicator based off of one data s...


          Alternatively, you can add a data series in the indicator and specify the TradingHours template and use values from that series as well as supply that series for an indicator call input series.

          AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName)



          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Oh thanks didn't know that!!
            Is it possible to get other indicator from your indicator? I mean, now instead of creating by myself the line I realized that I can use the indicator with the input to my RTH using the input series of ETH and the line is perfect now, the thing is, now with my indicator I want to make a rectangle to that line, is that even possible or I just have to print it by myself?
            Also, how's the loop to loop thought all input series of the chart? For instance if I have 10 days loaded and I want to draw a rectangle draw it on every day.

            Thanks in advance!

            Comment


              #7
              Hello cmtjoancolmenero,

              Your custom indicator can draw a line or rectangle. If you want to draw using ETH information use the ETH data series as the input series.
              Your indicator can call other indicators.

              For example try calling:
              double mySMAValue = SMA(14)[0];
              Print(mySMAValue);

              OnBarUpdate() runs for every bar on the chart.
              Try printing the time of the bar and the bar number:
              Print(Time[0].ToString() + " | CurrentBar: " + CurrentBar.ToString());
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Thanks for the reply ChelseaB,

                What I'm asking is, now on my chart I've added an indicator that gets data from a ETH chart and it's being printed to the RTH one as you showed to me previously with the youtube video, then what I'm asking is can I get for instance the indicator that I've added is PriorDayOHLC, and I just added the "Close" one getting it from the ETH, so what I need now is to draw a rectangle from the last candle of the day (21:59:59) to the line of today.

                So I'm playing with two parts, 1 is to get the last candle of the day and then knowing its close value (depending if its green or red) draw a rectangle from that close bar to the OHLC. Any hints? Ofc if I have 200 days loaded I want to do it on all days.

                Comment


                  #9
                  Hello cmtjoancolmenero,

                  You would add your indicator using the ETH input series and call Draw.Rectangle() at the price called from the PriorDayOHLC() indicator.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Yes but doing this does not iterate thtough all the days loaded, plus I need to get the current OHLC and the last candle of the last day

                    Comment


                      #11
                      Hello cmtjoancolmenero,

                      To confirm, you are printing the time of the bar and bar number and you are not seeing this for the previous days loaded in the Data Series window?

                      Please provide the output text file.

                      On an intra-day chart, the CurrentDayOHL indicator provides the open, high, and low of the current session.


                      Close[0] is the current price of the last updated bar. (Use Calculate.OnPriceChange/.OnEachTick for the current bar to update before the bar closes)
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello ChelseaB,

                        No, the thing is my scenario is :

                        I already have an OHLC from other indicator (CurrentDayOHLC) on my chart, what I want to do is, on my RTH chart, get the last candle (the close price) and from there, draw a rectangle to the current OHLC from the indicator.

                        Can you help me on this?

                        OHLC is in the current day and I need to get the prior day close price candle and get that price and draw a rectangle until my OHLC and this for all the days loaded.

                        Comment


                          #13
                          Hello cmtjoancolmenero,

                          Any series or indicator you want to access from an indicator you have to add to that indicator or call from that indicator.

                          You have to call the CurrentDayOHL() indicator if you want to get values from that indicator.

                          The chart has both RTH and ETH bars on it (only the ETH bars are hidden). Use the ETH data series as the input series for the indicator. Draw a rectangle and it will appear over the bars for the RTH bars visible on the chart.

                          "OHLC is in the current day and I need to get the prior day close price candle and get that price and draw a rectangle until my OHLC and this for all the days loaded."

                          Call Draw.Rectangle() and supply the PriorDayOHLC().PriorClose[0] value as the startY, and supply Close[0] as the endY.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello ChelseaB,

                            We are getting close, but still some concepts missing IMHO.

                            On my chart I have two types of chart, ETH/RTH this works, (i'm wondering if it would be possible to get just the value from a trading hours instead of having multiples charts inside).
                            I could print the PriorDayOHLC().PriorClose[0] in the RTH (using the ETH), the problem is that in code I do call PriorDayOHLC then it won't get the ETH one, I don't know which one is going to take, that's why I'm asking if it would be possible to get PriorDayOHLC().PriorClose[0] from specific trading hours so then I can get the price that is that OHLC and then I just get the Close[0] from the RTH to get the last candle close.

                            I think I'm being clear but if you miss something or missunderstands something please let me know. The thing is easy I guess, I just want to print a rectangle from the OHLC to the Close[0].

                            An example would be :

                            I need to get the value of the PriorDayOHLC().PriorClose[0] ETH value, then get the last candle (I guess with Close[0]) from the RTH but not in the OnBarUpdate because I'll get on each render of the candle a new Close[0] I need the Close[0] from "yesterday".

                            Any hints?

                            Comment


                              #15
                              Hello cmtjoancolmenero,

                              The TradingHours is associated with a specific Price Series.

                              The primary series, a.k.a BarsInProgress 0, a.k.a. BarsArray[0], a.k.a. Closes[0], Opens[0], Volumes[0], etc will the be the chart bars that are used as the Input series for the strategy.
                              Whatever is selected in the Data Series window as the TradingHours for that price series will be the trading hours the strategy or indicator is accessing.
                              You can set the strategy or indicator to use any series that is added to the chart, and that will become the primary series for the script.

                              The script can also call AddDataSeries() and specify the trading hours template. That series is now associated with that trading hours.

                              If the Inputs series for PriorDayOHLC() is using ETH trading hours, then the values such as the PriorClose will be based on ETH trading hours.
                              If the Inputs series for PriorDayOHLC() is using RTH trading hours, then the values such as the PriorClose will be based on RTH trading hours.

                              Set the input series of the indicator to the price series with the ETH trading hours.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by burtoninlondon, 04-28-2024, 12:38 AM
                              3 responses
                              32 views
                              0 likes
                              Last Post burtoninlondon  
                              Started by burtoninlondon, 05-01-2024, 10:13 AM
                              2 responses
                              24 views
                              0 likes
                              Last Post burtoninlondon  
                              Started by LillyMarv, Today, 06:47 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post LillyMarv  
                              Started by Salahinho99, Today, 04:13 AM
                              0 responses
                              16 views
                              0 likes
                              Last Post Salahinho99  
                              Started by junkone, 04-28-2024, 02:19 PM
                              8 responses
                              93 views
                              1 like
                              Last Post brucerobinson  
                              Working...
                              X