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

Add Bands to Indicator

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

    Add Bands to Indicator

    Hello,

    I'm brand new to coding and have been learning primarily through online tutorials and scouring the internet for resources. Recently, I managed to grasp the basics well enough to modify an Elliot Wave oscillator I found on this forum. Being able to visualize the oscillator line was a significant milestone for me, as it deepened my understanding of C# coding. However, my current challenge lies in converting an MT5 indicator originally coded by mladen back in 2016 into NT8. While I've managed to adjust the calculations accordingly, I'm struggling with integrating the bands into the indicator.

    The MT5 Code is this

    int levelsPeriod = (int)(SlowPeriod+MathCeil(FastPeriod/2.0)); // This are the levels calculation

    int i=(int)MathMax(prev_calculated-1,0); for (; i<rates_total && !_StopFlag; i++)
    {

    double price = getPrice(Price,open,close,high,low,i,rates_total);

    val[i] = iCustomMa(MaMethod,price,FastPeriod,i,rates_total, 0)-iCustomMa(MaMethod,price,SlowPeriod,i,rates_total, 1); // this is the Elliot Oscillator itself

    levelUp[i] = (val[i]>0) ? iEma(val[i],levelsPeriod,i,rates_total,2) : (i>0) ? iEma(levelUp[i-1],0,i,rates_total,2) : iEma(0,0,i,rates_total,2);
    levelDn[i] = (val[i]<0) ? iEma(val[i],levelsPeriod,i,rates_total,3) : (i>0) ? iEma(levelDn[i-1],0,i,rates_total,3) : iEma(0,0,i,rates_total,3);
    levelMi[i] = (levelUp[i]+levelDn[i])*0.5;​


    I'm seeking assistance in adding bands to the NT8 indicator. I've attached both the original MT5 indicator and the code I've developed for NT8. Any help would be greatly appreciated as I work towards achieving this milestone and reaching my goal. Thank you for your time and effort.

    Best Regards,
    Telmo

    Attached Files

    #2
    Hello tsantospinto,

    Thanks for your post.

    If these are plots from the MT5 indicator, you could use AddPlot() to add a plot(s) to a NinjaScript indicator and then assign a calculated value to the plot(s).

    AddPlot() Help Guide: https://ninjatrader.com/support/help...t8/addplot.htm

    It seems that a for loop might be used in the code you shared which would fall under C# education. You could do a quick Google search for something like "Using Loops in C#" to find information about working with C# loops and example code.

    Note that is against our policy to convert a script from a programming language to NinjaScript on your behalf and we do not provide C# education in our support.

    Below are NinjaTrader Support article links with information about getting started with NinjaScript which you might find helpful.

    Getting Started with NinjaScript: https://support.ninjatrader.com/s/ar...th-NinjaScript
    Basic Syntax: https://support.ninjatrader.com/s/ar...e-Basic-Syntax
    Looping Commands: https://support.ninjatrader.com/s/ar...oping-Commands
    Educational Examples: https://support.ninjatrader.com/s/ar...ional-Examples

    This forum thread will be open for other community members to share their insights or offer their services to convert the code for you.

    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services.

    You can find a list of programmers for hire here on the ecosystem site: https://ninjatraderecosystem.com/sea...mming-services


    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    Last edited by NinjaTrader_BrandonH; 04-14-2024, 01:38 PM.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you for responding. Regrettably, the code is from Metatrader 5, not NT5. Since the code is open, there are no rights violations. I comprehend your policies. I've already reached out to several programmers, but their quotes exceed my budget. Perhaps someone on the forum could provide insights into converting the indicator. Thank you once again.



      Comment


        #4
        Hello tsantospinto,

        Thanks for your notes.

        That was a typo in my previous post which has been changed to MT5.

        This forum thread will be open for other community members to share their insights on the topic and offer their services to convert the code for you.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by tsantospinto View Post
          Thank you for responding. Regrettably, the code is from Metatrader 5, not NT5. Since the code is open, there are no rights violations. I comprehend your policies. I've already reached out to several programmers, but their quotes exceed my budget. Perhaps someone on the forum could provide insights into converting the indicator. Thank you once again.
          Your request is a bit unclear, do not assume everyone is familiar with MT5 or SwingFinder. It is simply the difference between two moving averages (it has nothing to do with finding a "Swing").

          If you know what the final result should look like, attach a screenshot of a chart with the indicator on it, explain what the bands are, and perhaps how you intend to use this indicator. This is a simple request and most anyone motivated can make the modification you want.

          BTW, that Elliott wave Osc has nothing to do with Swing or Elliott Wave either..

          Cheers!

          Comment


            #6
            Originally posted by aligator View Post

            Your request is a bit unclear, do not assume everyone is familiar with MT5 or SwingFinder. It is simply the difference between two moving averages (it has nothing to do with finding a "Swing").

            If you know what the final result should look like, attach a screenshot of a chart with the indicator on it, explain what the bands are, and perhaps how you intend to use this indicator. This is a simple request and most anyone motivated can make the modification you want.

            BTW, that Elliott wave Osc has nothing to do with Swing or Elliott Wave either..

            Cheers!
            Thank you for your feedback.
            Yes the indicator is nothing more then the difference from 2 moving averages ( i use SMA 5 - 15 ). I call it swingfinder because i use it to define my swing movements ( think outside the box) and then i use fibonacci to enter the trade, using a simple concept RIC ( Rejection - Impulse - Correction ).

            For the oscillator itself it uses the FastSMA[0] - SlowSMA[1]

            For the bands , and as im a complete newbie on coding, here are the code on MT5 language :

            The Bands Levels are calculated by this formula MT5 Language
            int levelsPeriod = (int)(SlowPeriod+MathCeil(FastPeriod/2.0));

            levelUp[i] = (val[i]>0) ? iEma(val[i],levelsPeriod,i,rates_total,2) : (i>0) ? iEma(levelUp[i-1],0,i,rates_total,2) : iEma(0,0,i,rates_total,2);
            levelDn[i] = (val[i]<0) ? iEma(val[i],levelsPeriod,i,rates_total,3) : (i>0) ? iEma(levelDn[i-1],0,i,rates_total,3) : iEma(0,0,i,rates_total,3);
            levelMi[i] = (levelUp[i]+levelDn[i])*0.5;​

            where val[i] is the oscillator as per the following formula
            val[i] = iCustomMa(MaMethod,price,FastPeriod,i,rates_total, 0)-iCustomMa(MaMethod,price,SlowPeriod,i,rates_total, 1);

            Attached is my MT5 screen so can see the indicator at work

            I really appreciate if someone could help me on this task.

            Kind Regards,
            Telmo

            Attached Files

            Comment


              #7
              I'll explain how I utilize this indicator in case there's someone interested who could assist me in converting it from MT5 to NT8. Instead of relying on ZigZag, I utilize the Elliot Oscillator, which essentially calculates the variance between two averages. The crux lies in the bands, which delineate the extremes, enabling us to identify swings. Moving from one extreme to another, I delineate the swing. For instance, if the indicator shifts from a downward extreme to an upward extreme, it signifies a market swing. Subsequently, I plot the Fibonacci retracement, and unless the market breaches 128% of the current swing, I only engage in trades aligned with the prevailing movement. This method provides a robust and straightforward means of trend determination. Typically, I initiate trades from the 61.8% level, but you can utilize your existing indicator for entry definition and employ this method for trend identification. I hope this piques the interest of a coder on the forum who can assist me with this endeavor. Thank you.



              Comment


                #8
                Originally posted by tsantospinto View Post
                I'll explain how I utilize this indicator in case there's someone interested who could assist me in converting it from MT5 to NT8. Instead of relying on ZigZag, I utilize the Elliot Oscillator, which essentially calculates the variance between two averages. The crux lies in the bands, which delineate the extremes, enabling us to identify swings. Moving from one extreme to another, I delineate the swing. For instance, if the indicator shifts from a downward extreme to an upward extreme, it signifies a market swing. Subsequently, I plot the Fibonacci retracement, and unless the market breaches 128% of the current swing, I only engage in trades aligned with the prevailing movement. This method provides a robust and straightforward means of trend determination. Typically, I initiate trades from the 61.8% level, but you can utilize your existing indicator for entry definition and employ this method for trend identification. I hope this piques the interest of a coder on the forum who can assist me with this endeavor. Thank you.



                Thanks for the info but I assume if you are using this indicator to risk trading your money then you know what these bands mean, how they are calculated, and the conditions for drawing them.

                I do not know MT5 code to read what the code says, but if you explain in words what the code is supposed to do and how these bands are calculated with the conditions for drawing them, perhaps I or someone else can write the code in NT8.

                Also, if you give a link or reference form where the indicator comes from might be helpful.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by AgriTrdr, Yesterday, 01:51 PM
                6 responses
                20 views
                0 likes
                Last Post bobperez  
                Started by ETFVoyageur, Yesterday, 12:11 PM
                11 responses
                39 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by rdlans, Today, 05:42 AM
                0 responses
                3 views
                0 likes
                Last Post rdlans
                by rdlans
                 
                Started by llanqui, 05-22-2024, 06:14 AM
                13 responses
                34 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by AgriTrdr, Today, 05:33 AM
                0 responses
                3 views
                0 likes
                Last Post AgriTrdr  
                Working...
                X