Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

adding an indicator and checking if the price has penetrated the trendline

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

    adding an indicator and checking if the price has penetrated the trendline

    Hi NT

    I have successfully imported an indicator from the NT forum's indicator section:
    • AutoTrendH
    I want to to able to see it on my charts when I backtest. So for this reason I have tried to add it the same way I add others (please see a picture attached).
    I get an error, tried various combinations
    • Add(AutoTrendH());
    • Add(AutoTrendH(5));
    • Add(AutoTrendH);
    but neither works

    please advise.

    ***
    Also, in my strategy, can I programatically check if the price has crossed the trendlines drawn by this AutoTrendH indicator (eg: using CrossAbove) or I can't do this?

    Thanks
    Attached Files

    #2
    Jonas, you would need to carefully check the overload Intellisense would offer you for adding this indicator in so all needed parameters are used, for example this call should compile successfully -

    Add(AutoTrendH(false, true, 5));

    In the strategy sharing section there should be also a script using this indicator for trading decisions by the same author, I would suggest to check into that for working with it's signals provided.

    Comment


      #3
      Hello Ionaz:

      In addition to the example that Bertrand gave for adding to your strategys Initialize section which will show the indicator in your charts while running and backtesting, there are 3 public methods that can be called within your strategys logic to utilize signals from the indicator.

      Usage:
      AutoTrendH(bool: alertOnBreak, bool: showHistory, int: strength).TrendPrice ::returns trendline price at rightmost bar position
      AutoTrendH(bool: alertOnBreak, bool: showHistory, int: strength).Signal ::0 = no signal, 1 = Up break of down trend line(buy signal), -1 = Down break of up trend line(sell signal)
      AutoTrendH(bool: alertOnBreak, bool: showHistory, int: strength).Direction ::1=direction of last defined trend was up, -1=direction of last defined trend was down
      Where
      alertOnBreak : true = activates Alert box messaging
      showHistory : true = chart records historical trend lines, line breaks, points when trend was originated
      strength : min # bars for trend detection sensitivity (lower number = higher sensitivity)

      So in your OnBarUpdate section for example..
      protected override void OnBarUpdate()
      { ....
      if (AutoTrendH(true,true,14).Signal== 1) { EnterLong(); }
      if (AutoTrendH(true,true,14).Signal== -1) { EnterShort(); }
      }

      Would give you a simplistic always-in strategy that enters a position anytime any trendline is broken (up or down)

      Comment


        #4
        Hi Derek

        Thank you for your post.
        I have tried your indicator and found it very powerful.

        I've programmed trendline detection & break on MACD avg line, but have some issues backtesting it.
        I always wanted to use your indicator for this purpose, but wonder if it's possible to use MACD avg line as an input for AutoTrendH.

        If this is possible, please advise how can that be done.

        Thank you

        Comment


          #5
          Hello Ionaz:
          As written, you will not be able to use AutoTrendH for this purpose. The code contains commands that are designed for graphically connecting candlestick bar highs and lows not present in the MACD oscillator and if you try it will throw an exception. I like the concept and it could be re-written for this purpose. At a later date I may undertake this project (but for now I have several others taking precedence) and if I do I will contact you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          76 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          45 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          26 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          32 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          62 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X