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

Keltner Channel with Ema

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

    Keltner Channel with Ema

    Good Afternoon;

    Does anyone know how to change the keltner channel settings to ema from the default sma. I have tried modifying the code but get an error message when I try to compile it.

    Any help will be appreciated.

    Than you and good trading

    aafwintb

    #2
    Hello,

    Thank you for your note.

    First open the default KeltnerChannel indicator>right click>Save As and name it something else.

    Change this code:

    double
    middle = SMA(Typical, Period)[0];
    double offset = SMA(diff, Period)[0] * offsetMultiplier;

    So that is looks like this:

    double middle = EMA(Typical, Period)[0];
    double offset = EMA(diff, Period)[0] * offsetMultiplier;

    Basically just change the "S" in SMA to "E" so that it is EMA.
    DenNinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply Ben. I did that and still get error message when I try to compile.

      Comment


        #4
        Hello,

        It worked for me. I suggest deleting the file you have now and starting over fresh.

        Is the error red? If so, the error is in another file. Double click on the error and it will pull up the file with the error.
        DenNinjaTrader Customer Service

        Comment


          #5
          Thanks for you help Ben. It works now.
          Have a great weekend.

          Comment


            #6
            Greetings,

            How do I add horizontal lines to the channel, all my attempts have failed. I want to be able to see the lines across multiple timeframes by choosing attach to all charts in their properties

            Some thing like the screen shot attached
            Attached Files
            Last edited by ramos04; 09-01-2017, 05:07 AM.

            Comment


              #7
              Hello ramos04,

              Thank you for the post.

              You could just draw the horizontal line on the most current plot value of these channels.

              Example:
              Code:
              protected override void OnBarUpdate()
                      {
                          Plot0.Set(Close[0]);
              	    DrawHorizontalLine("MyLine", Plot0[0], Color.Black);
              Make sure CalculateOnBarClose == false to calculate on each tick.

              This will apply to any time frame you have on the chart. Programmatically drawn objects can not be applied to all charts of the same instrument.

              Please let us know if we may be of any further assistance.
              Last edited by NinjaTrader_ChrisL; 09-05-2017, 08:39 AM.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_ChrisL View Post
                Programmatically drawn objects can not be applied to all charts of the same instrument.
                Thanks NT_ChrisL, all I needed the code for was to attach the objects across timeframes not just that applied chart.

                I have been doing it manually ie add the horizontal line to the chart and attach it to all charts although laborious and as you stated, I think I have no option but to keep it that way.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by devatechnologies, 04-14-2024, 02:58 PM
                3 responses
                19 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by tkaboris, Today, 08:01 AM
                0 responses
                2 views
                0 likes
                Last Post tkaboris  
                Started by BarzTrading, Today, 07:25 AM
                1 response
                11 views
                1 like
                Last Post NinjaTrader_Clayton  
                Started by EB Worx, 04-04-2023, 02:34 AM
                7 responses
                161 views
                0 likes
                Last Post VFI26
                by VFI26
                 
                Started by Mizzouman1, Today, 07:35 AM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X