• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Convert indicator to strategy

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

    Convert indicator to strategy

    Hello,

    I would like to convert the D3SpotterV3 indicator for NT8 to a strategy to be able to optimize the parameters and find the best divergences

    I have tried to copy the code in parts from the indicator to a newly created strategy but I do not get it and many errors appear.

    Somebody could help me

    Thank you very much
    Attached Files

    #2
    Hello Mestor,

    What are the errors you are getting?

    Was the code in your script?

    To confirm, you have started a new NinjaScript Strategy and you are calling the indicator from your strategy, is this correct?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      Thanks for your interest

      I do not understand much programming and what I want is simply that instead of D3Spotter being an indicator, I need it to be a strategy.

      I do not want to call the indicator from the strategy, but to be a strategy with that code.

      I tried to copy the indicator code into an empty strategy but it does not work, that's where many errors appear.

      Thank you

      Comment


        #4
        Hello Mestor,

        The simplest way to use the code would be to leave the indicator as an indicator and call the value from the indicator.

        But if you wanted to take the more advanced route and create a new script and copy just the logic for OnBarUpdate you could choose to do this instead.

        I was not able to confirm, what are the errors you are getting?

        What is the code in the script?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello,

          what I want is the second thing you are saying, but when I copy the content of the indicator to the strategy, many errors appear with the code CS0103

          I do something wrong

          The code of the indicator is the one that I have attached in my first post

          Comment


            #6
            Hello Mestor,

            You will not be able to copy all of the contents. You would only copy the logic in OnBarUpdate and variable declaration.

            I am not able to assist from an error code. You must provide the full error message.

            Or provide a screenshot.

            (edited, I forgot to add the link)
            Below is a link to a forum post with helpful information about getting started with NinjaScript that includes a link to the NinjaScript Editor 401 video that demonstrates copying the logic and variables from one script to another.
            http://ninjatrader.com/support/forum...609#post503609
            Last edited by NinjaTrader_ChelseaB; 06-04-2018, 12:29 PM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              thanks for your help

              I'm going to do tests

              Best regards

              Comment


                #8
                code to connect draw line to a strategy?

                Its fairly easy to make a strategy from a moving average crossover utilizing a plot but some indicators draw lines that never cross anything they draw a dot, arrow , word , or something a little more complex like
                Code:
                Draw.Line(this, "low"+CurrentBar.ToString() + BarsAgo.ToString(), true, BarsAgo, Low[BarsAgo] - (TickSize * MarkerDistanceFactor), 
                									A, Low[A] - (TickSize * MarkerDistanceFactor), DivergenceColor, DivergenceDashStyle, DivergenceLineWidth);
                My question is is there a anyway to insert a generic piece of code just before any type of draw.arrow , draw.dot draw.line . into a indicator that acts as a value/signal that can be accessed when creating a strategy through strategy builder to create a buy or sell signal?
                Most likely there has to be some code in the properties area of the indicator added also, any help or tips/ links I would really appreciate/

                Thanks Quantismo

                Comment


                  #9
                  Hello Quantismo,

                  Thank you for your post.

                  You can use our example at the following link to expose indicator values that are not plots so you can access them in another indicator or strategy.
                  Please let me know if you have any questions.
                  Patrick H.NinjaTrader Customer Service

                  Comment


                    #10
                    Expose a Value from more complex indicators

                    I see in the 2 examples i.e.( sampleBools) and I can remember the other one, that a very simple indicator like the MACD is used to for a example in how to expose a variable in a indicator so a strategy can access it. Neither of these methods work in more complicated indicators so far as I have tried exhaustively , if anyone can show a example of one working in someone's custom random complicated indicator I would appreciate it.

                    Thanks
                    Quantismo

                    Comment


                      #11
                      Hello quantismo,

                      Thank you for your post.

                      I am not aware of any complexity that would prevent the sample from working as intended.

                      Do you have an example of a complicated indicator that this approach does not work in?

                      I look forward to your response.
                      Patrick H.NinjaTrader Customer Service

                      Comment


                        #12
                        RE - Complicated Indicator

                        Thanks for responding Patrick... Here is a fairly complicated custom indicator you can see If you think any of those expose methods would still work in. I marked with the green forward slashes two area's where long and short entries would make sense to expose to a strategy.

                        If any of the exposed variable methods work in this indicator they would work in any indicator.

                        Thanks
                        Quantismo
                        Attached Files

                        Comment


                          #13
                          Hello Quantismo,

                          The Strategy Builder is only able to pull from plots.

                          Anything that is not a plot in an indicator cannot be selected in the Strategy Builder, though if the exposed object is public you would be able to access the object from an unlocked script that is coded by hand (outside of the Strategy Builder).

                          Is there a specific plot in your script that is not appearing in the Plot drop-down when selecting this indicator in the Condition Builder of the Strategy Builder?

                          I am seeing there should be 4 plots: IndicPlot0, IndicPlot1, IndicPlot2, and IndicPlot3. Are any of these plots unselectable in the Plot drop-down in the Condition Builder?

                          Below I am providing a public link to a short example script that demonstrates setting a plot after detecting an action. This indicator can be used in the Strategy Builder.
                          https://ninjatrader.com/support/foru...725#post529725
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            I would like to convert an indicator to a strategy. In a strategy is it possible to do graphics calculations such as normal indicator plots and also Sharp DX as in the OnRender event in an indicator?

                            Comment


                              #15
                              Hello mballagan,

                              Yes, it is possible to plot and use OnRender code in a strategy.

                              We look forward to assisting.
                              JimNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by saltminer, Today, 11:06 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post saltminer  
                              Started by saltminer, Today, 10:14 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post saltminer  
                              Started by Mykro, Today, 10:03 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Mykro
                              by Mykro
                               
                              Started by coolTrade, Today, 09:37 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post coolTrade  
                              Started by PatrickM, Today, 08:43 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post PatrickM  
                              Working...
                              X