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

complie error - Bressert Double Smooth Stochastics

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

    complie error - Bressert Double Smooth Stochastics

    Hi,

    I'm looking for help to code a cAlgo script to NT7 for Bressert Double Smooth Stochastics indicator

    Could someone please help me with a compatible NT7 script :

    Code:
    using System;
    using cAlgo.API;
    using cAlgo.API.Internals;
    using cAlgo.API.Indicators;
    *
    namespace cAlgo
    {
    ****[Levels(0, 20, 40, 60, 80, 100)]
    ****[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None, ScalePrecision = 2)]
    ****public class DSSBressert : Indicator
    ****{
    ********[Parameter("Stochastic period", DefaultValue = 13)]
    ********public int Stochastic_Period { get; set; }
    *
    ********[Parameter("EMA period", DefaultValue = 8)]
    ********public int EMA_Period { get; set; }
    *
    ********[Parameter("WMA period", DefaultValue = 8)]
    ********public int WMA_Period { get; set; }
    *
    ********[Output("DSS", Color = Colors.White, Thickness = 1)]
    ********public IndicatorDataSeries DSS { get; set; }
    *
    ********[Output("DSS Up", Color = Colors.DodgerBlue, PlotType = PlotType.Points, Thickness = 5)]
    ********public IndicatorDataSeries DSS_Up { get; set; }
    *
    ********[Output("DSS Down", Color = Colors.Red, PlotType = PlotType.Points, Thickness = 5)]
    ********public IndicatorDataSeries DSS_Down { get; set; }
    *
    ********[Output("WMA", Color = Colors.Gold, Thickness = 1)]
    ********public IndicatorDataSeries WmaResult { get; set; }
    *
    ********[Output("L1", LineStyle = LineStyle.Solid, Color = Colors.LightGray)]
    ********public IndicatorDataSeries L1 { get; set; }
    *
    ********[Output("L2", LineStyle = LineStyle.DotsRare, Color = Colors.LightGray)]
    ********public IndicatorDataSeries L2 { get; set; }
    *
    ********[Output("L3", LineStyle = LineStyle.DotsRare, Color = Colors.LightGray)]
    ********public IndicatorDataSeries L3 { get; set; }
    *
    ********[Output("L4", LineStyle = LineStyle.Solid, Color = Colors.LightGray)]
    ********public IndicatorDataSeries L4 { get; set; }
    *
    ********private double Ln = 0;
    ********private double Hn = 0;
    ********private double LXn = 0;
    ********private double HXn = 0;
    ********private double alpha = 0;
    ********private IndicatorDataSeries mit;
    ********private WeightedMovingAverage WMA;
    *
    ********protected override void Initialize()
    ********{
    ************mit = CreateDataSeries();
    ************alpha = 2.0 / (1.0 + EMA_Period);
    ************WMA = Indicators.WeightedMovingAverage(DSS, WMA_Period);
    ********}
    *
    ********public override void Calculate(int index)
    ********{
    ************L1[index] = 20;
    ************L2[index] = 40;
    ************L3[index] = 60;
    ************L4[index] = 80;
    *
    ************if (double.IsNaN(mit[index - 1]))
    ************{
    ****************mit[index - 1] = 0;
    ************}
    *
    ************if (double.IsNaN(DSS[index - 1]))
    ************{
    ****************DSS[index - 1] = 0;
    ************}
    *
    ************Ln = MarketSeries.Low.Minimum(Stochastic_Period);
    ************Hn = MarketSeries.High.Maximum(Stochastic_Period);
    *
    ************mit[index] = mit[index - 1] + alpha * ((((MarketSeries.Close[index] - Ln) / (Hn - Ln)) * 100) - mit[index - 1]);
    *
    ************LXn = mit.Minimum(Stochastic_Period);
    ************HXn = mit.Maximum(Stochastic_Period);
    ************DSS[index] = DSS[index - 1] + alpha * ((((mit[index] - LXn) / (HXn - LXn)) * 100) - DSS[index - 1]);
    *
    ************if (DSS[index] > DSS[index - 1])
    ************{
    ****************DSS_Up[index] = DSS[index];
    ****************DSS_Down[index] = double.NaN;
    ************}
    *
    ************if (DSS[index] < DSS[index - 1])
    ************{
    ****************DSS_Down[index] = DSS[index];
    ****************DSS_Up[index] = double.NaN;
    ************}
    *
    ************WmaResult[index] = WMA.Result[index];
    ********}
    *
    ****}
    }
    Last edited by seveera; 07-12-2018, 01:21 PM. Reason: Wrong description

    #2
    Welcome to the forums seveera!

    We will not be able to debug and correct the code for you as this would exceed the scope of services we may provide, but we could offer some suggestions to help you to debug the code.

    The error from the compiler says that there is already a DSSBressert class defined in the cAlgo namespace. You will have to make your own class to avoid the error.

    Additionally, I do not understand your use of asterisks and would not recommend using such syntax to avoid more compiler errors. A reference for basic C# syntax can be found in the NinjaTrader 7 help guide. For more in depth C# education, I recommend looking for resources external to NinjaTrader.

    Basic Syntax - https://ninjatrader.com/support/help...sic_syntax.htm

    We could also have someone reach out with information about NinjaScript Consultants in our EcoSystem that would be happy to write this script or any other at your request.

    Please let us know if this interests you or if there is anything else we can do to help.
    JimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by seveera View Post
      Hi,

      I'm looking for help to code a cAlgo script to NT7 for Bressert Double Smooth Stochastics indicator

      Could someone please help me with a compatible NT7 script :
      Or convert the below PHP script (from esignal) to NT7 script

      Code:
      /********************************* 
      Description:         
          DSS Bressert (Double Smoothed Stochastic) 
           
      Version:            1.0  04/10/2009 
      
      Formula Parameters:                     Default: 
          pds                                 10 
          TriggerLen                          5 
          Overbought                          80 
          Oversold                            20 
          EMAlen                              9 
      
      Notes: 
          Double Smoothed Stochastics (DSS) is designed by William Blaw.  
          It attempts to combine moving average methods with oscillator principles.  
      **********************************/ 
      var fpArray = new Array(); 
      var bInit = false; 
      
      function preMain() { 
          setStudyTitle("DSS Bressert"); 
          setCursorLabelName("DSS", 0); 
          setCursorLabelName("Trigger", 1); 
          setDefaultBarFgColor(Color.brown, 0); 
          setDefaultBarFgColor(Color.red, 1); 
          setStudyMax(101); 
          setStudyMin(-1); 
          var x = 0; 
          fpArray[x] = new FunctionParameter("pds", FunctionParameter.NUMBER); 
          with(fpArray[x++]) { 
              setLowerLimit(1); 
              setDefault(10); 
          } 
          fpArray[x] = new FunctionParameter("TriggerLen", FunctionParameter.NUMBER); 
          with(fpArray[x++]) { 
              setLowerLimit(1); 
              setDefault(5); 
          } 
          fpArray[x] = new FunctionParameter("Overbought", FunctionParameter.NUMBER); 
          with(fpArray[x++]) { 
              setLowerLimit(1); 
              setDefault(80); 
          } 
          fpArray[x] = new FunctionParameter("Oversold", FunctionParameter.NUMBER); 
          with(fpArray[x++]) { 
              setLowerLimit(1); 
              setDefault(20); 
          } 
          fpArray[x] = new FunctionParameter("EMAlen", FunctionParameter.NUMBER); 
          with(fpArray[x++]) { 
              setLowerLimit(1); 
              setDefault(9); 
          }    
      } 
      
      var xDSS = null; 
      var xTrigger = null; 
      
      function main(pds, TriggerLen, EMAlen, Overbought, Oversold){ 
      var nBarState = getBarState(); 
          if (nBarState == BARSTATE_ALLBARS) { 
              if (pds == null) pds = 10; 
              if (TriggerLen == null) TriggerLen = 5; 
              if (Overbought == null) Overbought = 80; 
              if (Oversold == null)    Oversold = 20; 
              if (EMAlen == null) EMAlen = 9; 
          } 
          if (bInit == false) { 
              addBand(Overbought, PS_SOLID, 1, Color.blue, 0); 
              addBand(Oversold, PS_SOLID, 1, Color.blue, 1);             
              xDSS = ema(EMAlen,stochK(pds,1,1,ema(EMAlen, stochK(pds,1,1)))); 
              xTrigger = ema(TriggerLen,xDSS); 
              bInit = true; 
          } 
          var nDSS = xDSS.getValue(0); 
          var nTrigger = xTrigger.getValue(0); 
          if(nDSS==null||nTrigger==null) return; 
          return new Array(nDSS,nTrigger); 
      }

      Comment


        #4
        Thank you, will reach out to some in the ecosystem

        Comment


          #5
          Originally posted by seveera View Post
          Thank you, will reach out to some in the ecosystem
          Dstoch for NT 7
          Attached Files

          Comment


            #6
            Hello,
            Any way someone have the DSS for NT8?
            Regards

            Comment


              #7
              Hello Mr_trader,

              I was unable to locate a DSS indicator on the user app share however I'll leave this post open so the original poster or other users may be able to assist you.

              Thank you for your patience.
              Heath R.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by fiddich, Today, 05:25 PM
              0 responses
              3 views
              0 likes
              Last Post fiddich
              by fiddich
               
              Started by gemify, 11-11-2022, 11:52 AM
              6 responses
              803 views
              2 likes
              Last Post ultls
              by ultls
               
              Started by ScottWalsh, Today, 04:52 PM
              0 responses
              4 views
              0 likes
              Last Post ScottWalsh  
              Started by ScottWalsh, Today, 04:29 PM
              0 responses
              7 views
              0 likes
              Last Post ScottWalsh  
              Started by rtwave, 04-12-2024, 09:30 AM
              2 responses
              22 views
              0 likes
              Last Post rtwave
              by rtwave
               
              Working...
              X