Announcement

Collapse
No announcement yet.

how to plot during the progress of the bar

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

  • how to plot during the progress of the bar

    i have a formula that i reused form the lib. Basically, it plots the NR7. However it plots the WR7(Widest range in 7 bars) only at the end of the bar.
    How do i change it so that the plotting of the text happens as soon as it detects WR7
    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("NR7");
    }

    function 
    main() {
        var 
    nState getBarState();
        if (
    nState == BARSTATE_NEWBAR) {
            var 
    widest_bar_index "";
            var 
    narrowest_bar_index "";
            var 
    narrowest_width 500000;
            var 
    widest_width 0;
            for (var 
    8>= 1i--) {
                var 
    width_of_bar high(-i) - low(-i);
                if (
    width_of_bar narrowest_width) {
                    
    narrowest_width width_of_bar;
                    
    narrowest_bar_index i;
                } else if (
    width_of_bar widest_width) {
                    
    widest_width width_of_bar;
                    
    widest_bar_index i;
                }
            }
            var 
    symbol getSymbol();
            if (
    narrowest_bar_index == 1) {
                
    // last bar was an NR7
                //var this_hour = getHour(1);
                //var this_minute = getMinute(1);
                //if ((this_hour >= 10 && this_hour < 16) || (this_hour == 9 && this_minute > 30)) {
                    
    drawTextRelative( -1AboveBar1"N"Color.greennullText.PRESET Text.BOLDnull12);
                
    //    debugPrintln(symbol + " NR7 in last bar: " + this_hour + ":" + this_minute + " (" + narrowest_width + ")");
                //}
                //} else {
                //var this_hour = getHour(-narrowest_bar_index);
                //var this_minute = getMinute(-narrowest_bar_index);
                //debugPrintln(symbol + " NR7 in bar: " + this_hour + ":" + this_minute + " (" + narrowest_width + ")");
            
    }
            if (
    widest_bar_index == 1) {
                
    // last bar was an WR7
                //var this_hour = getHour(-1);
                //var this_minute = getMinute(-1);
                //if ((this_hour >= 10 && this_hour < 16) || (this_hour == 9 && this_minute > 30)) {
                    
    drawTextRelative( -1AboveBar1"H"Color.rednullText.PRESET Text.BOLDnull12);
                
    //    debugPrintln(symbol + " WR7 in last bar: " + this_hour + ":" + this_minute + " (" + widest_width + ")");
                //}
            //} else {
            //    var this_hour = getHour(-widest_bar_index);
                //var this_minute = getMinute(-widest_bar_index);
                //debugPrintln(symbol + " WR7 in bar: " + this_hour + ":" + this_minute + " (" + widest_width + ")");
            
    }

        }


  • #2
    Help-Help plot during the execution of the bar

    i tried to change the code
    nState == BARSTATE_CURRENTBAR
    It only plots the last bar.
    so i changed it to


    (nState == BARSTATE_CURRENTBAR)|| (nState == BARSTATE_NEWBAR) )
    It still plots only the end of the bar. how do i plot if i get a signal during the ticks of the bar.

    Comment

    Working...
    X