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

Button in the Chart Trader - how to find out the indicator values.

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

    Button in the Chart Trader - how to find out the indicator values.

    I have created buttons in the chart trader. I want to click on a button and get (for example in the Print() function):
    - the ATR indicator value from the last closed candle;
    - the Close Ttime of the last closed candle;
    - the Close Price of the last closed candle.
    How can I do this?
    Click image for larger version

Name:	Screenshot_2.jpg
Views:	791
Size:	132.8 KB
ID:	1113032

    #2
    Hello webus,

    If you used an indicator to add the buttons you could just use normal indicator series or call other indicators. For example Close[0] or Time[0].

    From the button event you would also have to wrap the code with a TriggerCustomEvent action: https://ninjatrader.com/support/help...=triggercustom

    Code:
    TriggerCustomEvent(o =>
    {
    
         //your NS code
    
    }, null);



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

    Comment


      #3
      Hi NinjaTrader_Jesse,

      Originally posted by NinjaTrader_Jesse View Post
      Hello webus,

      If you used an indicator to add the buttons you could just use normal indicator series or call other indicators. For example Close[0] or Time[0].

      From the button event you would also have to wrap the code with a TriggerCustomEvent action: https://ninjatrader.com/support/help...=triggercustom

      Code:
      TriggerCustomEvent(o =>
      {
      
      //your NS code
      
      }, null);



      I look forward to being of further assistance.
      Can you please clarify it in more detail?
      When I click on a button and try to get, for example, the close time of the last closed bar (Closes[0][0].ToString()) - I will get the close time of the oldest (very first) bar on the chart. The same is with the indicator value. I will get the value of the oldest bar (not the last closed).
      It seems to me that pressing the buttons does not see the actual values. How do I get the values that I expect and that match the chart?

      Comment


        #4
        Hello webus,

        Can you please clarify it in more detail?
        What more would you like detailed here? This is a simplified sample and I had included a comment about where your code would go, did you have a question with the sample or the link I provided? The help guide describes what the TriggerCustomEvent is and why that would be used. In a button event that would be required for your code to work otherwise what you are seeing is expected because that is not a NinjaScript event that is a WPF button event.

        If some part of that sample or the help guide is not clear can you specify what you are having trouble with or provide a sample of what you tried in relation to the TriggerCustomEvent?

        I look forward to being of further assistance.

        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi NinjaTrader_Jesse,

          Originally posted by NinjaTrader_Jesse View Post
          Hello webus,

          What more would you like detailed here? This is a simplified sample and I had included a comment about where your code would go, did you have a question with the sample or the link I provided? The help guide describes what the TriggerCustomEvent is and why that would be used. In a button event that would be required for your code to work otherwise what you are seeing is expected because that is not a NinjaScript event that is a WPF button event.

          If some part of that sample or the help guide is not clear can you specify what you are having trouble with or provide a sample of what you tried in relation to the TriggerCustomEvent?

          I look forward to being of further assistance.
          I didn't understand how it works and how to use it.
          Is there any working example for buttons?
          Could you please provide an example, how can I find out, for example, the closing price of the last closed bar in this way?

          Comment


            #6
            Hello webus,

            We don't have any additional samples for this aside from the two in the help guide and the one I provided. This method makes use of a Lambda expression, if you are not familiar with that topic in C# I would suggest to research that so you have a good understanding of what this syntax is. A lot of the more advanced NinjaScript items will use standard C# concepts so it is good to get a firm understanding of C# concepts to aid in NinjaScript development. https://docs.microsoft.com/en-us/dot...da-expressions

            I had provided a working example in post 2, I also cut out the unnecessary parts that the help guide shows to simplify it further. This is a working example:

            Code:
            TriggerCustomEvent(o =>
            {
            
                 //your NS code
            
            }, null);
            Your code goes where the comment says it goes, this code would go in your buttons event handler between the curly braces.

            If this is not clear can you try adding this to your script and then post the code you tried so I can understand what difficulty you are having here?



            I look forward to being of further assistance.


            JesseNinjaTrader Customer Service

            Comment


              #7
              Originally posted by webus View Post
              I have created buttons in the chart trader. I want to click on a button and get (for example in the Print() function):
              - the ATR indicator value from the last closed candle;
              - the Close Ttime of the last closed candle;
              - the Close Price of the last closed candle.
              How can I do this?
              Click image for larger version

Name:	Screenshot_2.jpg
Views:	791
Size:	132.8 KB
ID:	1113032
              If you don't mind my asking, how did you add buttons to chart trader? I've been searching for a while but nothing has helped me know where to start.

              Comment


                #8
                Hello trevor14,

                You can find some examples of adding content to the chart trader here:
                Hello All, Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum. Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm (https://ninjatrader.com/support/helpGuides/nt8/creating-chart-wpf-(ui)-modifi.htm) I've


                Please let me know if I may be of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by trevor14 View Post

                  If you don't mind my asking, how did you add buttons to chart trader? I've been searching for a while but nothing has helped me know where to start.
                  Did you succeed? If you still need help, please let me know.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Kaledus, Today, 01:29 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post Kaledus
                  by Kaledus
                   
                  Started by PaulMohn, Today, 12:36 PM
                  1 response
                  16 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by yertle, Yesterday, 08:38 AM
                  8 responses
                  37 views
                  0 likes
                  Last Post ryjoga
                  by ryjoga
                   
                  Started by rdtdale, Today, 01:02 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_LuisH  
                  Started by alifarahani, Today, 09:40 AM
                  3 responses
                  19 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X