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

Addon button for boolean variable

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

    Addon button for boolean variable

    Is there a way to add a button to the chart window that is tied to a boolean variable that can then be used in a strategy? Basically I want to be able to enable/disable a strategy with a single click directly from the chart window. Doing so thru the strategy button requires 3 clicks and mouse movement, which at times takes too long.

    #2
    Hello slimcactus,

    Thanks for your post and welcome to the NinjaTrader forums!

    Yes, you can do that!

    Below I have provided a link to an example called long and short toolbar buttons (They are actually chart buttons).

    This strategy is publicly available on our NinjaTrader Ecosystem website:Here is a basic guideline of how to import NinjaScript add-ons in NinjaTrader 8:

    Note — To import NinjaScripts you will need the original .zip file.

    To Import:
    1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
    2. From the Control Center window select the menu Tools > Import > NinjaScript Add-on...
    3. Select the downloaded .zip file
    4. NinjaTrader will then confirm if the import has been successful.
    Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

    Here is a short video demonstration of the import process:The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Worked live a charm. Thank you. This is so much faster than toggling the "Enabled" button inside the strategy window, especially since NT sometimes takes 8-10s to start or stop the script. I was also able to make the button change color based on the state.

      Comment


        #4
        can I access this indicator in strategy builder ,to check if the boolean variable is true ?

        Comment


          #5
          Hello yBl123,

          Long Short Toolbar Buttons is actually an unlocked strategy and not an indicator, so unfortunately you cannot access it via the Strategy Builder.

          Please let us know if you have any further questions.
          Gaby V.NinjaTrader Customer Service

          Comment


            #6
            is there any indicator that has buttons that you know of ? ,I think I have seen in the past ,thanks !

            Comment


              #7
              Hello,

              Yes, please see the example script linked below:



              Please let us know if we can assist further.
              Gaby V.NinjaTrader Customer Service

              Comment


                #8
                what would I need to do for these buttons to be seen in strategy builder? Thanks

                Comment


                  #9
                  Hello,

                  Can you clarify what you mean by 'seeing the buttons in the Strategy Builder'?

                  Indicators will only be accessible in the Strategy Builder if the indicator contains a plot and a value is assigned to that plot. The Strategy Builder would then be able access that plot's value in the Conditions and Actions screen.

                  This indicator does not add any plots via AddPlot(), it's just demonstrating adding WPF modifications to a chart.
                  Gaby V.NinjaTrader Customer Service

                  Comment


                    #10
                    is it possible to add a plot to detect if the button was on ,say a value of 1
                    or it would need to be a variable that cant be accessed in strategy builder ?

                    Comment


                      #11
                      Hello,

                      Please see this forum post which explains exposing indicator plot values to the Strategy Builder:
                      I'm trying to expose my variables to the strategy builder so everyone can have better use of the WaveTrend indicator (it has a lot of code). Explain this to me like I am 5 because this isnt the first time I've tried to figure it out and hit a wall. What is Series? I know its like an array that stores bars. Why not just call it


                      You can set a plot value when a value is clicked, and then read that as signal in a Strategy Builder strategy. This would require using TriggerCustomEvent():


                      Please see this script as an example, specifically '#region Use case 2, submitting a limit order with limit price updated to indicator plot values'.
                      I need some guidance. I need to create a script that has 3 plots that are public and they plot either a 1 or 0. But I need to create another indicator that has 3 chart buttons that sets these variables. The first indicator needs to get those values from the second indicator depending on the button clicks. Because of using


                      Instead of submitting an order in the TriggerCustomEvent() call, you could instead set a plot value that could then be accessed via the Strategy Builder.

                      Please let us know if you have any further questions.
                      Gaby V.NinjaTrader Customer Service

                      Comment


                        #12
                        and I guess this would be able to trigger multiple strategies at the same time ? they would all be able to trigger if the plot value is 1?
                        because i have seen in another thread someone saying the only way to do this would be with making static variables

                        Comment


                          #13
                          Hello,

                          Each indicator will have a separate button since this is triggered by button press.

                          If you wanted to click a single button and have that button affect multiple strategies, yes you would have to use a static class variable.

                          Please note that that is not officially supported, so you would implement this at your own risk. Additionally, to implement this you would need to unlock the strategy and code it by hand, so it would not be accessible via the Strategy Builder.

                          Here is an example script demonstrating using a static class:



                          If you have any further questions please let us know.
                          Gaby V.NinjaTrader Customer Service

                          Comment


                            #14
                            I am confused ,how will one strategy have access to this indicator and not any other strategy ?
                            how will the button press be affecting only one strategy ? and if if only 1 which one ?
                            Last edited by yBl123; 01-10-2024, 10:57 AM.

                            Comment


                              #15
                              Hello,

                              Every strategy that uses an instance of the indicator only has access to that specific instance of the indicator. Each instance of the indicator has its own button, so the button press will only affect the strategy that is using that indicator instance.

                              Please let me know if I can clarify further.
                              Gaby V.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ageeholdings, Today, 07:43 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post ageeholdings  
                              Started by pibrew, Today, 06:37 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post pibrew
                              by pibrew
                               
                              Started by rbeckmann05, Yesterday, 06:48 PM
                              1 response
                              14 views
                              0 likes
                              Last Post bltdavid  
                              Started by llanqui, Today, 03:53 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post llanqui
                              by llanqui
                               
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              12 views
                              0 likes
                              Last Post burtoninlondon  
                              Working...
                              X