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

Strategy Builder with Divergence Input Series Indicator

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

    Strategy Builder with Divergence Input Series Indicator

    Hello please i try use the indicator Divergence Input Series in Strategy Builder, I modify the indicator with plots, for choose in the builder, but when i try compilated the strategy have errors.

    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    dinput1 = dinput(Close, 5, 1, 1, 1, true, false, true, 1, 1, true, 9, 1 Minute, Brushes.Green, Brushes.Red, Brushes.Red, Brushes.Green);
    SetProfitTarget("", CalculationMode.Percent, Profit1);
    SetStopLoss("", CalculationMode.Percent, Loss1, false);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if ((Times[0][0].TimeOfDay >= TimeOpen.TimeOfDay)
    && (Times[0][0].TimeOfDay <= Closetime1.TimeOfDay)
    && (dinput1.TUp[0] > 0))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if ((Position.MarketPosition == MarketPosition.Long)
    && (Times[0][0].TimeOfDay >= Exittime1.TimeOfDay))
    {
    ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
    }

    The mark in blue 1 Minute is wrong, please how must be the correct write?

    Regards

    #2
    Hello walter739, thanks for writing in.

    The original script is not designed to be used in the builder. Firstly, the parameters for the additional data series need to be removed and the call to AddDataSeries needs to be hardcoded. The indicator also needs plots to be accessed in the builder. I made a version attached that fixes things up for the builder. Make sure your strategy adds the same data series as Divergence. In my example I changed AddDataSeries to AddDataSeries(BarsPeriodType.Minute, 1); so your strategy will also need to add a 1 minute series if you are using Divergence.

    You can check the plot values for either a 1 for true or a 0 for false e.g.


    Please let me know if I can assist any further.
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Waoo Chris, i can compare the original indicator with you indicator builder and i can learn, many and many thank you for time, works great, very appreciated.

      Comment


        #4
        Hello, i modify the indicator Divergencyinputseriesbuilder for 5 minutes AddDataSeries. In my strategy i try indentify the swing point low in variable for exit position, but for some reason not work well in the print ouput. I think the indicator is the reaosn, please if give me a light.

        Regards
        Attached Files

        Comment


          #5
          Hi Walter, thanks for your reply.

          Unfortunately, I will not be able to debug the custom strategy. I made a simple test script that isolates just the divergence indicator to test it's output and my test is creating signals here. Please see attached.
          Attached Files
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Thanks for your time Chris. I use your script, and put print swinglow (not always,sometimes) and is not right. Maybe is the indicator or i not use correctly ? Please if you can give me advice

            Regards
            Attached Files

            Comment


              #7
              Hi Walter thanks for your reply.

              Could you tell me exactly what is not right so I can know what to look for? I can not tell what the issue is from your screen shot.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Hello Chris, the swinglow dont print correctly. I annex picture.

                Thanks
                Attached Files

                Comment


                  #9
                  Hi Walter thanks for your reply.

                  Using Swing in the Builder has been discussed on the forum before. Our colleague Paul has made an example helping to understand output given by the swing indicator here:

                  https://ninjatrader.com/support/foru...swing-strategy

                  Best regards,
                  -ChrisL
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    Sorry,many thank you for the information.

                    Regards

                    Comment


                      #11
                      Originally posted by NinjaTrader_ChrisL View Post
                      Hi Walter, thanks for your reply.

                      Unfortunately, I will not be able to debug the custom strategy. I made a simple test script that isolates just the divergence indicator to test it's output and my test is creating signals here. Please see attached.
                      Hi Chris,

                      I used your TestDivergence, and changed to use RSI(14, 3) as the input. The trade doesn't seem to be correct though. Please see the screenshot. It took two consecutive trades. The first trade might be valid, but the second trade doesn't look like a RSI divergence.

                      Did I misunderstand how this divergence indicator work?

                      Another question I have is that there are many divergence indicators, and I couldn't get any of them to work for me, and I suspect I will have a better success rate if there is some kind of documentation or sample usage for these indicators. Am I suppose to install the indicators and just try on my own to get it to work? or is there a place where I can find documentation or sample usage?

                      Thanks!


                      Attached Files

                      Comment


                        #12
                        Hi op1031,

                        See this publicly available link defining what divergence is and how to use it:


                        The divergence builder example outputs up and down signals for the strategy builder to use. Are you using the RSI as input for this indicator? Have you printed the values using the Print method to see what output is being produced?

                        Kind regards,
                        -ChrisL
                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Chris,

                          Yes, I am using RSI as the input. I understand what divergence look like, the investopedia link you show has a picture that shows the two peaks in price vs the peaks in RSI.
                          I just ran the strategy analyzer and took a screenshot again. How can one possibly say that, in the screenshot, the trade at the yellow arrow is a divergence to the long side?


                          Attached Files

                          Comment


                            #14
                            Hi op1031,

                            The code still uses price series arrays so it would take some re-writing to make it compatible with a custom input like an indicator. I attached an example that shows how to use the Inputs array rather than using price series.

                            Kind regards,
                            -ChrisL
                            Attached Files
                            Chris L.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Chris,

                              I see. I misunderstood what this is for then. Thank you for the sample code.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by funk10101, Today, 12:02 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post funk10101  
                              Started by gravdigaz6, Yesterday, 11:40 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by MarianApalaghiei, Yesterday, 10:49 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by XXtrader, Yesterday, 11:30 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post XXtrader  
                              Started by love2code2trade, 04-17-2024, 01:45 PM
                              4 responses
                              28 views
                              0 likes
                              Last Post love2code2trade  
                              Working...
                              X