Announcement

Collapse
No announcement yet.

2011 Mar: Three-Bar Inside Bar Pattern

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2011 Mar: Three-Bar Inside Bar Pattern

    File Name: ThreeBar_IBP.efs

    Description:
    Three-Bar Inside Bar Pattern

    Formula Parameters:
    Profit Target Level: 0.75
    Stop-loss Level: 0.75

    Notes:
    The related article is copyrighted material. If you are not
    a subscriber of Stocks & Commodities, please visit
    www.traders.com.

    Download File:
    ThreeBar_IBP.efs



    EFS Code:
    PHP Code:
    /*********************************
    Provided By:  
        Interactive Data Corporation (Copyright © 2010) 
        All rights reserved. This sample eSignal Formula Script (EFS)
        is for educational purposes only. Interactive Data Corporation
        reserves the right to modify and overwrite this EFS file with 
        each new release. 
        
    Description:        
        Three-Bar Inside Bar Pattern 
     
    Version:            1.0  14/01/2011

    Formula Parameters:                     Default:
        Profit Target Level                   0.75
        Stop-loss Level                       0.75
        
        
    Notes:
     The related article is copyrighted material. If you are not
     a subscriber of Stocks & Commodities, please visit 
     [url]www.traders.com.[/url]

    **********************************/
    var fpArray = new Array();
    var 
    bVersion null;
    function 
    preMain()
    {

        
    setPriceStudy(true);
        
        var 
    x=0;
        
    fpArray[x] = new FunctionParameter("gPT"FunctionParameter.NUMBER);
        
    with(fpArray[x++])
        {
        
    setName("Profit Target Level");
        
    setLowerLimit(0.0001);
            
    setDefault(0.75);
        }
        
    fpArray[x] = new FunctionParameter("gSL"FunctionParameter.NUMBER);
        
    with(fpArray[x++])
        {
        
    setName("Stop-loss Level");
        
    setLowerLimit(0.0001);
            
    setDefault(0.75);
        }    
    }

    var 
    0;
    var 
    entryPrice 0;
    var 
    startPos 0;
    function 
    main(gPTgSL)
    {
        if (
    bVersion == nullbVersion verify();
        if (
    bVersion == false) return;   

        if (
    getCurrentBarIndex() == || getCurrentBarCount() < 4) return;
        
        if ((
    high(0) < high(-1)) && (low(0) > low(-1)))
        {
            
    drawLineRelative(-1,high(-1),0,high(-1), PS_SOLID1Color.greyi++);
            
    drawLineRelative(-1,low(-1),0,low(-1), PS_SOLID1Color.greyi++);
        }

        
    // Exit Strategy
        
    if (Strategy.isLong())
        {
                
    startPos --;
                if (
    high(0) >= entryPrice+entryPrice*(gPT 100))
                {
    //limit long position
                    
    Strategy.doSell("Exit Long"Strategy.LIMITStrategy.THISBARStrategy.ALL
                        
    Math.max(open(0), (entryPrice+entryPrice*(gPT 100))));
                    
    drawShapeRelative(0,AboveBar1Shape.DOWNARROWnullColor.limeShape.PRESETi++);
                    
    drawTextRelative(0,AboveBar2"Sell"Color.whiteColor.lime
                        
    Text.PRESET|Text.FRAME|Text.CENTER"Arial"10i++);
                    
    drawTextRelative(0,AboveBar3"0"Color.limenullText.PRESET Text.CENTER"Arial"10i++);
                    
    drawLineRelative(startPosopen(startPos), 0open(0), PS_SOLID2Color.yellowi++);
                }
                if (
    low(0) <= entryPrice-entryPrice*(gSL 100))
                {
    //stop long position
                    
    Strategy.doSell("Exit Long"Strategy.STOPStrategy.THISBARStrategy.ALL
                        
    Math.min(open(0), (entryPrice-entryPrice*(gSL 100))));
                    
    drawShapeRelative(0,AboveBar1Shape.DOWNARROWnullColor.limeShape.PRESETi++);
                    
    drawTextRelative(0,AboveBar2"Sell"Color.whiteColor.lime
                        
    Text.PRESET|Text.FRAME|Text.CENTER"Arial"10i++);
                    
    drawTextRelative(0,AboveBar3"0"Color.limenullText.PRESET Text.CENTER"Arial"10i++);
                    
    drawLineRelative(startPosopen(startPos), 0open(0), PS_SOLID2Color.yellowi++);
                }
        }
        if (
    Strategy.isShort())
        {
                
    startPos--;
                if (
    low(0) <= entryPrice-entryPrice*(gPT 100))
                {
    //limit short position
                    
    Strategy.doCover("Exit Short"Strategy.LIMITStrategy.THISBARStrategy.ALL
                        
    Math.min(open(0), (entryPrice-entryPrice*(gSL 100))));
                    
    drawShapeRelative(0,BelowBar1Shape.UPARROWnullColor.redShape.PRESETi++);
                    
    drawTextRelative(0,BelowBar2"Cover"Color.whiteColor.red
                        
    Text.PRESET|Text.FRAME|Text.CENTER"Arial"10i++);
                    
    drawTextRelative(0,BelowBar3"0"Color.rednullText.PRESET|Text.CENTER"Arial"10i++);
                    
    drawLineRelative(startPosopen(startPos), 0open(0), PS_SOLID2Color.yellowi++);
                }
                if (
    high(0) >= entryPrice+entryPrice*(gSL 100))
                {
    //stop short position
                    
    Strategy.doCover("Exit Short"Strategy.STOPStrategy.THISBARStrategy.ALL
                        
    Math.max(open(0), (entryPrice+entryPrice*(gSL 100))));
                    
    drawShapeRelative(0,BelowBar1Shape.UPARROWnullColor.redShape.PRESETi++);
                    
    drawTextRelative(0,BelowBar2"Cover"Color.whiteColor.red
                        
    Text.PRESET|Text.FRAME|Text.CENTER"Arial"10i++);
                    
    drawTextRelative(0,BelowBar3"0"Color.rednullText.PRESET|Text.CENTER"Arial"10i++);
                    
    drawLineRelative(startPosopen(startPos), 0open(0), PS_SOLID2Color.yellowi++);
                }
        }

        
    // Entry Strategy
        
    if (!Strategy.isInTrade())
        {
                if ((
    close(-1) > close(-2)) && (high(-2) < high(-3)) && (low(-2) > low(-3)) && (close(-3) > close(-4)))
                {
    //entry long position    
                    
    Strategy.doLong ("Entry Long"Strategy.MARKETStrategy.THISBAR);
                    
    drawShapeRelative(0,BelowBar1Shape.UPARROWnullColor.limeShape.PRESETi++);
                    
    drawTextRelative(0,BelowBar2"Buy"Color.whiteColor.lime
                        
    Text.PRESET|Text.FRAME|Text.CENTER"Arial"10i++);
                    
    drawTextRelative(0,BelowBar3"1"Color.limenullText.PRESET|Text.CENTER"Arial"10i++);
                    
    entryPrice close(-1);
                    
    startPos 0;
                }
                if ((
    close(-1) < close(-2)) && (high(-2) < high(-3)) && (low(-2) > low(-3)) && close(-3) < close(-4)) 
                {
    //entry short position   
                    
    Strategy.doShort ("Entry Short"Strategy.MARKETStrategy.THISBAR);
                    
    drawShapeRelative(0,AboveBar1Shape.DOWNARROWnullColor.redShape.PRESETi++);
                    
    drawTextRelative(0,AboveBar2"Short"Color.whiteColor.red
                        
    Text.PRESET|Text.FRAME|Text.CENTER"Arial"10i++);
                    
    drawTextRelative(0,AboveBar3"-1"Color.rednullText.PRESET  Text.CENTER"Arial"10i++);
                    
    entryPrice close(-1);
                    
    startPos 0;
                }
        }

        if (
    Strategy.isLong()) setBarBgColor(Color.darkgreen);
        if (
    Strategy.isShort()) setBarBgColor(Color.maroon);    
        
    }

    function 
    verify() {
        var 
    false;
        if (
    getBuildNumber() < 779) {
            
    drawTextAbsolute(535"This study requires version 8.0 or later."
                
    Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
                
    null13"error");
            
    drawTextAbsolute(520"Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp"
                
    Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
                
    null13"upgrade");
            return 
    b;
        } else {
            
    true;
        }
        return 
    b;

    Last edited by eSignal; 02-15-2011, 05:52 AM.
Working...
X