• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MTF Smooth Plot line

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

    MTF Smooth Plot line

    I have an indicator (Panel 2) that loads a second series. A plot within that indicator plots out a line driven from the data I have coming from the second series. However, due to it being from a higher time frame on the primary timeframe, the line is jagged rather than smooth. I know this is because there are a number of primary bars that make up the one bar of the higher time frame and until the secondary bar is complete the last result will plot a horizontal line.
    Is there an eloquent way to have that jagged secondary plot smooth out?

    Thank you in advance.



    The lower lines (red and cyan) are jagged. These I'd like to smooth out.

    #2
    Hello fling_wing,

    I don't know of a good way without misrepresenting the data.

    With the smaller time frame as the bar is building it won't know what the price of the higher time frame will be in the future. You can always loop backwards through the smaller time frame bars and set plot values historically and smooth them out, but this would take extra processing. (But it is an option)

    Does the indicator only run in real-time?

    Does TickReplay allow the indicator to build intra-bar and produce different values through the higher time frame with Calculate set to On price change or On each tick?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello fling_wing,

      I don't know of a good way without misrepresenting the data.

      With the smaller time frame as the bar is building it won't know what the price of the higher time frame will be in the future. You can always loop backwards through the smaller time frame bars and set plot values historically and smooth them out, but this would take extra processing. (But it is an option)

      Does the indicator only run in real-time?

      Does TickReplay allow the indicator to build intra-bar and produce different values through the higher time frame with Calculate set to On price change or On each tick?
      Thanks for the reply, Chelsea.

      In retrospect I should have addressed what I'm trying to ultimately achieve with my request.
      I have achieved the result I'm after using Draw.Line instead of Plot by using a condition capture. A line is then drawn from the start of the condition until the end and then repeat. This then produces a smooth line as the far right line isn't drawn until the second time-frame bar is finished and so on.
      The downside to this is that firstly I'm using a Draw object which is resource heavy and secondly, there are 1000's if not 10,000's of little lines drawn to make up the line. I notice that when I open a chart up to expand a lengthy period of time NT8 starts to get slow and then crashes. All is well when only a relatively small time period is displayed.
      So what I'm trying to achieve is a less resource hungry code than what I have.

      With reference to your first paragraph- the extra processing negates that option.
      The indicator runs both in real time and historically.
      I have TickReplay off. Everything is set to Calculate On Close.

      I'm presuming there is no way to stop a Plot from printing until that second series bar is complete like I've done with the Draw.Line? I've tried my condition code with the plot but nothing prints. I'm guessing that the Plot needs to start and keep running on each primary T/F bar, not stop start like the Draw.Line does?

      I can feed the data from the second time-frame into the primary time frame. Lets say I have a 1000 tick primary chart. The second time frame is 3000 tick. For each second time-frame bar there are 3 primary time-frame bars.
      The condition capture code I'm using looks to see if the data on the previous primary T/F bar is the same as the current, if it is the next line isn't drawn until the previous bar data is different. The lines are then drawn from each data point.

      An interesting observation however. If a second DataSeries is added to the chart in the chart settings and then the indicator told to utilise the data input from that second DataSeries, the line is smooth. It looks like NT8 is not processing the next Plot until the second series bar is complete. So if NT can do this natively, surely there is a way to do it with code?

      The attached image is of the Draw.Line code I have. You can see the lines are smooth but is made up of 1000's of little lines.
      Attached Files

      Comment


        #4
        Hello fling_wing,

        Plots in a script are synchronized to the primary series.

        If you manually add a series to a chart on another panel, and use this as an input source for an indicator, that series is the primary series for that indicator.
        There are slots created on the chart for each bar of that primary series in a secondary panel.

        Added series to an indicator do not create bar slots on the chart. The plot will need a value for each primary bar slot on the chart.


        If you want to use a hidden series as the primary input series for an indcator, that is a choice.
        Below is a link to a video that demonstrates.
        https://youtu.be/XRGxiO3XW-k


        I was not able to confirm, did you test using TickReplay with Calculate 'On each price change' or 'On each tick' and this did not give you the results you wanted?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello fling_wing,

          Plots in a script are synchronized to the primary series.

          If you manually add a series to a chart on another panel, and use this as an input source for an indicator, that series is the primary series for that indicator.
          There are slots created on the chart for each bar of that primary series in a secondary panel.

          Added series to an indicator do not create bar slots on the chart. The plot will need a value for each primary bar slot on the chart.


          If you want to use a hidden series as the primary input series for an indcator, that is a choice.
          Below is a link to a video that demonstrates.
          https://youtu.be/XRGxiO3XW-k


          I was not able to confirm, did you test using TickReplay with Calculate 'On each price change' or 'On each tick' and this did not give you the results you wanted?

          I have tested using TickReplay with Calc on price and each tick- no, not what I'm after unfortunately.

          Thanks for the YouTube vid. I'm pretty comfortable with this, however the indicator is a MTF indicator with 2 different data series within it plotting two different data sources. So with the hidden series concept, I could only drive one higher time frame within that indicator panel.

          Looks like the smooth plot on MTF indicators is a no go. Shame, perhaps it's something you can put through to the developers?

          Thanks Chelsea,

          Comment


            #6
            Hello fling_wing,

            To confirm, your indicator is set with Calculate .OnEachTick with TickReplay enabled on the chart and this indicator does not change values intra-bar?

            If this indicator is on a chart, in real-time with Calculate .OnEachTick do values change inra-bar?

            Was the script designed to only updated when IsFirstTickOfBar is true?


            What are you wanting submitted as a feature request?

            Are you wanting NinjaTrader to display plot values that are not set in the code?

            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello fling_wing,

              To confirm, your indicator is set with Calculate .OnEachTick with TickReplay enabled on the chart and this indicator does not change values intra-bar?

              If this indicator is on a chart, in real-time with Calculate .OnEachTick do values change inra-bar?

              Was the script designed to only updated when IsFirstTickOfBar is true?


              What are you wanting submitted as a feature request?

              Are you wanting NinjaTrader to display plot values that are not set in the code?
              Hi,

              Yes, I've tried it with Calculate.OnEachTick with Tick Replay enabled. However, because the data is is coming from another indicator that processes on each bar, the data can only ever be fed once a bar is complete. Intra bar movements are non existent.

              I've never utilised IsFirstTickOfBar so no, it's not.

              Feature request. To be able to process Plots in a MTF environment such as my case. Be able to halt the plot printing on each primary bar but only on BarInProgress == 1 or BarsArray[?] for instance.

              Not sure what you mean for the last one. My Plot values are dynamic.

              Comment


                #8
                Hello fling_wing,

                Thank you for your patience.

                I put together an example of how to avoid the plateaus in your plots from larger series in your script. The file is attached and you can download it and import through Tools > Import > NinjaScript Add On.

                This file utilizes OnRender() and RenderTarget.DrawGeometry in order to take the secondary series closes and plot them on the chart without a plateau effect.

                So instead of seeing something like the following:
                Click image for larger version

Name:	plateau.png
Views:	1
Size:	40.2 KB
ID:	1045095

                You would see this instead:
                Click image for larger version

Name:	noplateau.png
Views:	1
Size:	48.0 KB
ID:	1045096

                You can find information on custom rendering at the following link: https://ninjatrader.com/support/help..._rendering.htm

                Please let me know if you have any questions.
                Attached Files
                Patrick H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_PatrickH View Post
                  Hello fling_wing,

                  Thank you for your patience.

                  I put together an example of how to avoid the plateaus in your plots from larger series in your script. The file is attached and you can download it and import through Tools > Import > NinjaScript Add On.

                  This file utilizes OnRender() and RenderTarget.DrawGeometry in order to take the secondary series closes and plot them on the chart without a plateau effect.

                  So instead of seeing something like the following:
                  Click image for larger version

Name:	plateau.png
Views:	1
Size:	40.2 KB
ID:	1045095

                  You would see this instead:
                  Click image for larger version

Name:	noplateau.png
Views:	1
Size:	48.0 KB
ID:	1045096

                  You can find information on custom rendering at the following link: https://ninjatrader.com/support/help..._rendering.htm

                  Please let me know if you have any questions.
                  Hi Patrick,

                  Firstly, thank you for putting the time in to look at this for me. I have to say though, I've had a look at the indicator and can honestly say, it's on another level from my script knowledge!
                  I can follow as far as the OnBarUpdate Value[0] = Closes[1][0]; but after that, I'm lost. Well, not entirely true, I can follow it- I just don't have the knowledge to 'work' it.

                  However, I have had a go at implementing this script into my indictor but have met some challenges.
                  I've attached an image of what I'm seeing.
                  My indicator is grabbing data from another indicator (higher data series) to paint the line. I swapped out your Closes[1][0]; with my data variable and you can see the bottom line in the image I attached paints more or less the same as the top line which is the indicator taking data straight from an added data series in the NT8 settings for that chart. I'm using the top indicator to check the lower one we are working on.
                  If you look at the indicator we are working on (lower panel) you can see that it plots most of the points but then will skip a number of them and join up with some other point. I've selected the plot with my mouse so you can see the point circles do actually marry up with the top indicator but the plot line misses a large number of them.
                  I've tried for hours to sort this but I fear the issue lies within the rendering code of which I'm not familiar with.
                  Have you any ideas as to why our indicator is skipping joining up some of the plot points?

                  Comment


                    #10
                    Hi again Patrick,
                    A little hasty on my part. I have managed to change the code to make the plot print to each point. I changed the lastvalue to -100 (was 0) and within the if statement for lastvalue (to print the line) to > -100 (was >= 0). As my data points run into the minus figures, the line wouldn't print anything below 0.

                    Second plan now. There are two plots for each data series. The example you provided captures only one. How would I add a second plot to that particular data series which plots a second source of data?
                    Second to that, as this is a MTF indicator, would I need to double up the custom rendering script for each plot and data series or is there a more eloquent way to achieve MTF/multi data series plots with the example you provided?
                    Last edited by fling_wing; 01-13-2019, 03:38 PM.

                    Comment


                      #11
                      Hello fling_wing,

                      Thank you for your response.

                      You would need to duplicate the logic in place in OnRender() for the PathGeometry and GeometrySink in order to set another plot.

                      Please let me know if you have any questions.
                      Patrick H.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi Patrick,

                        Thanks for the assistance. I've got the multiple plots plotting and different plots from different timeframes all within the same indicator.
                        I was struggling to get the indicator to work but changed the Value[0] = Close[0] etc to Values[0][0] = Close[0] and Values[1][0] = Close[0) etc and then it worked.

                        Thank you so much for yours and Chelsea's help. Great service provided by you both.

                        I've attached an image of the finished product....smoooth!! Cheers

                        Click image for larger version

Name:	Screen Shot 2019-01-16 at 10.48.12 pm.png
Views:	1
Size:	23.2 KB
ID:	1045429

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by ralett, Today, 11:44 AM
                        1 response
                        12 views
                        0 likes
                        Last Post NinjaTrader_Spencer  
                        Started by DMDINAZ, Today, 11:03 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by sukhob, Today, 10:14 AM
                        4 responses
                        10 views
                        0 likes
                        Last Post sukhob
                        by sukhob
                         
                        Started by beaacontreras, Today, 09:27 AM
                        1 response
                        20 views
                        0 likes
                        Last Post NinjaTrader_PatrickG  
                        Started by fxSol, 03-17-2019, 04:17 AM
                        5 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_ChristopherS  
                        Working...
                        X