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

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.
            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.

                  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.

                      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.
                          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 BarzTrading, Today, 07:25 AM
                              2 responses
                              14 views
                              1 like
                              Last Post BarzTrading  
                              Started by devatechnologies, 04-14-2024, 02:58 PM
                              3 responses
                              19 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by tkaboris, Today, 08:01 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post tkaboris  
                              Started by EB Worx, 04-04-2023, 02:34 AM
                              7 responses
                              162 views
                              0 likes
                              Last Post VFI26
                              by VFI26
                               
                              Started by Mizzouman1, Today, 07:35 AM
                              1 response
                              10 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X