Announcement

Collapse
No announcement yet.

Trendline

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

  • Trendline

    New to this so your patience is appreciated!

    I am working with the Formula Editor trying to create a simple trendline to display a line on a chart for the lowest low bars for a period of, say 60, in any time frame.

    It would be great if it would dynamically update.

    A "starter" line formula will be a great help.

    Thanks in advance for your advice or suggestions.

    Craig

  • #2
    HELLO

    I can not help with with the formula editor, but have you experimented with the Regression trend channel. You could just have it display the lower line and omit the center and higher high line. You could put in 60 bars as default and this would work in any timeframe you have. It would also update dynamically as the bars change.

    Good Luck

    Pogman

    Comment


    • #3
      Well that'll blow my mind. Amazing how "simple" something may be if someone points you in the right direction.

      Many thanks.

      Craig

      Comment


      • #4
        Craig
        The enclosed efs will calculate the lowest Low in the last 60 bars and draw a horizontal line from that Low. The line will dynamically update as new bars are added to the chart.
        The efs was created by slightly modifying and combining into a single script the example shown in this post (in that case the highest High was used)
        Hope this helps
        Alex

        PHP Code:
        function preMain(){
            
        setPriceStudy(true);
            
        setShowCursorLabel(false);
        }

        function 
        main(){

            var 
        llvBI lowestBarNdx(60,low());
            
        drawLineRelative(llvBI,low(llvBI),0,low(llvBI), PS_SOLID,2Color.red,"line1");

            return;
        }

        function 
        lowestBarNdx(Length,Source) {
            var 
        vValue   Source.getValue(0);
            var 
        barIndex 0;
            for(var 
        0Lengthi++) {
                
        vValue Math.min(vValueSource.getValue(-i));
                if(
        vValue == Source.getValue(-i)){
                    
        barIndex getCurrentBarIndex()-i;
                }
            }
            return 
        barIndex;

        Comment

        Working...
        X