• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing Indicator

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

    Trailing Indicator

    I wanted to create an indicator showing the 3 day highest high and lowest low, which is similar to Donchain Channel. Something like what I've attached. I was wondering how should I programme it.
    Attached Files

    #2
    Hello,
    Hello,
    Use DrawHorizontalLine() to draw lines representing your 3 day high and 3 day low values. I have included an example below of how to accomplish this.


    Code:
    protected override void Initialize()
            {      Add(PeriodType.Day, 1);
            }
    
    protectedoverridevoid OnBarUpdate() { stopPricehigh = High[ 0]; if(High[ 0] <= HighestBar(Highs[ 1], 3)) { ExitLongStop(stopPricehigh); } stopPrice = Low[ 0]; if(Low[ 0] <= LowestBar(Lows[ 1], 3)) { ExitLongStop(stopPrice); } DrawHorizontalLine( "HighLine" , stopPricehigh, Color.Black); DrawHorizontalLine( "LowLine" , stopPrice, Color.Black);
    Shawn B.NinjaTrader Customer Service

    Comment


      #3
      What you have attached is a Donchian Channel displaced by one bar.

      Simply take the standard Donchian Channel and set the Displacement to +1.

      Attached is a screenshot showing a displaced Donchian Channel for the section of the ES chart that you have posted.

      It is my own version of the Donchian Channel, which has a trend filter added.
      Attached Files

      Comment


        #4
        May I know what does the () and [] mean in DonchianChannel? For example: DonchianChannel(1).Lower[10]

        And can someone tell me whats the difference between period n bar? Thx
        Last edited by JT1230; 11-11-2015, 09:07 AM.

        Comment


          #5
          Originally posted by JT1230 View Post
          May I know what does the () and [] mean in DonchianChannel? For example: DonchianChannel(1).Lower[10]

          And can someone tell me whats the difference between period n bar? Thx
          (1) is the lookback period. To implement your idea you would need to set the lookback period to 3.

          [10] indicates the bar which is used to perform calculations. A value of 10 indicates that the last bar used for calculations was 10 bars ago. 0 designs the current bar.

          For example DonchianChannel(1).Lower[10] means the lower channel of a 1-period Donchian Channel (this would be just the low) calculated 10 bars ago. Therefore it will return the low of the bar 10 bars ago.

          Comment


            #6
            Hello JT1230,
            Harry is correct. The () holds a value for the period or number of bars used in the calculation. The [] holds a int value specifying the number of bars ago.
            I have included the Donchian Channel Help Guide to assist you further.
            Shawn B.NinjaTrader Customer Service

            Comment


              #7
              Sorry I'm a newbie, please bear with me. I didn't get what you meant. Are you saying that both Periods and Bars ago are for calculation? It would be easier for me to comprehend if you can attach a picture for me to compare.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Gerik, Today, 10:58 PM
              0 responses
              1 view
              0 likes
              Last Post Gerik
              by Gerik
               
              Vps by stooby
              Started by stooby, Today, 08:32 PM
              0 responses
              11 views
              0 likes
              Last Post stooby
              by stooby
               
              Started by FaaastEddy, Today, 08:25 PM
              0 responses
              3 views
              0 likes
              Last Post FaaastEddy  
              Started by YevhenShynkarenko, Yesterday, 01:22 AM
              2 responses
              39 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by testingsarasa, 05-20-2018, 02:50 PM
              11 responses
              739 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X