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 kujista, Today, 05:44 AM
                0 responses
                5 views
                0 likes
                Last Post kujista
                by kujista
                 
                Started by ZenCortexCLICK, Today, 04:58 AM
                0 responses
                5 views
                0 likes
                Last Post ZenCortexCLICK  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                172 responses
                2,281 views
                0 likes
                Last Post sidlercom80  
                Started by Irukandji, Yesterday, 02:53 AM
                2 responses
                18 views
                0 likes
                Last Post Irukandji  
                Started by adeelshahzad, Today, 03:54 AM
                0 responses
                8 views
                0 likes
                Last Post adeelshahzad  
                Working...
                X