Announcement

Collapse
No announcement yet.

2012 Sep: Developing A Multi-Level Strategy by Vladimir Vladimirovich Voznjuk

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

  • 2012 Sep: Developing A Multi-Level Strategy by Vladimir Vladimirovich Voznjuk

    File Name: MultiPairIndicator.efs

    Description:
    Pair Trading. Developing A Multi-Level Strategy by Vladimir Vladimirovich Voznjuk

    Formula Parameters:

    MultiPairIndicator.efs
    Symbol 1: 6J #F
    Symbol 2: 6E #F
    One-way Pair: false
    Lower Band: -0.01
    Upper Band: 0.01
    Signal Method: Levels
    Buy Color: blue
    Sell Color: red


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

    Download File:
    MultiPairIndicator.efs

    MultiPairIndicator.efs


    EFS Code:
    PHP Code:
    /*********************************
    Provided By:  
    eSignal (Copyright c eSignal), a division of Interactive Data 
    Corporation. 2012. All rights reserved. This sample eSignal 
    Formula Script (EFS) is for educational purposes only and may be 
    modified and saved under a new file name.  eSignal is not responsible
    for the functionality once modified.  eSignal reserves the right 
    to modify and overwrite this EFS file with each new release.

    Description:     
        Pair Trading. Developing A Multi-Level Strategy by Vladimir Vladimirovich Voznjuk

    Version:            1.00  16/07/2012

    Formula Parameters:                         Default:
        Symbol 1                                  6J #F
        Symbol 2                                  6E #F 
        One-way Pair                              false
        Lower Band                                -0.01
        Upper Band                                0.01
        Signal Method                             Levels 
        Buy Color                                 blue
        Sell Color                                red 
        
    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();

    function 
    preMain()
    {   
        
    setStudyTitle("MultiPair Indicator");      
        
    setIntervalsBackfill(true);  
        
        var 
    0;
        
        
    fpArray[x] = new FunctionParameter("gSymbol1"FunctionParameter.STRING);
        
    with(fpArray[x++])
        {
            
            
    setName("Symbol 1");        
            
    setDefault("6J #F");
        }     
        
        
    fpArray[x] = new FunctionParameter("gSymbol2"FunctionParameter.STRING);
        
    with(fpArray[x++])
        {
            
    setName("Symbol 2");        
            
    setDefault("6E #F");
        }     
        
        
    fpArray[x] = new FunctionParameter("gOneWay"FunctionParameter.BOOLEAN);
        
    with(fpArray[x++])
        {
            
    setName("One-way Pair");        
            
    setDefault(false);
        }    
        
        
    fpArray[x] = new FunctionParameter("gLower"FunctionParameter.NUMBER);
        
    with(fpArray[x++])
        {
            
    setName("Lower Band");        
            
    setDefault(-0.01);
        } 
        
        
    fpArray[x] = new FunctionParameter("gUpper"FunctionParameter.NUMBER);
        
    with(fpArray[x++])
        {
            
    setName("Upper Band");        
            
    setDefault(0.01);
        } 
        
        
    fpArray[x] = new FunctionParameter("gMethod"FunctionParameter.STRING);
        
    with(fpArray[x++])
        {
            
    setName("Signal Method");
            
    addOption("Levels");
            
    addOption("Zero line");         
            
    setDefault("Levels");
        } 
        
        
    fpArray[x] = new FunctionParameter("gBuyColor"FunctionParameter.COLOR);
        
    with(fpArray[x++])
        {
            
    setName("Buy Color");        
            
    setDefault(Color.blue);
        } 
        
        
    fpArray[x] = new FunctionParameter("gSellColor"FunctionParameter.COLOR);
        
    with(fpArray[x++])
        {
            
    setName("Sell Color");        
            
    setDefault(Color.red);
        } 
    }

    var 
    bInit false;
    var 
    bVersion null;

    var 
    xSymbol2Open null;
    var 
    xSymbol2Close null;

    var 
    xSymbol1Open null;
    var 
    xSymbol1Close null;

    var 
    vInterval null;

    function 
    main(gSymbol1gSymbol2gOneWaygLowergUppergMethod,gBuyColor,gSellColor)
    {
        if (
    bVersion == nullbVersion verify();
        if (
    bVersion == false) return; 
        
        if (!
    bInit)
        {
            
    vInterval getInterval();
            
    xSymbol2Open open(sym(gSymbol2+","+vInterval));
            
    xSymbol2Close close(sym(gSymbol2+","+vInterval));
            
            
    xSymbol1Open open(sym(gSymbol1+","+vInterval));
            
    xSymbol1Close close(sym(gSymbol1+","+vInterval));
            
            
    addBand(gLower,PS_SOLID,1,gBuyColor,0);
            
    addBand(gUpper,PS_SOLID,1,gSellColor,1);
            
    addBand(0,PS_SOLID,1,Color.lime,2);
            
            
    bInit true;
        }

        var 
    vSymbol2Open_0 xSymbol2Open.getValue(0);
        var 
    vSymbol2Open_1 xSymbol2Open.getValue(-1);
        
        var 
    vSymbol2Close_0 xSymbol2Close.getValue(0);
        var 
    vSymbol2Close_1 xSymbol2Close.getValue(-1);
        
        var 
    vSymbol1Open_0 xSymbol1Open.getValue(0);
        var 
    vSymbol1Open_1 xSymbol1Open.getValue(-1);
            
        var 
    vSymbol1Close_0 xSymbol1Close.getValue(0);
        var 
    vSymbol1Close_1 xSymbol1Close.getValue(-1);
        
        if (
    vSymbol2Open_1 == null || vSymbol2Close_1 == null || vSymbol1Open_1 == null || vSymbol1Close_1 == null
            return;
        
        var 
    vRes_0 0;
        var 
    vRes_1 0;
        
        if (
    gOneWay)
        {
            
    vRes_0 = (vSymbol2Close_0 vSymbol2Open_0)+(vSymbol1Close_0 vSymbol1Open_0);
            
    vRes_1 = (vSymbol2Close_1 vSymbol2Open_1)+(vSymbol1Close_1 vSymbol1Open_1);
        }
        else
        {
            
    vRes_0 = (vSymbol2Close_0 vSymbol2Open_0)-(vSymbol1Close_0 vSymbol1Open_0);
            
    vRes_1 = (vSymbol2Close_1 vSymbol2Open_1)-(vSymbol1Close_1 vSymbol1Open_1);
        }
        
        var 
    nBarsCount getCurrentBarCount();
        
        if (
    gMethod == "Levels")
        {   
            if (
    vRes_0>gUpper && vRes_1<gUpper
            {
                
    drawShapeRelative(0TopRow2  Shape.DOWNARROWnullgSellColorShape.PRESET,"LDn"+nBarsCount);         
            } 
            else
            {
                
    removeShape("LDn"+nBarsCount);
            }

            if (
    vRes_0<gLower && vRes_1>gLower
            {
                
    drawShapeRelative(0BottomRow2  Shape.UPARROWnullgBuyColorShape.PRESET,"LUp"+nBarsCount);
            } 
            else
            {
                
    removeShape("LUp"+nBarsCount);
            }
        }
        
        if (
    gMethod == "Zero line")
        {   
            if (
    vRes_1<&& vRes_0>0
            {
                
    drawShapeRelative(0BottomRow2  Shape.UPARROWnullgBuyColorShape.PRESET,"ZUp"+nBarsCount); 
            } 
            else
            {
                
    removeShape("ZUp"+nBarsCount);
            }

            if (
    vRes_1>&& vRes_0<0
            {
                
    drawShapeRelative(0TopRow2  Shape.DOWNARROWnullgSellColorShape.PRESET,"ZDn"+nBarsCount);           
            } 
            else
            {
                
    removeShape("ZDn"+nBarsCount);
            }
        }
        
        return 
    vRes_0;
    }

    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;

Working...
X