Announcement

Collapse
No announcement yet.

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:	75
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);

    https://ninjatrader.com/support/help...b=average+true

    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);

      https://ninjatrader.com/support/help...b=average+true

      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

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by mr_trade, Today, 08:41 AM
            1 response
            20 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by StoneMan78, Today, 05:24 AM
            1 response
            17 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by rocgusma, Yesterday, 04:42 PM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Jorge.andres.o, 09-17-2020, 06:00 PM
            2 responses
            49 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Stephen Trading, Yesterday, 10:55 AM
            1 response
            28 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X