Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

'How to' Show/Hide Price Markers Check Box option in Indicator Dialogue Box

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

    'How to' Show/Hide Price Markers Check Box option in Indicator Dialogue Box

    Hello,
    Could someone help me out with how to stop the attached indicator showing Price Markers?
    It is an indicator I have modified, which itself is a modification (by Ninja I believe, CurrentOHLC2) of the stock Ninja CurrentOHL modified to also plot Yesterday's OHLC, plus prior Mid Points with adjustable look-back period.
    I've modified that indicator's prior look-back Mid Points to also plot prior High/Lows & all seems well.
    However, the modified one I adapted doesn't have the Dialogue Box Check Box option to disable Price Markers that the original stock Ninja CurrentOHL and PreviousOHLC have.
    I can't identify where this in any of the code - could someone help me out? (clearly I don't know how to code, just copy and paste).

    Also - as an aside: I asked under Platform Support if such an indicator was already available and/or how to do it and was helpfully provided with some code by ChrisL to add a Data Series to do it - but it was all above my paygrade to use, hence taken this route. I thought I should ask if there if there is anything inherently ill-advised in my solution. It has the further (seemingly apparent) attraction that I currently use many instances of the Current & Previous OHLC indicators for Sessions so can cut the number in half as this does both Current and Previous, FWIW

    Kind regards,
    Attached Files

    #2
    Hello brucerobinson,

    You can control the price markers using the property PaintPriceMarkers. I am not aware of a way to hide that property so I am not certain how that would have happened in your test. In either case you can set a default by using PaintPriceMarkers.



    For your second question I couldn't really comment there as I don't know what your overall goal was. Using multiple instances of the same indicator is fine so that shouldn't be an issue.

    I look forward to being of further assistance.

    Comment


      #3
      Hello Jesse and thanks for your fast response.
      Forgive me if my lack of knowledge is contributing here - however:...

      I'd already looked for any reference to price markers in the code of the stock CurrentOHL and of the modified version I had worked from.
      From your comment "I am not aware of a way to hide that property so I am not certain how that would have happened in your test" - I have just opened the stock Ninja CurrentOHL.cs thinking I must have somehow failed to find it when I looked line-by-line through the code prior to posting here, and also for clues as to where I would place it in my modification. Upon running Find in notepad on Paintpricemarkers, pricemarkers etc in CurrentOHL nothing found? You say you don't understand as it can't be hidden, I say I and Notepad Find can't find it. Yet it displays in the CurrentOHL Indicator, the code of which I am searching. So something is not adding up....

      On the second point - my overall goal was simply to add the prior prior (i.e. day before Previous) day's high and low lines, in the same manner the CurrentOHL draws Current and PreviousOHLC draws previous. Nothing more.

      Kind regards,

      Edit: Today Price Marker option available. On reflection, I installed and compiled the modified indicator 'on the fly' and not restarted Ninja. Schoolboy error, not used to it. Perhaps that was something to do with it.

      Still don't understand why I can't 'Find' PriceMarkers in any of the code - but I guess I don't need to. Probably another schoolboy error.
      Apologies & thanks for the assistance.

      Kind regards,
      Last edited by brucerobinson; 08-29-2020, 09:51 AM. Reason: Solved

      Comment


        #4
        Everything working as expected.
        However, unable to locate PaintPriceMarkers in the code and its Default is True - I never want Price Markers, but being unable to find the code cannot change it to False
        Ditto with Display in Data Box - can't find code relating to this and the Default is True. I never want data in the Data Box (and am fairly certain 1) it uses resources to do so and 2) Data being displayed in the Data Box has been the source of 'issues' in development in days of yore).

        Could someone kindly point me to how/where to make both these Settings False by default. It will be unnecessarily annoying having to manually un-check these boxes when I apply this indicator to each of my charts.

        Thanks
        Kind regards,

        Comment


          #5
          Hello brucerobinson,


          From your comment "I am not aware of a way to hide that property so I am not certain how that would have happened in your test" - I have just opened the stock Ninja CurrentOHL.cs thinking I must have somehow failed to find it when I looked line-by-line through the code prior to posting here, and also for clues as to where I would place it in my modification. Upon running Find in notepad on Paintpricemarkers, pricemarkers etc in CurrentOHL nothing found? You say you don't understand as it can't be hidden, I say I and Notepad Find can't find it. Yet it displays in the CurrentOHL Indicator, the code of which I am searching. So something is not adding up....
          My comment was saying that I am not certain how it would be hidden from the user interface, it would not be expected to not see this listed in the UI when applying an indicator with a plot. That code is not in the file its self but is shown in the user interface as a checkbox you can click. If you want to manually control this in the code, you would use the code shown in the help guide sample that I linked. You would have to add that code yourself to control it differently or with a specific value from code.

          I would suggest to avoid opening files in notepad, you can instead use the NinjaScript editor to view the code of the files you have imported. To edit a system indicator you would have to make a duplicate of it by doing Right click -> Save as in the file in the NinjaScript editor.

          Still don't understand why I can't 'Find' PriceMarkers in any of the code - but I guess I don't need to. Probably another schoolboy error.
          Apologies & thanks for the assistance.
          With the added details it sounds like you will not need to, not for this use case. If you wanted to control this in your own development you could use the code I had linked to.


          However, unable to locate PaintPriceMarkers in the code and its Default is True - I never want Price Markers, but being unable to find the code cannot change it to False
          Ditto with Display in Data Box - can't find code relating to this and the Default is True. I never want data in the Data Box (and am fairly certain 1) it uses resources to do so and 2) Data being displayed in the Data Box has been the source of 'issues' in development in days of yore).
          These are not in the script because it uses the default which is true. These are inherited indicator properties that all indicators have, it does not need to be set in State.SetDefaults in the code but it can be to override the default of true.

          If you don't want to re code the indicator and just want to set this, when you apply the indicator just set Paint Price Markers to false and also display in data box. You can then set that as the default using the indicators template. There is no code change needed.

          If you actually want to change this in the code and its a stock indicator you need to duplicate the indicator first and then edit the copy. You can right click in the code inside the NinjaScript editor -> Save as and give it a new name, You can then add the code as shown in the help guide to set a default value.


          I look forward to being of further assistance.

          Comment


            #6
            Hello Jesse and many thanks. Clear and understood.
            Checkboxes - saving to Template is perfectly adequate for my humble needs. Unnecessarily ended up down a coding rabbit-hole.
            The only thing that isn't working is the Closes, for which I suspect I'll need to copy code over from the stock OHL/PriorOHL indicators.
            The main aim here was to be able to plot range High/Lows farther back than yesterday, and that is working, as is everything else except Closes, so I'll have a solution one way or another, eventually.
            Kind regards,
            Bruce

            Comment


              #7
              Hello,
              Could someone kindly look at and tell me why the attached CurrentOHLC3Full does not plot previous days’ Open and Close?

              The attached CurrentOHLC2 from which ‘…..OHLC3Full’ is derived “/// Plots the open, high, low, midpoint and close price values for the current session, yesterdays midpoint and a priorday midpoint sessions.”

              I would like it to plot yesterday’s and a priorday’s Open, High, Low and Close also.
              I have succeeded in modifying it to plot yesterday’s and a priorday’s High and Low, but (using the same approach) cannot get it to plot the Open and Close of either yesterday/a prior day.

              I hope the modifications I have made will be readily apparent, which are to include GetDayBar(). to include () .Open/Close in addition to GetDayBar().High/Low used for calculating mid-points (having read the Help, that these are valid values to employ) for yesterday and priorday as follows:…...

              // Check to ensure that sufficient intraday data was supplied for yesterdays day Max & Min HL values
              if(Bars.GetDayBar(1) != null){
              yesterdaysDayHigh = Bars.GetDayBar(1).High;
              yesterdaysDayLow = Bars.GetDayBar(1).Low;
              }
              yesterdaysMidPoint = (yesterdaysDayHigh + yesterdaysDayLow) /2 ;

              // Check to ensure that sufficient intraday data was supplied for prior day Max & Min HL values
              if(Bars.GetDayBar(PriorDaysLookBack) != null){
              priorDayHigh = Bars.GetDayBar(PriorDaysLookBack).High;
              priorDayLow = Bars.GetDayBar(PriorDaysLookBack).Low;
              }
              priorMidPoint = (priorDayHigh + priorDayLow) /2 ;

              modified as follows: (Lines 147-159)

              // Check to ensure that sufficient intraday data was supplied for yesterdays day Max & Min HL and get Open/Close values
              if(Bars.GetDayBar(1) != null){
              yesterdaysDayHigh = Bars.GetDayBar(1).Open;
              yesterdaysDayHigh = Bars.GetDayBar(1).High;
              yesterdaysDayLow = Bars.GetDayBar(1).Low;
              yesterdaysDayHigh = Bars.GetDayBar(1).Close;
              }
              yesterdaysMidPoint = (yesterdaysDayHigh + yesterdaysDayLow) /2 ;

              // Check to ensure that sufficient intraday data was supplied for prior day Max & Min HL and get Open/Close values
              if(Bars.GetDayBar(PriorDaysLookBack) != null){1
              priorDayHigh = Bars.GetDayBar(PriorDaysLookBack).Open;
              priorDayHigh = Bars.GetDayBar(PriorDaysLookBack).High;
              priorDayLow = Bars.GetDayBar(PriorDaysLookBack).Low;
              priorDa yHigh = Bars.GetDayBar(PriorDaysLookBack).Close;
              }
              priorMidPoint = (priorDayHigh + priorDayLow) /2 ;

              ...added in all the .SetDefaults ShowYesterdaysDayOpen/HLC (Lines 68-76), AddPlots (Lines 86-94) etc…..

              I notice in the original CurrentOHLC2, for the Show(Current)Open/High/Low/Mid-points the format…..
              if (ShowOpen){
              if (!PlotCurrentValue || !sameDay)
              CurrentOpen[0] = currentOpen;
              else
              for (int idx = 0; idx < CurrentBar - 1; idx++)
              CurrentOpen[idx] = currentOpen;
              }
              .is used,
              and works when modified for yesterday and prior day High and Low….
              if (ShowYesterdaysDayHigh){
              if (!PlotCurrentValue || yesterdaysDayHigh != YesterdaysDayHigh[0])
              YesterdaysDayHigh[0] = yesterdaysDayHigh;
              else
              for (int idx = 0; idx < CurrentBar - 1; idx++)
              YesterdaysDayHigh[idx] = yesterdaysDayHigh;
              }
              ..but not the same adjustment for the Open, does not work:
              if (ShowYesterdaysDayOpen){
              if (!PlotCurrentValue || yesterdaysDayOpen != YesterdaysDayOpen[0])
              YesterdaysDayOpen[0] = yesterdaysDayOpen;
              else
              for (int idx = 0; idx < CurrentBar - 1; idx++)
              YesterdaysDayOpen[idx] = yesterdaysDayOpen;
              }
              and that in the original (Current)Close uses the different format….
              if (ShowClose){
              CurrentClose[0] = currentClose;


              ….which is also different (outside the if {} Lines 113-122) in the original. So perhaps for yesterday and prior day Close I should be using format….
              if (ShowYesterdaysDayClose){
              YesterdaysDayClose[0] = yesterdaysDayClose;

              It all works for the yesterday and prior day High and Low plots, but not for their Open and Close counterparts using the same approach.

              Kind regards,


              Attached Files

              Comment


                #8
                Hello brucerobinson,

                Thanks for your reply.

                We will leave this thread open for any community member that would like to assist you with your development project.

                Please note that as a small team we cannot provide debugging services.

                We recommend using Print statements to help debug the issues. By using print statements, you can print out for example when an if statement is being hit or you can print out the values of the conditions that make up the if statement. Here is a link to our debugging tips: https://ninjatrader.com/support/help...script_cod.htm

                As you have identified what is not plotting, those areas of the code that calculate that plot should be examined with print statements first. With no plot in evidence then the statement that is assigning the value to the plot is not being hit or is being provided with an incorrect value. For example, your lines may be plotting at a value of 0 which you would not see if you do not change the scaling of your chart. The Print statements will help identify that as well if you also print out the value of the plot.

                While debugging can be overwhelming at first, if you focus on one plot and can resolve it, likely it will lead to the resolution of the other plots issues.

                Alternatively, if you would like your indicator created for you, we can provide a link to 3rd party developers in the Ninjatrader ecosystem.

                Comment


                  #9
                  Hello brucerobinson,

                  After taking a quick look at your code and re-reading your post, it looks like the code is assigning incorrect values to the variables that are then used to plot.

                  Here is an example: yesterdaysDayHigh = Bars.GetDayBar(1).Open;

                  You should change that to yesterdaysDayOpen = Bars.GetDayBar(1).Open;

                  Comment


                    #10
                    Hello #PaulH and thank you so much for revisiting and identifying the schoolboy copy and paste/failed to edit error. Code blindness/fatigue. Corrected and working perfectly.
                    Satisfying to have got all of it otherwise perfect, and the work not gone to waste.

                    If I may trouble you with a related question, now this is working:
                    I was advised by ChrisL that I might use the following to get the prior day data:

                    "You could do something like use a Daily series and access the daily values 2 bars ago E.g.:

                    Code:
                    else if (State == State.Configure) { AddDataSeries(BarsPeriodType.Day, 1); } double open, high, low, close; protected override void OnBarUpdate() { if(BarsInProgress == 1) { if(CurrentBars[1] < 2) return; open = Opens[1][2]; high = Highs[1][2]; low = Lows[1][2]; close = Closes[1][2]; } }
                    "
                    and by Jim:
                    "It may be more CPU intensive to have the high/low calculated from intraday data and use variables to store the session before last's OHLC than to simply use the added data series. Using the added data series would be easier and would not be as resource intensive when the script is running."

                    Does this mean that ideally I should consider changing the way the PriorDay gets its data to the method proposed by ChrisL? I have found a couple of appropriate code examples to assist me if I should consider attempting this.

                    I am delighted to have successfully made the necessary modifications - this meets all my needs and if it causes no performance issues 'as is' I am satisfied - achieving this will give me the 'Prior Prior Day' I sought with the added functionality of variable lookback period, and Prior and Current DayOHLC all in one. Thus able to remove stock Prior and Current OHLC, halving the number of these indicators. Thank you for spotting the mistake.

                    Kind regards,

                    Comment


                      #11
                      Hello brucerobinson,

                      Thanks for your reply.

                      Glad that worked out.

                      As you get into coding you would do well to learn to debug your coding as it may not always be a copy/paste issue!

                      The method you are using GetDayBar() to pull the previous days data has the following help guide note: "The bar object returned is a "virtual bar" built from the underlying bar series and its configured session. Since the bar object is virtual, its property values are calculated based on session definitions contained in the trading day only. The returned bar object does NOT necessarily represent the actual day. For accessing a true "Daily" bar, please see use AddDataSeries() and use the BarsPeriodType.Day as the bars period. "

                      So indeed the method does evaluate the previous (or specified) day's intraday data to build the virtual bar. It would be more CPU use than adding a daily bar series and pulling the previous (or specified) day bar values.

                      However, with what you have you can reduce the CPU use by only pulling the data once per session rather than on every bar as is done now. The previous days' values would not change so why pull them on every bar of the current session? The same would be true if you added daily bars, no need to pull them on every bar of the current session.

                      A notable consideration of using daily bars, assuming you are using Futures instruments, these will be fixed ETH based bars that you cannot adjust. Additionally, depending on your provider, daily bars close price is actually adjusted to the daily settlement price value and not the "last price" of the ETH session. This may or may not be meaningful to you but certainly would be a difference.

                      By using GetDayBar() the data will be based on the charts session setting which may or may not be critical to you. Using day bars you would not be able to pull less than ETH data from those bars.

                      If you want to add daily bars, I highly recommend that you become familiar with the concepts of Multi-time Frame coding and the programming considerations needed. Here is a link to that information: https://ninjatrader.com/support/help...nstruments.htm

                      Comment


                        #12
                        Hello Paul and many thanks.
                        "As you get into coding you would do well to learn to debug your coding as it may not always be a copy/paste issue!" - hoping not to do any more after this ;-)

                        I do however always investigate as fully as I can comprehend before asking for Support.
                        It was as a result, that prompted the questions I asked i.e. having pieced together ChrisL/Jim's comments on cpu use and the Help on building a bar you've cited etc - and the issue of Sessions (as I could not easily determine if adding a Daily bar series was ETH/RTH or user defined but I got the impression it was one, perhaps the other, but not any/all from Help on Add Daily Bar series) that led me to ask....

                        I use RTH/ETH/Overnight Sessions from Trading Hours templates & multiple data series - so yes, it is a notable consideration indeed.
                        Simply put - if I want Sessions' OHLC I have to go GetDayBar to build the bar virtually - cpu intensive but far less so if poll prior day's data once/Session.
                        (Yes I'm familiar with Settlement Close, issue, thanks for noting (I used to use Pivots)).


                        "However, with what you have you can reduce the CPU use by only pulling the data once per session rather than on every bar as is done now. The previous days' values would not change so why pull them on every bar of the current session? The same would be true if you added daily bars, no need to pull them on every bar of the current session."
                        Absolutely - and my next question if was as I suspected. How to....At the moment all is updated 'OnPriceChange' of current Session. Only reason is I didn't know if next iteration was Add Daily Bars and if not, how to poll previous Session data only once. Any resources you can point me to on how to only poll that data once....

                        I will of course investigate myself.

                        Thanks

                        Comment


                          #13
                          Hello brucerobinson,

                          Thanks for your reply.

                          I'm not sure why you would need to use OnEachTick or OnPriceChange processing for a flat line (other than the current close line but do you really need that?).

                          You are using a plotsyle of HLine which means it will draw a horizontal line so it will draw automatically to the right edge of the right edge bar.

                          So if you switch to Calculate.OnBarClose it would be less of a running CPU burden.

                          You can use the systems Bars.IsFirstBarOfSession as a trigger to pull the prior days' data. so that would only happen once per session and as the values don't change there would be less calculation effort.

                          For example:

                          if (Bars.IsFirstBarOfSession) // on the first bar of data , get the prior days information
                          {

                          if(Bars.GetDayBar(1) != null)
                          {
                          yesterdaysDayOpen = Bars.GetDayBar(1).Open;
                          yesterdaysDayHigh = Bars.GetDayBar(1).High;
                          yesterdaysDayLow = Bars.GetDayBar(1).Low;
                          yesterdaysDayClose = Bars.GetDayBar(1).Close;
                          yesterdaysMidPoint = (yesterdaysDayHigh + yesterdaysDayLow) /2 ;
                          }


                          if(Bars.GetDayBar(PriorDaysLookBack) != null)
                          {
                          priorDayOpen = Bars.GetDayBar(PriorDaysLookBack).Open;
                          priorDayHigh = Bars.GetDayBar(PriorDaysLookBack).High;
                          priorDayLow = Bars.GetDayBar(PriorDaysLookBack).Low;
                          priorDayClose = Bars.GetDayBar(PriorDaysLookBack).Close;
                          priorMidPoint = (priorDayHigh + priorDayLow) /2 ;
                          }

                          }


                          Reference: https://ninjatrader.com/support/help...rofsession.htm

                          Comment


                            #14
                            Hello Paul and many thanks (again).
                            "I'm not sure why you would need to use OnEachTick or OnPriceChange processing for a flat line (other than the current close line but do you really need that?)." - indeed (doh on my part) and no I don't use current close, it was already present in the code I plagiarised, never seen Close in any CurrentOHL before.

                            Thanks for the code snippet. I've stumbled across similar now I think about it, but despite that it would have taken a copy/paster forever to get there. That will be job done. Marvellous. Satisfying & productive little excursion into Ninjascript.

                            Once functioning, I will likely look to tidy to the minimum fit for my purpose i.e. I don't use/need current close nor mid-points which is another unnecessary cpu calculation, legacy from the original. Albeit maybe then rather moot when polling/calculating only once, but I have a preference for the most elegant lightest solution.

                            Many thanks once again for your attention and excellent support - I appreciate it.

                            Kind regards,

                            Comment


                              #15
                              I'd noticed this took a while 'calculating' after F5 compared with stock PriorOHLC although no perceptible change whilst plotting. However I use many instances of these, so was keen it should not bring things to a standstill once applied universally.
                              With the modification, refresh is now almost instantaneous, and applied to all charts no perceptible impact on performance (albeit quiet hours, but no reason to expect so).
                              Project completed.
                              Excellent

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by CarlTrading, 03-31-2026, 09:41 PM
                              1 response
                              81 views
                              1 like
                              Last Post NinjaTrader_ChelseaB  
                              Started by CarlTrading, 04-01-2026, 02:41 AM
                              0 responses
                              42 views
                              0 likes
                              Last Post CarlTrading  
                              Started by CaptainJack, 03-31-2026, 11:44 PM
                              0 responses
                              64 views
                              2 likes
                              Last Post CaptainJack  
                              Started by CarlTrading, 03-30-2026, 11:51 AM
                              0 responses
                              68 views
                              0 likes
                              Last Post CarlTrading  
                              Started by CarlTrading, 03-30-2026, 11:48 AM
                              0 responses
                              55 views
                              0 likes
                              Last Post CarlTrading  
                              Working...
                              X