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

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


              #7
              Thanks Jesse, What you saying is correct and I'm aware of that. Was just wondering if the was an xml example to help speed up the process. All the best Jeff

              Comment


                #8
                Hello Jof G,

                You could do that in a variety of ways however I am unaware of any specific sample of xml serialization, you could search online for C# xml serialize if you wanted to go that way. We do have a sample of writing data to file here which you could write the CurrentBar or other related values to and then re read:




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

                Comment


                  #9
                  Thanks again Jesse, These examples will help me speed up the job.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by RubenCazorla, Today, 09:07 AM
                  2 responses
                  11 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by i019945nj, 12-14-2023, 06:41 AM
                  7 responses
                  81 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by timmbbo, 07-05-2023, 10:21 PM
                  4 responses
                  158 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by tkaboris, Today, 08:01 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by Lumbeezl, 01-11-2022, 06:50 PM
                  31 responses
                  819 views
                  1 like
                  Last Post NinjaTrader_Adrian  
                  Working...
                  X