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

Most efficient user input [for controlling Long/Short/Neither]

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

    Most efficient user input [for controlling Long/Short/Neither]

    First of all I want to thank every single member of the NT team. I don't think a lot of people realize how insanely unique and valuable it is that you guys are here helping people with their coding.

    I am a discretionary trader and I've recently managed to get a basic version of a script put together that handles trade entry and management.

    Because my systematic entries are based on levels and orderflow that I interpret discretionarily, I need to control which side (long/short) the script will take as well as none at all.

    Currently I need to open the strategy settings and manually type "LONG/SHORT/NEITHER" to control which side to allow the script to take (if either).

    I was wondering what options exist that I may explore to make this more efficient.

    One thing that comes to mind would be having buttons on the chart itself. I'm not sure how difficult that would be, and before I start investing time into that route I wanted to ask the team/community if there are other routes that might be worth looking at as in addition to or instead of buttons?

    Even a drop-down menu would be a step improved from having to type into the settings. Ideally I'd like to not be required to open the strategy settings at all but that's still better than typing.

    Thanks again for your help so far!
    Last edited by butt_toast; 07-22-2021, 12:22 PM.

    #2
    Hello butt_toast,

    You can add custom buttons or other WPF elements to the window. The most simple way is to add them using the UserControlCollection: https://ninjatrader.com/support/help...ub=usercontrol

    You can find other examples here: https://ninjatrader.com/support/foru...t=1#post499327

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

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello butt_toast,

      You can add custom buttons or other WPF elements to the window. The most simple way is to add them using the UserControlCollection: https://ninjatrader.com/support/help...ub=usercontrol

      You can find other examples here: https://ninjatrader.com/support/foru...t=1#post499327

      I look forward to being of further assistance.
      Wow that is absolutely perfect thank you.

      Last edited by butt_toast; 07-22-2021, 01:32 PM.

      Comment


        #4
        I cannot believe I got it working.

        The easiest thing for me to do was take the example from the language reference and include that almost line for line.

        Then I changed the location to top center, added a new button for SOH with a new color (gray).

        I was not able to use "==" to compare the name of the button to "LONG" for example, but I was able to use content. This is what I mean in case someone else finds this thread:

        // Define a custom event method to handle our custom task when the button is clicked
        private void OnMyButtonClick(object sender, RoutedEventArgs rea)
        {
        System.Windows.Controls.Button button = sender as System.Windows.Controls.Button;
        if (button != null)
        {
        Print(button.Name + " Clicked");
        if (button.Content == "LONG")//button name is buy
        {
        LongShort = "LONG"; //variable to decide long/short is LONG
        }
        else if (button.Content == "SHORT")//button name is sell
        {
        LongShort = "SHORT"; //variable to decide long/short is SHORT
        }
        else if (button.Content == "SOH") //button name is soh
        {
        LongShort = "SOH";//variable to decide long/short is SOH
        }
        }
        } //OnMyButtonClick

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by TradeForge, 04-19-2024, 02:09 AM
        2 responses
        28 views
        0 likes
        Last Post TradeForge  
        Started by aprilfool, 12-03-2022, 03:01 PM
        3 responses
        327 views
        0 likes
        Last Post NinjaTrader_Adrian  
        Started by giulyko00, Today, 12:03 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by f.saeidi, Today, 12:14 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by AnnBarnes, Today, 12:17 PM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Working...
        X