Announcement

Collapse
No announcement yet.

drawTextRelative() function

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

  • drawTextRelative() function

    Why does only one line of the “drawTextRelative()” function executes and not both?
    Can, and how do you get both to execute in the same efs script?

    PHP Code:
    function preMain(){

    setPriceStudy(true);

    var 
    nPbUp null;
    var 
    nPbDn null;
    var 
    BarCntr 0;
    }
    function 
    main() {

    var 
    PB efsExternal("/My EFS scripts/Price Bands.efs");

    var 
    PBHi getSeries(PB,0);
    var 
    nPBHi PBHi.getValue();
    var 
    PrevPbHi PBHi.getValue(-1);
    var 
    BarHi getValue("High");
    var 
    ctPbUp getGlobalValue("nPbUp");
    var 
    PBLo getSeries(PB,1);
    var 
    nPBLo PBLo.getValue();
    var 
    PrevPbLo PBLo.getValue(-1);
    var 
    BarLo getValue("Low");
    var 
    ctPbDn getGlobalValue("nPbDn");

    // Count Up Bars
    if( nPBHi PrevPbHi && BarHi == nPBHi ) {
        
    ctPbUp = ++ctPbUp
    } else { ctPbUp };
    setGlobalValue("nPbUp"ctPbUp);

    // Count Down Bars
    if ( nPBLo PrevPbLo && BarLo == nPBLo ) {
        
    ctPbDn = ++ctPbDn
    } else { ctPbDn };
    setGlobalValue("nPbDn"ctPbDn);

    //debugPrintln("Symbol: " + getSymbol());
    //debugPrintln("Interval: " + getInterval());
    //debugPrintln("CurrentBar: " + getCurrentBarIndex());
    //debugPrintln(" PBHi: " + getSeries(PB,0), "PBLo: " + getSeries( PB,1));
    debugPrintln" ctPbDn: " ctPbDn" ctPbUp: " ctPbUp,  "CurrentBar: " getCurrentBarIndex());


    drawTextRelative0AboveBar2getGlobalValue("nPbUp"), nullnullText.PRESETnullnull );
    drawTextRelative0BelowBar2getGlobalValue("nPbDn"), nullnullText.PRESETnullnull );


    return


  • #2
    Earthling
    Actually both lines are executed but because you omitted to add a tagID parameter in the drawTextRelative() functions to identify the different graphic objects only one of them gets drawn. The correct code is enclosed below.
    PHP Code:
    drawTextRelative0AboveBar2getGlobalValue("nPbUp"), nullnullText.PRESETnullnull"Text1" rawtime(0) );
    drawTextRelative0BelowBar2getGlobalValue("nPbDn"), nullnullText.PRESETnullnull"Text2" rawtime(0) ); 
    You can replace rawtime(0) with a counter of your own or with the getCurrentBarCount() functtion or any other method that returns a unique value on every bar.
    For more information and examples on how to use graphical objects in efs see the Guide to Developing EFS Graphics which is available in the EFS KnowledgeBase under Help Guides and Tutorials
    Alex

    Comment

    Working...
    X