Announcement

Collapse
No announcement yet.

EFS help need (Breakout Inside Day)

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

  • EFS help need (Breakout Inside Day)

    Hi,

    I wrote a simple code which determine the Breakout Inside Day (BID) setup...

    Here is my code:

    PHP Code:
    var lastrawtime 0;
    var 
    BarCount 0;

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Breakout_ID");
        
    setShowCursorLabel(false);
        
    setDefaultPriceBarColorColor.black );
        
    //setComputeOnClose();
    }

    function 
    main() {

        if (
    lastrawtime != getValue("rawtime"0)) {
         
    BarCount += 1;
         
    lastrawtime getValue("rawtime"0);
        }    
       
        if (
    high(-2) > high(-1) && low(-2) < low(-1) && low(0) < low(-2)){
            
    setPriceBarColor(Color.red);
            
    Alert.addToList(getSymbol(), "BID Short"Color.blackColor.red);
            
    nLastRawTime getValue("rawtime",0);
        }else{
           
    removeText("Dn"+BarCount);
        }
        if (
    high(-2) > high(-1) && low(-2) < low(-1) && high(0) > high(-2)){
            
    setPriceBarColor(Color.blue);
            
    Alert.addToList(getSymbol(), "BID Long"Color.blackColor.blue);
            
    nLastRawTime getValue("rawtime",0);
        }else{
           
    removeText("UP"+BarCount);
        }
        return 
    null;

    See example 1



    My question is how would I change the code so that:

    1. The ID setup bars painted as well (better a different color)
    2. The code to mark any bar that the BID occur (not only the next bar) what meet the conditions.

    See example 2




    I would appreciate any tips!
    Best wishes,

  • #2
    Hello Nooze,

    You would need to be able to paint historical price bars when the BID bar is detected. Unfortunately, EFS does not have that ability. Alternatively, you could draw a line from the high or low of the setup bar to the BID bar like below. Or you could draw shapes or text on the setup bars using drawShapeRelative() or drawTextRelative().

    PHP Code:
    var lastrawtime 0;
    var 
    BarCount 0;

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Breakout_ID");
        
    setShowCursorLabel(false);
        
    setDefaultPriceBarColorColor.black );
        
    //setComputeOnClose();
    }

    var 
    nCntr 0;

    function 
    main() {    
        if (
    getBarState() == BARSTATE_NEWBAR) {
            
    nCntr++
            if (
    nCntr 100nCntr 0;
        }
        if (
    lastrawtime != getValue("rawtime"0)) {
         
    BarCount += 1;
         
    lastrawtime getValue("rawtime"0);
        }    
       
        if (
    high(-2) > high(-1) && low(-2) < low(-1) && low(0) < low(-2)){
            
    drawLineRelative(-2low(-2), 0low(-2), PS_SOLID2Color.magenta"low"+nCntr);
            
    setPriceBarColor(Color.red);
            
    Alert.addToList(getSymbol(), "BID Short"Color.blackColor.red);
            
    nLastRawTime getValue("rawtime",0);
        }else{
           
    removeText("Dn"+BarCount);
        }
        if (
    high(-2) > high(-1) && low(-2) < low(-1) && high(0) > high(-2)){
            
    drawLineRelative(-2high(-2), 0high(-2), PS_SOLID2Color.magenta"high"+nCntr);
            
    setPriceBarColor(Color.blue);
            
    Alert.addToList(getSymbol(), "BID Long"Color.blackColor.blue);
            
    nLastRawTime getValue("rawtime",0);
        }else{
           
    removeText("UP"+BarCount);
        }
        return 
    null;

    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

    Working...
    X