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

Add button to toolbar's chart

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

    Add button to toolbar's chart

    Hello, I've developed an strategy with several functions, one of then is to add a button on the toolbar to set a trailing stop of 1 tick when clicled, the problem is I'm creating the button on the same chart of my strategy and I want to add it only on the toolbar of the chart(s) who haves enabled the chart trader, and obviously if the chart(s) haves the same insturment, this is the code of the button:


    Code:
    if(ChartControl!=null)
    {
      System.Windows.Forms.Control[] controls =
      ChartControl.Controls.Find("tsrTool", false);
      if (controls.Length > 0)
      {
        ToolStripButton btnTemp = new System.Windows.Forms.ToolStripButton("temp");
        boldFont = new Font("Arial", 8,FontStyle.Bold);
        btnTemp=null;
        btnTrail = new System.Windows.Forms.ToolStripButton("btnTrail");
        //btnManual.Font = boldFont;
       
        btnTrail.Font=boldFont;  
        btnTrail.ForeColor=Color.White;
        btnTrail.BackColor=Color.Red;  
        btnTrail.Text = "MicroTrail";
        strip = (System.Windows.Forms.ToolStrip)controls[0];
        strip.Items.Add(btnTrail);
        btnTrail.Click += MicroTrailFunc;
        buttonsloaded=true;
      }
    }

    Thanks for your help!

    #2
    Hello Quanto,

    Thank you for your post.

    The Strategies cannot be enabled on the chart when the Chart Trader is enabled in NinjaTrader 7.

    You would need to change approach to an Indicator instead if you want to have the toolbar button present when the Chart Trader is present.

    Please let me know if you have any questions.

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello Quanto,

      Thank you for your post.

      The Strategies cannot be enabled on the chart when the Chart Trader is enabled in NinjaTrader 7.

      You would need to change approach to an Indicator instead if you want to have the toolbar button present when the Chart Trader is present.

      Please let me know if you have any questions.
      Thanks Patrick for your answer,
      I know I can't have the Chart Trader on the same chart window with an enabled strategy and I can't change the aproach to an indicator because the button is only a feature of all my strategy, what I want to do is to have two charts with the same instrument, lets say NG 07-18, one of them with my strategy enabled, and the other one with the Chart Trader enabled and in this last one, to draw a custom button on the toolbar, currently, my strategy script draws the button on the same window chart of the strategy, that's what I want to change.


      again, thanks for your help

      Comment


        #4
        Originally posted by Quanto View Post
        .... to draw a custom button on the toolbar, currently, my strategy script draws the button on the same window chart of the strategy
        Which is completely normal.

        Originally posted by Quanto View Post
        that's what I want to change.
        Which is completely abnormal.

        I would venture to say that you are well beyond what NinjaTrader support will help you with here.

        Your request is just insane (but still pretty cool technically) to my thinking -- mostly because there are probably better ways to achieve the client-server effect of what you are probably after. Probably.

        If you decide to proceed, you'll have to rummage around in the Windows plumbing and eventually obtain a handle to the 'ChartControl' of the other chart window -- it will help if you are an expert with C# and Windows Forms (and especially Reflection) to do this rummaging.

        Heck, it takes quite a bit of skill and Reflection knowledge to rummage around the Windows internals of NinjaTrader.exe using Reflection as it is. All the examples I am familiar with focus on pillaging the display window your chart is hierarchically already a member of, not a different chart window.

        Good luck!

        Comment


          #5
          Originally posted by bltdavid View Post
          Which is completely normal.



          Which is completely abnormal.

          I would venture to say that you are well beyond what NinjaTrader support will help you with here.

          Your request is just insane (but still pretty cool technically) to my thinking -- mostly because there are probably better ways to achieve the client-server effect of what you are probably after. Probably.

          If you decide to proceed, you'll have to rummage around in the Windows plumbing and eventually obtain a handle to the 'ChartControl' of the other chart window -- it will help if you are an expert with C# and Windows Forms (and especially Reflection) to do this rummaging.

          Heck, it takes quite a bit of skill and Reflection knowledge to rummage around the Windows internals of NinjaTrader.exe using Reflection as it is. All the examples I am familiar with focus on pillaging the display window your chart is hierarchically already a member of, not a different chart window.

          Good luck!
          Yes bltdavid, I know is an abnormal request, but I've already seen it on another (payed) strategy, that's why I know that is possible to do what I want to do!
          Meanwhile, I'll be reading and triying, thanks for your help!

          Comment


            #6
            Originally posted by Quanto View Post
            Yes bltdavid, I know is an abnormal request, but I've already seen it on another (payed) strategy, that's why I know that is possible to do what I want to do!
            Which (paid) strategy?

            You're saying you start up the paid strategy in the 1st chart window, but you don't have to do or add anything special (such as a special 'companion' indicator) to the second chart window that has the Chart Trader?

            That I seriously doubt. I mean, think about that design. Just how the heck would the paid strategy 'know' which chart window running Chart Trader to add the toolbar button to? In no way (I'll bet my ham sandwich and last night's sushi dinner) does that strategy itself place the button on the other window's toolbar. Why? Because it is monumentally difficult and cumbersome to code it that way. It may be technically possible to do, but it is a terribly poor design decision. I mean, really really bad design. Let's not go there.

            Why? Because there are simpler, easier ways.

            I betcha the paid strategy requires that you add a special companion indicator to the Chart Trader window the strategy will communicate with. This companion indicator is obviously included when you buy the package. This indicator is coded to do special things, and it knows how to communicate and work with the paid strategy as a team, perhaps using a client-server style of communication.

            It is this special indicator that adds the toolbar button you see, and then this companion indicator sets up communications with the running strategy.

            Thus, the paid strategy and the included special companion indicator (running on a separate chart window) work as a team, communicating with each other as necessary to achieve the strategy effects the authors desired.

            Much much simpler design.

            I'll bet tomorrow's turkey sandwich that the paid strategy you speak of employs a special companion indicator.

            Comment


              #7
              Btw, this post entertains various ideas you might find helpful,


              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              4 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Started by alifarahani, Today, 09:40 AM
              6 responses
              41 views
              0 likes
              Last Post alifarahani  
              Started by Waxavi, Today, 02:10 AM
              1 response
              20 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Working...
              X