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

Indicator with multiple return values

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

    Indicator with multiple return values

    Hello,

    Sorry for a dumb question. I have an indicator that should tell strategy to go long/short at certain price. This means indicator needs to return 2 variables ("Short" and 1850.25, for example) . How can I do ?

    Thanks,
    redduke

    #2
    Hello RedDuke,

    Thank you for your post.

    You could have the indicator produce a StringSeries for the "Short" or "Long", and a DataSeries for the price.

    For information on StringSeries please visit the following link: http://www.ninjatrader.com/support/h...ries_class.htm

    For information on DataSeries please visit the following link: http://www.ninjatrader.com/support/h...ries_class.htm

    For a reference sample on producing values from an indicator that are not plots please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=4991

    Comment


      #3
      Hi Patrick,

      Thanks a lot. This is exactly what I needed.

      redduke

      Comment


        #4
        Hello,

        Few more questions.

        1) My indicator has several input parameters. Do I always need to list them when referring to external variables? For example if (MyIndicator(23,15,YES,100).MyVariable=='ZZZZZ').. .... Or is there an easier way to do it?
        2) After I added my strategy to a chart, some of the plots from an indicator that I used in it got displayed on the chart, but some got a new panel below chart. How can I make everything be plotted on the chart, just like indicator does when used by itself.

        Thanks,
        redduke

        Comment


          #5
          Hello RedDuke,

          Thank you for your post.

          1. Unfortunately, the constructors must be passed through to the method.

          2. This is set by the individual indicators Overlay property in the indicator's code. You would need to set Overlay to True in these cases. Or right click in your chart > select Indicators > select the indicator > New > then set the Panel to SameAsInputSeries > then right click in the Indciators menu and select 'SetDefaultFor'indicatorname''.

          Comment


            #6
            Thanks a lot

            Comment


              #7
              Hello Patrick,

              Would you have an example of how to send the value back from strategy to indicator?

              Once way, I guess is to use indicator parameters, but I am not sure if this is the best approach:

              [GridCategory("Parameters")]
              public string TEST
              {
              get { return tEST; }
              set { tEST = value; }
              }

              Thanks

              Comment


                #8
                Hello RedDuke,

                I want to make sure I understand you here. You are trying to pass a value from the strategy into the indicator, correct? If so, this would not be possible. You would need to pass the value from indicator to indicator or from indicator to strategy.

                Comment


                  #9
                  No wonder, I can not figure it out

                  Essentially, I want to communicate back to indicator that the order got filled. Is there any way to do it?

                  Thanks

                  Comment


                    #10
                    Hello RedDuke,

                    Thank you for your response.

                    You could have the strategy write the fill to a file and then read that from the indicator. We have a few reference samples on reading and writing to files at the following links:

                    Comment


                      #11
                      Originally posted by RedDuke View Post
                      Hello Patrick,

                      Would you have an example of how to send the value back from strategy to indicator?

                      Once way, I guess is to use indicator parameters, but I am not sure if this is the best approach:

                      [GridCategory("Parameters")]
                      public string TEST
                      {
                      get { return tEST; }
                      set { tEST = value; }
                      }

                      Thanks
                      You would have the strategy use the setter of the indicator and just assign the necessary value.

                      Comment


                        #12
                        Originally posted by koganam View Post
                        You would have the strategy use the setter of the indicator and just assign the necessary value.
                        I figured this out last night. Works great. Thanks for posting the answer still. I was about to post myself for others just in case.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by AaronKoRn, Yesterday, 09:49 PM
                        0 responses
                        11 views
                        0 likes
                        Last Post AaronKoRn  
                        Started by carnitron, Yesterday, 08:42 PM
                        0 responses
                        10 views
                        0 likes
                        Last Post carnitron  
                        Started by strategist007, Yesterday, 07:51 PM
                        0 responses
                        12 views
                        0 likes
                        Last Post strategist007  
                        Started by StockTrader88, 03-06-2021, 08:58 AM
                        44 responses
                        3,982 views
                        3 likes
                        Last Post jhudas88  
                        Started by rbeckmann05, Yesterday, 06:48 PM
                        0 responses
                        10 views
                        0 likes
                        Last Post rbeckmann05  
                        Working...
                        X