• 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

ChartTrader Call Click Button

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

    ChartTrader Call Click Button

    I have this code in "OnStartup" method. I want call the click event of btnMkt from another function. Is this possible?
    Now nothing happend.

    example: btnMkt.PerformClick();



    Code:
    Button btnMkt;
    void clickBuyMKT() {
        btnMkt.PerformClick();
    }
    protected override void OnStartUp() {
        for (int i = 0; i <= ChartControl.Controls.Count - 1; i++) {
            if (ChartControl.Controls[i] == ChartControl.Controls["pnlChartTrader"]) {
                Panel p = (Panel) ChartControl.Controls["pnlChartTrader"];
                for (int j = 0; j <= p.Controls.Count - 1; j++) {
                    if (p.Controls[j] == ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"]) {
                        Control ctrader = ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"];
                        for (int k = 0; k <= ctrader.Controls.Count - 1; k++) {
                            if (ctrader.Controls[k].Name == "btnBuyMarket") {
                                Button btnMkt = (Button) ctrader.Controls[k];
                            }
                        }
                    }
                }
            }
        }
    }

    #2
    Hello nekroart,

    Thanks for your post.

    We do not have any documentation on triggering UI controls in NT7 and could not offer support for such implementations. For NT8, we would recommend using the AddOn framework.

    NT8 AddOn Framework - https://ninjatrader.com/support/help...-us/add_on.htm

    When I tested your code, I was getting a Object reference not set to an instance of an object error since the example is setting a local btnMkt instead of the class level button. With this correction btnMkt is not null, however the PerformClick still does not work.

    PerformClick looks like the prefered way to trigger win forms buttons, but you may wish to investigate some other approaches as you are experimenting. I've included a StackOverflow link below.

    https://stackoverflow.com/questions/...ogrammatically

    I'll leave this thread open ended for any community members that may have experience in triggering button presses in NinjaTrader 7.

    If you have another question involving documented/supported NinjaScript, please feel free to open a new thread.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by saltminer, Today, 05:19 PM
    0 responses
    3 views
    0 likes
    Last Post saltminer  
    Started by martyn73, Today, 04:18 PM
    0 responses
    2 views
    0 likes
    Last Post martyn73  
    Started by aprendiz, Today, 03:42 PM
    0 responses
    2 views
    0 likes
    Last Post aprendiz  
    Started by 1001111, Today, 09:10 AM
    1 response
    18 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by usero86, Today, 06:02 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Working...
    X