Announcement

Collapse
No announcement yet.

EFS assistance

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

  • EFS assistance

    I'd like to add a feature to this existing code for intraday high low efs.
    If current intraday range is <=10.5, I'd like "3/2" text written above price bar the first time it's true (so not every price bar if <=10.5).
    If current intraday range >10.5, then "5/4" text above first price bar once true.
    Thank you in advance for the assistance.


    function preMain() {
    setStudyTitle("Day High/Low");
    setCursorLabelName("Day's High", 0);
    setCursorLabelName("Day's Low", 1);
    setPriceStudy(true);
    //setStudyMax(20);
    //setStudyMin(0);
    }

    var vFlag = true;
    var vHigh = null;
    var vLow = null;
    var vDay1 = null;
    var vDay2 = null;

    function main() {
    var nState = getBarState();


    if (nState == BARSTATE_NEWBAR) {
    if (vDay1 == null) {
    vDay2 = getDay();
    } else {
    vDay2 = vDay1;
    }
    vDay1 = getDay();
    if (vDay1 != vDay2) {
    vHigh = null;
    vLow = null;
    vFlag = true;
    }
    var vHour = getHour();
    if (vHour >= 16) {
    vFlag = false;
    }
    }

    if (vFlag == true) {
    if (vHigh == null) {
    vHigh = high();
    }
    if (vLow == null) {
    vLow = low();
    }
    vHigh = Math.max(high(), vHigh);
    vLow = Math.min(low(), vLow);
    }

    drawTextRelative(-10, vHigh, "High is " + vHigh + " Low is " + vLow, Color.black, Color.red, Text.FRAME | Text.ONTOP | Text.BOLD | Text.RIGHT | Text.TOP, null, null, "OS");
    return new Array(vHigh, vLow);
    }
    Michael

  • #2
    Hello michaelm,

    Here's a solution for you. The heart of the changes are on lines 55-66.

    michaelmRangeText.efs



    PHP Code:
    function preMain() {
    setStudyTitle("Day High/Low");
    setCursorLabelName("Day's High"0);
    setCursorLabelName("Day's Low"1);
    setPriceStudy(true);
    //setStudyMax(20);
    //setStudyMin(0);
    }

    var 
    vFlag true;
    var 
    vFlag2 true;
    var 
    vFlag3 true;
    var 
    vHigh null;
    var 
    vLow null;
    var 
    vDay1 null;
    var 
    vDay2 null;
    var 
    vBarCntr 0;

    function 
    main() {
    var 
    nState getBarState();


    if (
    nState == BARSTATE_NEWBAR) {
    vBarCntr += 1;
    if (
    vDay1 == null) {
    vDay2 getDay();
    } else {
    vDay2 vDay1;
    }
    vDay1 getDay();
    if (
    vDay1 != vDay2) {
    vHigh null;
    vLow null;
    vFlag true;
    vFlag2 true;
    vFlag3 true;
    }
    var 
    vHour getHour();
    if (
    vHour >= 16) {
    vFlag false;
    }
    }

    if (
    vFlag == true) {
    if (
    vHigh == null) {
    vHigh high();
    }
    if (
    vLow == null) {
    vLow low();
    }
    vHigh Math.max(high(), vHigh);
    vLow Math.min(low(), vLow);
    }

    if (
    vFlag2 == true && vHigh vLow <= 10.5) {
        
    drawTextRelative(0vHigh"3/2"Color.blackColor.red
            
    Text.FRAME Text.ONTOP Text.BOLD Text.CENTER Text.BOTTOM
            
    nullnull"3/2"+vBarCntr);
        
    vFlag2 false;
    }

    if (
    vFlag3 == true && vHigh vLow 10.5) {
        
    drawTextRelative(0vHigh"5/4"Color.blackColor.red
            
    Text.FRAME Text.ONTOP Text.BOLD Text.CENTER Text.BOTTOM
            
    nullnull"5/4"+vBarCntr);
        
    vFlag3 false;
    }

    drawTextRelative(-10vHigh"High is " vHigh " Low is " vLowColor.blackColor.red
    Text.FRAME Text.ONTOP Text.BOLD Text.RIGHT Text.TOPnullnull"OS");
    return new Array(
    vHighvLow);

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      thanks, jason.
      Michael

      Comment

      Working...
      X