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

Including D3Spotter indicator in a strategy

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

    Including D3Spotter indicator in a strategy

    Hey there,

    has anyone figured out a way how to implement D3Spotter into a strategy? I'm using it along with some other indicators, like RecatanglePriceBreakout, simple moving averages, and those are quite simple. But for D3 I keep getting errors, and being new to this whole programming ordeal it's frying my brain a bit.

    For example, for SMAs:

    public class MyOWn : Strategy
    {
    private SMA smaFast;
    private SMA smaSlow;
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Fast = 8;
    Slow = 13;
    }
    else if (State == State.Configure)
    {
    smaFast = SMA(Fast);
    smaSlow = SMA(Slow);

    smaFast.Plots[0].Brush = Brushes.Orange;
    smaSlow.Plots[0].Brush = Brushes.Green;

    AddChartIndicator(smaFast);
    AddChartIndicator(smaSlow);
    }
    }
    Add the region properties at the bottom and it's operational. Similarly PriceBreakoutRecatangularBase indicator has a strategy created for it, but looking at it, it's also quite easy to follow - 2 variables that have indicators created for it, and #regions that are copied over to the strategy file. For D3 indicator, there are a TON of variables (copied in below), so must I define every variable, if I JUST want to use it's divergence spotter for RSI only?

    Essentially, I would have to include all these below in the strategy, and define them all as well?

    Is there a way to create only a few private variables for what I need for RSI, and copy over the #regions that are relevant, rather than again the entire load? Then, of course I want to draw it on the chart, just like SMAs, but it won't let me just do RSI function.

    If i try:
    AddChartIndicator(D3SpotIndicatorMethod.RSI(14));

    I get "non-invocable member.... cannot be used like a method.

    Hopefully someone has tackled this, and could shed some light on how to approach this.

    Thank you for your thoughts.

    public class D3SpotterV3 : Indicator
    {
    private D3SpotIndicatorMethod method = D3SpotIndicatorMethod.RSI;
    private D3SpotPriceType pType = D3SpotPriceType.High_Low;
    private bool useDefaultPlot = true; // Default setting for UseDefaultPlot
    private bool showAlerts = false;

    // Results
    private double foundValue;
    private double foundAvg;
    private double foundDiff;
    private double foundStochD;
    private double foundStochK;

    private int rsi_Period = 14;
    private int mom_Period = 14;
    private int rsi_Smooth = 3;
    private int rvi_Period = 14;
    private int cci_Period = 14;
    private int mfi_Period = 14;
    private int roc_Period = 14;
    private int stochrsi_Period = 14;

    private int smi_EMAPeriod1 = 25;
    private int smi_EMAPeriod2 = 1;
    private int smi_Range = 13;
    private int smi_SMIEMAPeriod = 25;

    // MACD variables
    private int macd_Fast = 12;
    private int macd_Slow = 26;
    private int macd_Smooth = 9;

    // Stochastics and Fast Stochastics
    private int stoch_PeriodD = 7;
    private int stoch_PeriodK = 14;
    private int stoch_Smooth = 3;
    private int stochfast_PeriodD= 3;
    private int stochfast_PeriodK= 14;

    private bool initDone = false;
    private ISeries<double> Indicator;
    private int [] HighBarsAgo;
    private int [] LowBarsAgo;
    private int ThisHigh;
    private int ThisLow;
    private int QHLength = 0;
    private int QLLength = 0;
    private int QueueLength = 3;
    private int scanWidth = 30;
    private int A = 1;
    private int BarsAgo;
    private double priceDiffLimit = 0.0;
    private double indicatorDiffLimit = 0.0;

    private DashStyleHelper divergenceDashStyle = DashStyleHelper.Dot;
    private int divergenceLineWidth = 3;
    private int markerDistanceFactor = 1;
    private Brush divergenceColor = Brushes.DarkMagenta;
    private Brush lowerDotColor = Brushes.Cyan;
    private Brush upperDotColor = Brushes.Yellow;

    private string myAlert1 = @"C:\Program Files (x86)\NinjaTrader 8\sounds\Alert1.wav";
    private string myAlert2 = @"C:\Program Files (x86)\NinjaTrader 8\sounds\Alert2.wav";

    private int do_Period = 14;
    private int do_Smooth1 = 5;
    private int do_Smooth2 = 3;
    private int do_Smooth3 = 9;

    #2
    Hello lmatiukas,

    Thank you for writing in.

    You need to call the indicator's method. You cannot use "D3SpotIndicatorMethod.RSI(14)". D3SpotIndicatorMethod.RSI is not a method.

    I do not have the NinjaTrader 8 version of this particular indicator, but with NinjaTrader 7, the indicator's method is D3SpotterV3(). IntelliPrompt will automatically tell you what parameters are needed to be passed into the method call when you place that opening parenthesis (

    To reduce the amount of parameters to pass into the when calling the indicator, you will need to modify the indicator's code and remove the properties that you will not be using.

    I would not suggest modifying the indicator's code if you are not certain how the indicator is using those parameters for its logic.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Just another post in this ocean, but improves algo dramatically

      I have masters in MSF, and my focus has been numbers of companies' financials, and thus their underlying stocks. The reality of the situation is that in most cases financials do not matter, since for a long time now, computers make trades based on trend, and social engineering.

      I've run so so so many tests, upgraded my home computer to a bit of a supercomputer and ran some more. Divergences and Fibonacci studies have shown time and again to be what most algos run out there. In the end with computers on both sides, none of this will matter, and there won't be any more stock market. But for another 5-10 years maybe It's interesting that I could not find another strategy trying to incorporate these things publicly.

      Maybe looking at these variables is so profitable that whoever has figured out the right mix of programming won't share it - and I am technically doing that too right now. Interesting end to my ramble right here.

      Comment


        #4
        Sorry about the thread-o-mancy on this ancient and venerable thread..... But i'm also wanting to use the D3 spotter to spot divergences. When trying to use the Strategy builder in NT8 I see there are numbered plots in the plot reading portion of the condition building window. Which one would you use for say detecting the first of several ways this indicator might be used would you use it as plot0 in the first instance and plot1 in the next? It's a complicated indicator and while it's use is fairly straightforward as an indicator it's not as clear when incorporated into a strategy , through the builder or manually in the editor itself. Would a user create variables to call in the condition builder, similar to how I was recently instructed on creating a dynamic trailing stop? and then do manual reordering in the editor for example?

        Seems a bit odd compared to the more straight forward nature of more simple indicators.

        If you need more information from me about what i'm trying to accomplish I can certainly send you some screen shots. And hopefully you can do a handy video.

        Originally posted by NinjaTrader_ZacharyG View Post
        Hello lmatiukas,

        Thank you for writing in.

        You need to call the indicator's method. You cannot use "D3SpotIndicatorMethod.RSI(14)". D3SpotIndicatorMethod.RSI is not a method.

        I do not have the NinjaTrader 8 version of this particular indicator, but with NinjaTrader 7, the indicator's method is D3SpotterV3(). IntelliPrompt will automatically tell you what parameters are needed to be passed into the method call when you place that opening parenthesis (

        To reduce the amount of parameters to pass into the when calling the indicator, you will need to modify the indicator's code and remove the properties that you will not be using.

        I would not suggest modifying the indicator's code if you are not certain how the indicator is using those parameters for its logic.

        Comment


          #5
          Also I think this is correct but I'd like confirmation you'd only need to write user inputs for those user variables you want to be able to adjust or backtest on each iteration of this indicator right? For example the stochastic iteration and CCI iterations would need their user inputs defined if you intend to adjust them. But if you aren't using any of the others you don't need to define them. Is that correct?

          Comment


            #6
            Hello Daryl,

            Thank you for your post.

            We would not have these details on the D3 Spotter. I would recommend asking the developer directly on these questions.
            Originally posted by Daryl Haaland View Post
            Sorry about the thread-o-mancy on this ancient and venerable thread..... But i'm also wanting to use the D3 spotter to spot divergences. When trying to use the Strategy builder in NT8 I see there are numbered plots in the plot reading portion of the condition building window. Which one would you use for say detecting the first of several ways this indicator might be used would you use it as plot0 in the first instance and plot1 in the next? It's a complicated indicator and while it's use is fairly straightforward as an indicator it's not as clear when incorporated into a strategy , through the builder or manually in the editor itself. Would a user create variables to call in the condition builder, similar to how I was recently instructed on creating a dynamic trailing stop? and then do manual reordering in the editor for example?

            Seems a bit odd compared to the more straight forward nature of more simple indicators.

            If you need more information from me about what i'm trying to accomplish I can certainly send you some screen shots. And hopefully you can do a handy video.

            Comment


              #7
              Hello Daryl,

              Thank you for your additional post.

              You would only write user variables for values you wish to control either manually when setting up the strategy instance to run or in an optimization.
              Originally posted by Daryl Haaland View Post
              Also I think this is correct but I'd like confirmation you'd only need to write user inputs for those user variables you want to be able to adjust or backtest on each iteration of this indicator right? For example the stochastic iteration and CCI iterations would need their user inputs defined if you intend to adjust them. But if you aren't using any of the others you don't need to define them. Is that correct?
              Please let me know if you have any questions.

              Comment


                #8
                Thanks!! Will Do, Hopefully George W gets back to me soon.

                Originally posted by NinjaTrader_PatrickH View Post
                Hello Daryl,

                Thank you for your post.

                We would not have these details on the D3 Spotter. I would recommend asking the developer directly on these questions.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Lumbeezl, 01-11-2022, 06:50 PM
                31 responses
                817 views
                1 like
                Last Post NinjaTrader_Adrian  
                Started by xiinteractive, 04-09-2024, 08:08 AM
                5 responses
                14 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by swestendorf, Today, 11:14 AM
                2 responses
                6 views
                0 likes
                Last Post NinjaTrader_Kimberly  
                Started by Mupulen, Today, 11:26 AM
                0 responses
                6 views
                0 likes
                Last Post Mupulen
                by Mupulen
                 
                Started by Sparkyboy, Today, 10:57 AM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X