Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Display price and time dimensions for lines and rectangles?

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

    #16
    Originally posted by mishhh View Post
    So the core question (it seems it's because my lack of understanding c# and ninjascript):

    After creating some object, how will I know the object has been changed? resized?
    I saw the interface IDrawObject, (methods and properties).

    Though, I cannot see how I will know when the object is changed by user.
    Can I treat this event through ninjascript functions?
    Or will I treat this event though c#?
    1. You would use a structure to store the property data of interest at the time of creation of the drawobject.
    2. On each OnBarUpdate(), check if the current property data has changed.
    3. Do what you want if the data has changed
    4. Update the data to the current values.

    So the event must be generated, essentially using and testing a boolean variable that depends on whether the data under test has changed since the last time that it was read.

    Comment


      #17
      Koganam,
      Thank you for clarifications

      So basically you and Brett make use of OnBarUpdate() event to check and update the state of different things, like drawn objects.

      It's not exactly what I was looking for (I'm used to this method from MT4), but it's a workaround in the end.

      Thanks again

      Comment


        #18
        Originally posted by mishhh View Post
        Koganam,
        Thank you for clarifications

        So basically you and Brett make use of OnBarUpdate() event to check and update the state of different things, like drawn objects.

        It's not exactly what I was looking for (I'm used to this method from MT4), but it's a workaround in the end.

        Thanks again
        Pretty much all supported methods of processing using NT are done by using OnBarUpdate() to take action based on state variables. There are other advanced methods, that are documented in the NT literature, but NT pretty much warns you that they will not provide support beyond the documentation. That is where this forum, and its users come in, though it must be stated, in all fairness, that NT support will occasionally provide helpful links or comments, even for these advanced methods.

        Comment


          #19
          So koganam,
          Good clarification about NT support, NT world stuffs inside my head are well more organized now.

          About these advanced methods, can you tell about the general idea at least? If you happen to know more about it.
          I mean, keeping it to the simple example I just asked about.
          I see 2 scenarios (now I don't know if rectangle object has OnResize object, or any events at all)

          scenario1 (if drawn rectangle has OnResize event (or sizeChanged whatever)):
          1. display info near the mouse OnResize event of the rectangle

          scenario2if drawn rectangle does not have OnResize event):
          1a. dealing with OnMouseDown event
          1b. checking if mouse is over the rectangle's corners. If yes, retain position of mouse
          2a. dealing with OnMouseUp event
          2b. if mouse was over the rectangle's corners => then update the info near mouse ( + update the chart control altogether?!)

          But this is only my general view, as I didn't do anything like this until now in c# + NT7

          Comment


            #20
            You sound more like you are trying to track the mouse, rather than trying to track the object. Trying to track the mouse will require standard C#. Maybe I do not understand your objective, or maybe, are you focusing on a method rather than an objective?

            It is not hard to get the y-coordinates of a rectangle for example and store these in a structure. The x-coordinates can be stored as bar time values or bar count values. If you store these in a structure, then it is easy to determine if these values have changed. Using this data, you can write a function OnRectangleChange() to return a bool value.

            As far as I am aware, NT does not generate the kind of events that you seem to be describing. Of course, what I have described is essentially the same thing, triggered off of OnBarUpdate(), which loosely speaking, is an event.

            The other advanced methods for processing change are probably not relevant to this issue, as they relate mostly to handling orders during machine-based strategy trading. They are events such as those described in this link: http://www.ninjatrader.com/support/h...n_program2.htm
            Last edited by koganam; 02-14-2011, 01:07 PM.

            Comment


              #21
              Now it's clear to me that first I will do through OnBarUpdate(), because I'm not that into c#, events, mouse, objects etc.

              My general objective is quite clear: have faster measurements tools.

              I study a lot, but in NT things are sooo slow, because there's no fast measurement tool.

              Instead of so many words (english is not my first language as you probably know already) it would be faster if you would temporary install MT5 and play with crosshair, line and rectangle.

              The most useful things, for measurement at least, would be these 2 (exactly like in MT4 or MT5):

              1. a tool that when you click and drag, you can measure the distance in time and price.
              In MT4 and MT5, this tool is the crosshair, and when you left click the mouse and drag, you see the difference in pips and time bars.

              2. when I create a line or a rectangle (or anyother shape), each time I resize them, I see the difference in pips and timebars.

              ----
              Another best thing would be to be able to display not only price difference and timebars, but other parameters or values, calculated by me programatically.

              Thank you for guiding me, it helped in making the decision

              Comment


                #22
                To do that, you would need to write you own indicator.

                Basically, you would set CalculateOnBarClose to false, then use DrawText() to write the y-coordintate/x-coordinate/difference that you want to see. That way on every tick, you would see the current dimensions of the rectangle. If CalculateOnBarClose is true, you would only see the updated dimensions when the current bar closes.

                Comment


                  #23
                  Nice tip koganam,

                  you just saved me a lot of time just with this tip. I was asking myself about what CalculateOnBarClose means when it's false (when it's true, it's obvious lot obvious).
                  But maybe I read the documentation diagonally, and didn't catch the idea when I read about it.

                  Thanks, and I'll get back when I have progress.

                  Comment


                    #24
                    Feature Request: Ruler Option

                    Kyle/Ninja Folks,
                    To formalise this request. Many trading apps have the concept of a Ruler option that lets you measure distance (in ticks/pips & in Bars(time) & in Degrees(often meaningless). Clearly the Units it displays are determined by the Units set in the X & Y axis. The Degrees work best in Axis Units not Screen Pixel Units. So 1 Tick UP & 1 bar across = 45 reguardless of how compressed the bar space is.

                    There seem to be 2 common approaches.
                    1. A Toolbar tool called Ruler, where you click on 2 points & it displays the "Distance".
                    2. A Toolbar option. "Show/Hide Measurement" which displays the measurements of an object while you are creating it. Also transiently shows the measurements when you click on it.

                    How is it used by traders?
                    Assume they have a rule that says the price needs to retrace 9 ticks from the prior high before going long. It is handy to have a Ruler snap to the prior High, drag to the low of the current bar & show you how many ticks you've retraced.

                    Hope that helps you understand the need better.
                    ----------
                    Mishhh,

                    Part 1 - Mouse to Chart Coordinates
                    Ninja has an undocumented object called ChartControl. If you enter "ChartControl." in your code you will see the intillisense display all its methods. I had a Forum Post on this 18 mths ago, but can't find it at present to link to it.

                    Some of the properties tell you the Hight & Width of the ChartControl (ie Area of your chart) Others tell you the Max & Min values of the Y Axis being Displayed, as well as the number of the First & Last bars visible on the chart. It is then a simple matter to convert the Mouse Coordinates to the Bar coordniates.
                    You need to be using the PLOT() method.

                    Part 2 - Properties of an Object
                    This are good questions I've never spent must time on.
                    Question 1: How can I tell which object has been selected by the User?
                    - I've not seen any Event that Ninja exposed that tells you what the User is doing. like an OnClick Event.
                    Question 2: Can I ask a DrawObject what its properties are. Also can I iterate thru all Drawn objects on the chart?

                    Normally I draw the objects from my indicator, so I keep track of the values in an internal structure. But if the Trader Draws something on the chart, how can I access that programattically. I don't know.

                    Thought 3. You will find Ninja is fantastic for writting Indicators & Strategies. Via .NET there is almost nothing you cant' do. However that is where you hit a wall. Extending the UI, adding your own menus & toolbars, is extremely challenging.

                    I hope this answers your question in some small way.

                    Comment


                      #25
                      Question 2: Can I ask a DrawObject what its properties are. Also can I iterate thru all Drawn objects on the chart?
                      Yes, you can to both questions.

                      ref: http://www.ninjatrader.com/support/h...rawobjects.htm

                      Comment


                        #26
                        Thank you David for your input,
                        and konagam for your input again,

                        you brought more light in here about ChartControl (I'm still just a beginner in NT7) and other details.

                        light is good

                        for now I've temporarily (I hope) returned to MT4 and MT5, because of their measurement tools.
                        It's quite a pity NinjaTrader doesn't allow fast measurements of price and time.
                        For study purposes, ninjatrader is still clumsy, too clumsy.

                        After all, we have only 2 dimensions, price and time. I don't quite understand what other traders are doing, or how are they use ninjatrader.
                        Probably they are occupied with strategies more, than study the market.
                        I honestly cannot imagine how they study the market in ninjatrader.

                        For study, MT5 is way better. But they lack stocks. And they don't permit continuous time (24/7 session template). Only market time is allowed, which sucks.

                        Multicharts is quite nice, but it's very expensive (for me at least).

                        What also dragged me back was the fact that I use only free providers for now in NT7, Yahoo and Kinetick.
                        So OnBarUpdate() is not that helpful, because I don't get ticks.

                        What I need can be programmed at lower level, or through .NET infrastructure, and I'm doomed for now.

                        My strategy was to let the time deal with this issue, while I study in MT5 and some GannAnalystPro, hoping that ninjatrader would give priority to improving this area.

                        Thank you again for your time

                        Comment


                          #27
                          Mishh,

                          We have an drawing object in NinjaTrader called the Ruler, This should do what you need in NinjaTrader let me know if it does not.

                          David,

                          I had missed your post. See the above as we do have a ruler drawing object that If I'm understanding you correctly should do what you need.

                          Let me know if I can be of further assistance.

                          Comment


                            #28
                            Yes, I found it after I posted, One of the features new to v7.0 that I'd overlooked.
                            thx

                            Comment


                              #29
                              mishhh,
                              A few thoughts.
                              1. OnBarUpdate() is the name of a method that is called whenever a new tick arrives. It is not limited to only showing complete bars.
                              The Trader can control what they look at via the indicator parameter "Calculate on bar close" which when set to true only displays complete bars & when set false shows every tick.
                              If the data feed was your issue, A number of Ninja brokers will provide Tick data to you at no charge if you've opend an account with them. Thus you can continue to trade in sim till you are ready.

                              2. I guess it depends on what you mean by "study the market". Fortunately everyone has a different opinion otherwise your never find a counterparty to your trade. I've used (& own) a vast number of products over the years.
                              For manually exploring 1 market at a time ie: drawing indicators on indicators & looking at a single market, Metastock is quite nice. Easy for newbie programmers but very limited beyond that.
                              OmniTrader / VisualTrader are brilliant for looking at the entire market in real time. The data mining & graphical systems builders let you filter the entire market to find stocks that have formed the pattern you've found profitable. Also easy to extend if you pay $1,000's for the Pro version. But limited to 1 min time periods, doesn't do Tick, Range & other charts. Limited to IB & MT broker support.
                              TradingStation(FXCM) is nice for trading FOREX, but based on some abscure language from brazil no-one ever used, it is a pain to extend. As is eSignal, you can extend everything about it except the indicators which have to be lines / bars etc. It lacks the graphical freedom provided by Ninja.
                              MetaTrader personally I think the charts look ugly & is much less friendly to trade FOREX than Tradestation but has a much better development environment. Still like OmniTrader you can't use the full capability of .NET & the GDI+ which can be limiting.

                              So for me, Ninja is a very flexible product, where you can display anything, with not too much effort. It is a bummer that much of their best features are "not supported" If this site offered "Wiki Pages" we could improve the help in that area.
                              Good luck with your trading, consider joining an org like Traders International talking to other traders while you trade may help your market study.

                              Comment


                                #30
                                Hello all,

                                What I am basically after is a way to be able to assign the price value I click on on a chart to a variable in an indicator. For example, if I have a variable in my custom indicator named entry price, then anytime I click on a price on the chart, this variable is assigned that price value. I am a novice when it comes to NTScripts and C#. I have looked at some of the codes in here, but unfortunately do not seem to really understand the workings, let alone how to go about amending them to suit my needs. I would be very grateful if somebody could come up with a code to do the above or some suggestions please. Many thanks.

                                Dan

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by algospoke, Yesterday, 06:40 PM
                                2 responses
                                19 views
                                0 likes
                                Last Post algospoke  
                                Started by ghoul, Today, 06:02 PM
                                3 responses
                                14 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by jeronymite, 04-12-2024, 04:26 PM
                                3 responses
                                45 views
                                0 likes
                                Last Post jeronymite  
                                Started by Barry Milan, Yesterday, 10:35 PM
                                7 responses
                                20 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by AttiM, 02-14-2024, 05:20 PM
                                10 responses
                                181 views
                                0 likes
                                Last Post jeronymite  
                                Working...
                                X