2011 Mar: Three-Bar Inside Bar Pattern

ICE Data Services -


ThreeBar_IBP.efs  EFSLibrary - Discussion Board
  

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:


/*********************************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/2011Formula 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  www.traders.com.**********************************/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 i = 0;var entryPrice = 0;var startPos = 0;function main(gPT, gSL){    if (bVersion == null) bVersion = verify();    if (bVersion == false) return;       if (getCurrentBarIndex() == 0 || getCurrentBarCount() < 4) return;        if ((high(0) < high(-1)) && (low(0) > low(-1)))    {        drawLineRelative(-1,high(-1),0,high(-1), PS_SOLID, 1, Color.grey, i++);        drawLineRelative(-1,low(-1),0,low(-1), PS_SOLID, 1, Color.grey, i++);    }    // Exit Strategy    if (Strategy.isLong())    {            startPos --;            if (high(0) >= entryPrice+entryPrice*(gPT / 100))            {//limit long position                Strategy.doSell("Exit Long", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, Math.max(open(0), (entryPrice+entryPrice*(gPT / 100))));                drawShapeRelative(0,AboveBar1, Shape.DOWNARROW, null, Color.lime, Shape.PRESET, i++);                drawTextRelative(0,AboveBar2, "Sell", Color.white, Color.lime, Text.PRESET|Text.FRAME|Text.CENTER, "Arial", 10, i++);                drawTextRelative(0,AboveBar3, "0", Color.lime, null, Text.PRESET | Text.CENTER, "Arial", 10, i++);                                drawLineRelative(startPos, open(startPos), 0, open(0), PS_SOLID, 2, Color.yellow, i++);            }            if (low(0) <= entryPrice-entryPrice*(gSL / 100))            {//stop long position                Strategy.doSell("Exit Long", Strategy.STOP, Strategy.THISBAR, Strategy.ALL, Math.min(open(0), (entryPrice-entryPrice*(gSL / 100))));                drawShapeRelative(0,AboveBar1, Shape.DOWNARROW, null, Color.lime, Shape.PRESET, i++);                drawTextRelative(0,AboveBar2, "Sell", Color.white, Color.lime, Text.PRESET|Text.FRAME|Text.CENTER, "Arial", 10, i++);                drawTextRelative(0,AboveBar3, "0", Color.lime, null, Text.PRESET | Text.CENTER, "Arial", 10, i++);                                drawLineRelative(startPos, open(startPos), 0, open(0), PS_SOLID, 2, Color.yellow, i++);            }    }    if (Strategy.isShort())    {            startPos--;            if (low(0) <= entryPrice-entryPrice*(gPT / 100))            {//limit short position                Strategy.doCover("Exit Short", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, Math.min(open(0), (entryPrice-entryPrice*(gSL / 100))));                drawShapeRelative(0,BelowBar1, Shape.UPARROW, null, Color.red, Shape.PRESET, i++);                drawTextRelative(0,BelowBar2, "Cover", Color.white, Color.red, Text.PRESET|Text.FRAME|Text.CENTER, "Arial", 10, i++);                drawTextRelative(0,BelowBar3, "0", Color.red, null, Text.PRESET|Text.CENTER, "Arial", 10, i++);                                drawLineRelative(startPos, open(startPos), 0, open(0), PS_SOLID, 2, Color.yellow, i++);            }            if (high(0) >= entryPrice+entryPrice*(gSL / 100))            {//stop short position                Strategy.doCover("Exit Short", Strategy.STOP, Strategy.THISBAR, Strategy.ALL, Math.max(open(0), (entryPrice+entryPrice*(gSL / 100))));                drawShapeRelative(0,BelowBar1, Shape.UPARROW, null, Color.red, Shape.PRESET, i++);                drawTextRelative(0,BelowBar2, "Cover", Color.white, Color.red, Text.PRESET|Text.FRAME|Text.CENTER, "Arial", 10, i++);                drawTextRelative(0,BelowBar3, "0", Color.red, null, Text.PRESET|Text.CENTER, "Arial", 10, i++);                                drawLineRelative(startPos, open(startPos), 0, open(0), PS_SOLID, 2, Color.yellow, i++);            }    }    // 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.MARKET, Strategy.THISBAR);                drawShapeRelative(0,BelowBar1, Shape.UPARROW, null, Color.lime, Shape.PRESET, i++);                drawTextRelative(0,BelowBar2, "Buy", Color.white, Color.lime, Text.PRESET|Text.FRAME|Text.CENTER, "Arial", 10, i++);                drawTextRelative(0,BelowBar3, "1", Color.lime, null, Text.PRESET|Text.CENTER, "Arial", 10, i++);                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.MARKET, Strategy.THISBAR);                drawShapeRelative(0,AboveBar1, Shape.DOWNARROW, null, Color.red, Shape.PRESET, i++);                drawTextRelative(0,AboveBar2, "Short", Color.white, Color.red, Text.PRESET|Text.FRAME|Text.CENTER, "Arial", 10, i++);                drawTextRelative(0,AboveBar3, "-1", Color.red, null, Text.PRESET  | Text.CENTER, "Arial", 10, i++);                entryPrice = close(-1);                startPos = 0;            }    }    if (Strategy.isLong()) setBarBgColor(Color.darkgreen);    if (Strategy.isShort()) setBarBgColor(Color.maroon);        }function verify() {    var b = false;    if (getBuildNumber() < 779) {        drawTextAbsolute(5, 35, "This study requires version 8.0 or later.",             Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,            null, 13, "error");        drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp",             Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,            null, 13, "upgrade");        return b;    } else {        b = true;    }    return b;}