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

SMI Indicator New Start

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

    SMI Indicator New Start

    I am new to NT. I use Interactive Brokers. I have no proficiency with the Ninjascript yet.

    I obtained coding from a vendor that does the SMI indicator. It works on their platform.

    Can someone help me use this coding and put it in Ninjascript so I can use the indicator?

    Coding is as follows: Says file is too big.




    declare lower;

    input over_bought = 40.0;
    input over_sold = -40.0;
    input percentDLength = 3;
    input percentKLength = 5;

    def min_low = lowest(low, percentKLength);
    def max_high = highest(high, percentKLength);
    def rel_diff = close - (max_high + min_low)/2;
    def diff = max_high - min_low;


    def avgrel = expaverage(expaverage(rel_diff, percentDLength), percentDLength);
    def avgdiff = expaverage(expaverage(diff, percentDLength), percentDLength);

    plot SMI = avgrel/(avgdiff/2)*100;
    smi.setDefaultColor(getColor(1));

    plot AvgSMI = expaverage(smi, percentDLength);
    avgsmi.setDefaultColor(getcolor(5));

    plot overbought = over_bought;
    overbought.setDefaultColor(getcolor(5));

    plot oversold = over_sold;
    oversold.setDefaultColor(getcolor(5));

    #2
    rtj4201,

    If any forum member jumps in that would be great. Unfortunately we do not offer any custom coding services. If you wish for such a service you can try one of the 3rd party NinjaScript Consultants here: http://www.ninjatrader.com/webnew/pa...injaScript.htm
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      If we knew what this was: "expaverage" , it would be a snap.
      eDanny
      NinjaTrader Ecosystem Vendor - Integrity Traders

      Comment


        #4
        How about exponential average.

        Comment


          #5
          initial version did not check for division by zero and Currentbar

          This has been posted: http://www.ninjatrader-support2.com/...ad.php?p=65575

          However, the initial version did not check for division by zero and Currentbar.
          Modify the OnBarUpdate to check for those conditions or download below:
          Code:
          		protected override void OnBarUpdate()
          		{
          			if (( CurrentBar < emaperiod2) | ( CurrentBar < emaperiod1)) {
          				return;
          			}
          			//Stochastic Momentum = SM {distance of close - midpoint}
          		 	sms.Set(Close[0] - 0.5 * ((MAX(High, range)[0] + MIN(Low, range)[0])));
          			
          			//High low diffs
          			hls.Set(MAX(High, range)[0] - MIN(Low, range)[0]);
          
          			//Stochastic Momentum Index = SMI
          			double denom = 0.5*EMA(EMA(hls,emaperiod1),emaperiod2)[0];
           			smis.Set(100*(EMA(EMA(sms,emaperiod1),emaperiod2))[0] / (denom ==0 ? 1 : denom  ));
          			
          			//Set the current SMI line value
          			SMI.Set(smis[0]);
          			
          			//Set the line value for the SMIEMA by taking the EMA of the SMI
          			SMIEMA.Set(EMA(smis, smiemaperiod)[0]);
          		}
          Attached Files

          Comment


            #6
            Thanks. I am new to Ninjascript.

            How do I input the zip file.

            On another thread, I got the original .cs of the SMI indicator and put it in the C:/my documents/ninja trader 6.5/bin/custom/indicator and then edited and compiled the program.

            The zip file has more than one imbedded file. How do I implement?

            Comment


              #7
              Have you had a chance to look through the online help? Here is the url for import: http://www.ninjatrader-support.com/H...e.html?Import1
              All versions of NT should have the ability to import these indicator files provided there are no errors in compiling them.
              Import

              You should only import NinjaScript Archive files (.zip) that you have obtained from a trusted source.

              To import:

              Just double click on the NinjaScript Archive file (.zip) and it will automatically start the import process

              or

              From the Control Center window select the menu File > Utilities > Import NinjaScript to open the Import NinjaScript dialog window
              Select the file you want to import
              Press the "Open" button

              * Prior to NinjaTrader Version 6.5, NinjaScript Archive files had the file extension .zip. These files can still be imported by following the 3 steps above

              Comment


                #8
                I imported it. It works fine.

                One question. The .cs version that I was referring to earlier has only two inputs and was a very smooth graph without a lot of bumps.

                This one is not smooth at all.

                I use a 1 minute chart. What settings would you recommend to smooth out the chart?

                Comment


                  #9
                  You have to play around with the three EMA periods EMAPeriod1, EMAPeriod2 and SMIEMAPeriod...all with influence the smoothing this indicator has...in default EMAPeriod2 is only 1 so you may want to increase this first and see if the result fits.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Need help improving the SMI indicator

                    I use an SMI indicator in TradeStation which is similar to the one attached below except better in 2 ways:

                    1. The one I use in TS has a zero line which I find helpful.
                    2. The one I use in TS only shows 1 line - when the fast average is above the slow average, the line is painted green, when the fast average crosses down thru the slower average, it paints the line red.It just makes for a cleaner, easier to read indicator.

                    Can someone adjust the code below to do that or tell me how to adjust it?Here is the code for the indicator in TS but I don't know how to code this in Ninja.

                    Here is the code from TradeStation.
                    Input:Length1(13),Length2(25),Length3(2),AlertLeve l(40), UpColor(green), DwnColor(red); Value1 = SMI(length1,length2,length3); plot1( Value1, "SMI" ); plot2( AlertLevel, "Sell line" ); plot3(-AlertLevel, "Buy line" ); plot4(0, "Zero"); If value1>value1[1] then begin plot1[1](value1[1],"SMI",upcolor); plot1(value1,"SMI",upcolor); end else begin plot1[1](value1[1],"SMI",dwncolor); plot1(value1,"SMI",dwncolor); end;

                    Thanks,
                    TC
                    Last edited by toddaclark; 05-14-2009, 07:00 PM.

                    Comment


                      #11
                      toddaclark, to add a zero line you can add this in the Initialize() -
                      Code:
                       
                      Add(new Line(Color.DarkViolet, 0, "Zero line"));
                      For creating a multi colored plot for easier reading, please see this reference sample - http://www.ninjatrader-support2.com/...ead.php?t=3227

                      To get this professional custom coded for you, please contact a NinjaScript consultant - http://www.ninjatrader.com/webnew/pa...injaScript.htm
                      BertrandNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by WHICKED, Today, 12:45 PM
                      2 responses
                      16 views
                      0 likes
                      Last Post WHICKED
                      by WHICKED
                       
                      Started by GussJ, 03-04-2020, 03:11 PM
                      15 responses
                      3,271 views
                      0 likes
                      Last Post xiinteractive  
                      Started by Tim-c, Today, 02:10 PM
                      1 response
                      8 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by Taddypole, Today, 02:47 PM
                      0 responses
                      2 views
                      0 likes
                      Last Post Taddypole  
                      Started by chbruno, 04-24-2024, 04:10 PM
                      4 responses
                      51 views
                      0 likes
                      Last Post chbruno
                      by chbruno
                       
                      Working...
                      X