• 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

DoubleClick on Selected DrawObject

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

    DoubleClick on Selected DrawObject

    DoubleClick on DrawObject is used by NT8. So I would like to active som code by Ctrl + DoubleClock on a drawobject like a Line, Ray etc. I know this will be tricky since I need do capture the event before Property popup is displayed.
    Anyone have som c# code that will do this.?
    Kindly Jeff

    #2
    Hello Jof G,

    Welcome to the NinjaTrader support forums.

    For double click that would be difficult as you would need to determine what object was selected in order to either allow or handle the event. The chart already has many mouse events so handling these events would likely prove difficult. This would require using the general C# WPF preview events.

    I am not aware of any samples using double click + a modifier however there is a sample of using the right click context menu to expand options for a chart object. Depending on what you are trying to do that may be a more simple way to approach the goal. https://ninjatrader.com/support/foru...nu?postcount=6

    What was the action you wanted to do after double clicking the object?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse, The sample was very good and I was able to do what I wanted using the RClick ContextMenue. I can also use this many other places ins my system. Here I was using FibonacciRetracement and draw Hlines on the chart. I had to 1) Select and align FibRet 2) Deselect to make stationary 3) Select again 4) Push my button on the main menu do draw the Hlines on the selected FibR. Now I can 1) Select and align Fib 2) Rclick and select Draw Hlines = Done. ... Beautiful...

      Now I have to figure out how to Persist/save the Hlines so they can survive a F5 or NT8 Restart. Any Sample for that, or should I open a new post?
      Really appreciate your help.

      Comment


        #4
        Hello Jof G,

        I wanted to make sure I understand whats happening in your use case, are you not seeing the objects saved because the action you do through the right click menu draws the objects?

        Pressing F5 would reload the script, I assume the reason the objects are not coming back is because your mouse action is now required to draw them, is that correct?


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,
          The Object I'm drawing from my right click menu is fine - Hline drawobjects draw correclty (I am drawing 3 draw objects via Ninjascriipt. So even thought drawing is activated by my Rclock menu. The are NOT manually user drawn, but Ninjascript drawn.( as per IDrawingTool.IsUserDrawn; will be false).

          Maybe there should be a feature request to be able to IDrawingTool..setUserDrawn to get the same behavior as manually drawn.

          The issue is that if I reload Ninjascript (F5) the objects I have drawn via Ninjascript are gone and I have to redraw them again. I dont user F5 very often, it's more that I exit NT8 and startup again they will be gone. I talked to support some month back and they said I have to make my own code to handle the save and restore. This is so I can get the same behaviour as if I was to draw Horizontal lines on the chart the manual ( normal ) way.
          So this is where I'm looking for some sample code to help me store and restore my Ninjascript drawn drawobjects.

          Thanks

          Comment


            #6
            Hello Jof G,

            If you are using the context menu to draw the objects through code but using a manual action, it would be expected that your objects do not save. There is no reason for them to be re drawn when you F5 and reload the script because you haven't manually drawn them again. If they should be re drawn, you would need to collect the data from the objects you draw somehow and save it, then reload it when the script starts and re draw them.

            Drawing an object manually will be saved because there is no logic associated there, with NinjaScript there is no expectation that a drawn object is ever saved because it requires the scripts logic to reach that conclusion.

            You could look into adding logic into your method which draws the object to write its data to XML or to a text file and then reload that in State.DataLoaded as one option. I will put in a feature request as well however I would not rely on that, I would suggest to implement your own saving if this is necessary to your development.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by faisamtrader, Today, 10:31 AM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_Tyler  
            Started by ChazJ, Today, 09:48 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by maxie, Today, 10:01 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Melissa  
            Started by Bionian, Today, 09:36 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Started by tomd, Today, 09:48 AM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Ariana  
            Working...
            X