Announcement

Collapse
No announcement yet.

lines and texts are not refreshed correctly.

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

  • lines and texts are not refreshed correctly.

    I wrote this following code to some line and text drawing feature. I applied it to $SPX chart. What I expected is the table color alterates between blue and red every time the main() is called and the value of the text ("q") increases by one. However, when I specify the interval as 1 tick ("T"), the text is displayed as I expected, but the table is never shown. If I set the interval to one minute, the table was drawn and the text was shown only when the new bar was starting to drawn. During the same bar (within the same minute), although the current price was changing, the value of "q" was increased by one ( which means the main() was called whenever the current $SPX quote changed ), however they were never refreshed unless I use my mouse to click on the indicator pane. Anyone knows how to explicitly request a refreshing within the efs?




    function preMain() {
    setStudyMin(0);
    setStudyMax(100);

    }

    var q = 0;
    var c = 0;

    function main() {

    if (getCurrentBarIndex()==0 ) {
    var x0, y0, dx, dy, nx, ny, i, j, tn;
    nx = 12;
    ny = 4;
    x0 = -80;
    y0 = 10;
    dx = 5;
    dy = 20;

    if ( c == 0 ) {
    for ( i = 0; i <= ny; i++ ) {
    tn = "H" + i;
    drawLineRelative(x0, y0 + dy * i, x0 + dx * nx, y0 + dy * i, PS_SOLID, 2, Color.blue, tn);
    }
    for ( j = 0; j <= nx; j++ ) {
    tn = "V" + j;
    drawLineRelative(x0 + dx * j, y0, x0 + dx * j, y0 + dy * ny, PS_SOLID, 2, Color.blue, tn);
    }
    c = 1;
    }
    else {
    for ( i = 0; i <= ny; i++ ) {
    tn = "H" + i;
    drawLineRelative(x0, y0 + dy * i, x0 + dx * nx, y0 + dy * i, PS_SOLID, 2, Color.red, tn);
    }
    for ( j = 0; j <= nx; j++ ) {
    tn = "V" + j;
    drawLineRelative(x0 + dx * j, y0, x0 + dx * j, y0 + dy * ny, PS_SOLID, 2, Color.red, tn);
    }
    c = 0;
    }

    q = q + 1;

    var f_font = "Arial";
    var f_size = 8;

    removeText("q");
    drawTextRelative(x0 + 1, y0 + dy * 2 + 16, q, Color.blue, Color.white, Text.ONTOP | Text.BOLD, f_font, f_size, "q");

    }
    }
Working...
X