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

Is this the correct co ordinate for the low of the current bar?

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

    Is this the correct co ordinate for the low of the current bar?

    I am trying to get an indicator to plot text at the low of the current bar
    I have used the following code successfully in NT7 but want to check if something is different in NT8?

    Code:
        int lowplace     =  (int)(ChartPanel.Y + chartScale.Height) - ((int) ((((Low.GetValueAt(ChartBars.ToIndex ))  - chartScale.MinValue) / chartScale.MaxMinusMin) * chartScale.Height)) - 1;
    I ask because this code works on one machine with NT8 but not 2 others??

    So first I just want to check that the code is basically correct.


    #2
    Hello Mindset,
    If your requirement is only to place text at current bar's low, it can be done easily with Low[0]. I don't know why exactly you're doing this calculation. You can use it in Draw.Text(). Hope it helps!

    Comment


      #3
      Hello Mindset,

      Draw.Text() would be the easiest way to draw text at the Low[0] of the of the bar.


      If you are wanting to custom render the text, you can use ChartControl.GetXByBarIndex() to get the x value of a bar, and ChartScale.GetYByValue() to get a y from a price.


      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        I think the best way is to show you what I am up against.
        As you can see in the first instance - rectangle and text is perfectly placed.
        In the second it isn't and it doesn't scale when you move the chart axis.
        Same code (as in the first post) different machines.


        Click image for larger version  Name:	working.JPG Views:	0 Size:	45.4 KB ID:	1125971

        Click image for larger version

Name:	not working.PNG
Views:	229
Size:	370.1 KB
ID:	1125973
        Last edited by Mindset; 11-02-2020, 11:23 PM.

        Comment


          #5
          Hello Mindset,
          You're using rectangle & text so you can definitely use Draw.Rectangle() & Draw.Text() & use Low[0] for current bar low. I can see there is a difference in font size in both machines, you can check it by right click on chart -> properties -> font. When you use Draw.Text() be sure to define the font in it so the font size is not altered & you don't see any discrepancies. I am sure with these built-in functions your task can be achieved & you won't get any scaling issues. Just in case you still face issues do let me know.

          Comment


            #6
            Hello Mindset,

            Is the rectangle drawn with Draw.Rectangle?

            Is the indicator applied to the same Scale Justification in the indicator parameters?

            If the object is drawn with Draw.Rectangle() using the Low[0] of the bar, I would expect the draw method object to scroll with the chart.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              HI Chelsea

              Its currently drawn with RenderTarget(rect,AreaBrushDx,TempWidth);
              it actually uses Low[1].
              I should add I paid money to have this converted as this was an original indicator I posted in NT7 back in 2011.
              and it works fine on 1 machine and it works fine for the guy who converted it - so it's a weird one. Is it code or is it platform or something else.

              Currently it's useless and that is frustrating.
              I understand a little about code but not really enough ( Im a cut and paste trial and error guy) - but in the past I have always got there.
              Just not this time.
              Support s going to connect to machine and have a look tomorrow so maybe they will see something.

              Comment


                #8
                Hello Mindset,

                If this is in OnRender() the behavior is different.

                You should be using Bars.GetLow() or TriggerCustomEvent to use bar data in a non-data-driven method.



                If you want the object to scroll with the chart, you have to write custom logic to do that. It won't do it by itself.

                Below is a link to an example.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Ok well that took a complete rewrite of the code but at least it works now. :-)
                  Get YBy Value was an important contributor plus also a little bit of out of the box thinking.
                  (Getting the rectangle to sit correctly took forever and doesn't appear to be something you can do using Draw.
                  Rectangle as that is based around the centre of the bar.
                  Last edited by Mindset; 11-06-2020, 04:17 AM.

                  Comment


                    #10
                    Lol this isn't simple this indicator of mine now completely screws up Advanced Risk Reward indicator.
                    My best guess is the ONRender function - is there something I should do?
                    I have already put in
                    base(OnRender(chartControl,chartScale);


                    Edit here's a video - is it me or is this indicator not behaving correctly? It doesn't seem to retain the user input lines.
                    if you press Hide/Show the lines go to their original settings ( which are always wrong because they are approximations of mouse clicks ( I don't know why that should be either?) not the ones where say you moved them too.
                    I made a video but apparenlty you can't upload those.
                    Heres a quick couple of screenshots instead Click image for larger version

Name:	2020-11-06_19-07-27.png
Views:	567
Size:	84.1 KB
ID:	1126448
                    Click image for larger version

Name:	2020-11-06_19-12-10.png
Views:	522
Size:	64.6 KB
ID:	1126449Click image for larger version

Name:	2020-11-06_19-18-13.png
Views:	512
Size:	703.5 KB
ID:	1126450Click image for larger version

Name:	2020-11-06_19-12-10.png
Views:	518
Size:	64.6 KB
ID:	1126451
                    Last edited by Mindset; 11-06-2020, 05:26 AM.

                    Comment


                      #11
                      Hello Mindset,

                      This is Jim responding on behalf of Chelsea who is out of the office at this time.

                      I would suggest continuing to work on your indicator outside the context of using Advanced Risk Reward. If you are able to identify something specific that affects Advanced Risk Reward, I would like to take a look. I converted the indicator from the NinjaTrader 7 version so functionality should match there, but if there is an existing issue that is easy to understand and correct I would like to have a look. I suggest commenting out sections of code to get to specific modifications that are affecting this indicator.

                      Please email me at platformsupport [at] ninjatrader [dot] com with a small test script that can reproduce issues with Advanced Risk Reward. Please include the text "Attn Jim 2813839 Advanced Risk Reward." I only converted the indicator and by no means an expert of its functionality, so please be explicit with steps needed to reproduce issues.

                      We look forward to assisting.
                      JimNinjaTrader Customer Service

                      Comment


                        #12
                        thanks Jim
                        However the behaviour I show in the snapshots is just your Indicator on it's own - it doesnt seem to retain the new lines if you move them and then hide/show? Or is it my platform?
                        With regards to my own indicator - its not worth the time and effort to work it out - I am not a coder so these things take forever. Its just a shame as I really like your indicator!
                        I will give it a go - as you say - commenting out sections to see if/where the problem is.
                        Just wanted to give you a heads up about the issue
                        Edit - what a dumbass I am! There is a button called save changes and guess what that does doh!
                        Last edited by Mindset; 11-06-2020, 11:45 PM.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by fx.practic, 10-15-2013, 12:53 AM
                        5 responses
                        5,404 views
                        0 likes
                        Last Post Bidder
                        by Bidder
                         
                        Started by Shai Samuel, 07-02-2022, 02:46 PM
                        4 responses
                        95 views
                        0 likes
                        Last Post Bidder
                        by Bidder
                         
                        Started by DJ888, Yesterday, 10:57 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        Started by MacDad, 02-25-2024, 11:48 PM
                        7 responses
                        159 views
                        0 likes
                        Last Post loganjarosz123  
                        Started by Belfortbucks, Yesterday, 09:29 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post Belfortbucks  
                        Working...
                        X