2007 May: Long On Talk, Short On Action

ICE Data Services -

TrongoneMA.efs  

EFSLibrary - Discussion Board  

File Name: TrongoneMA.efs

Description:
This study is based on the May 2007 article, Moving Averages: Long On Talk, Short On Action, by Anthony Trongone, PhD.

 

Formula Parameters:

  • SMA Periods: 34
  • Volume Trigger: 100,000,000
  • Lot Size: 1000

Notes:
This system is designed for QQQQ only and is a long only system. This study is designed for real time analysis and back testing. Intra-day time template should be set to 09:30-16:00 ET. The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.

 

Download File:
TrongoneMA.efs



EFS Code:

/***************************************
Provided By : eSignal (c) Copyright 2007
Description:  Moving Averages: Long On Talk, Short On Action 
              by Anthony Trongone, PhD

Version 1.0  3/08/2007

Notes:
* May 2007 Issue of Stocks and Commodities Magazine
* Study requires version 8.0 or later.
* This system is designed for QQQQ only.
* This system is a long only system.
* This study is designed for real time analysis and back testing.
* Intra-day time template should be set to 09:30-16:00 ET


Formula Parameters:                     Default:
SMA Periods                             34
Volume Trigger                          100,000,000
Lot Size                                1000
*****************************************************************/

function preMain() {
    setPriceStudy(true);
    setStudyTitle("Trongone MA ");
    setShowTitleParameters(false);
    setCursorLabelName("TMA", 0);
    setCursorLabelName("Yesterday's Vol", 1);
    setCursorLabelName("Night Session", 2);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarThickness(2, 0);
    

    var fp1 = new FunctionParameter("Periods", FunctionParameter.NUMBER);
        fp1.setName("SMA Periods");
        fp1.setLowerLimit(1);
        fp1.setDefault(34);
    var fp2 = new FunctionParameter("V", FunctionParameter.NUMBER);
        fp2.setName("Volume Trigger");
        fp2.setLowerLimit(0);
        fp2.setDefault(100000000);
    var fp3 = new FunctionParameter("LotSize", FunctionParameter.NUMBER);
        fp3.setName("Lot Size");
        fp3.setLowerLimit(1);
        fp3.setDefault(1000);
}

// Global Variables
var bVersion  = null;    // Version flag
var bInit     = false;   // Initialization flag
var xMA       = null;
var xVol      = null;
var vPosition = 0;      // 0 = flat,  1 = long
var nOpen     = null    // open of first bar of the day
var bBT       = true;   // back test flag

function main(Periods, V, LotSize) {
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;    

    //Initialization
    if (bInit == false) {
        xMA = sma(Periods, inv("D"));
        xVol = volume(inv("D"));
        bInit = true;
    }

    if (isLastBarOnChart()) bBT = false;
    
    var nState = getBarState();
    var nMA    = xMA.getValue(0);
    var nVol_1 = xVol.getValue(-1);
    var sVol_1 = formatVol(nVol_1);
    var nNight = open(0, inv("D")) - close(-1, inv("D"));
    
    if (nMA == null || nVol_1 == null || nNight == null) return;

    if (nState == BARSTATE_NEWBAR && day(0) != day(-1)) {
        nOpen  = open(0);
        if (nVol_1 > V && nNight < 0 && nOpen > nMA) {
            vPosition = 1;
            setBarBgColor(Color.lightgrey);
            drawShape(Shape.UPARROW, BelowBar1, Color.blue);
            Alert.playSound("ding.wav");
            Alert.addToList(getSymbol(), "TMA Long", Color.blue, Color.white);
            if (bBT) Strategy.doLong("TMA Long", Strategy.MARKET, Strategy.THISBAR, LotSize);
        }
    }

    if (vPosition == 1) {
        if (isDWM()) {
            if (nState == BARSTATE_NEWBAR) {
                vPosition = 0;
                if (bBT) Strategy.doSell("Close TMA Long", Strategy.CLOSE, Strategy.THISBAR, LotSize);
            }
        } else if (day(0) == day(-1)) {
            if (day(0) != day(1) && !isLastBarOnChart()) {
                vPosition = 0;
                drawShape(Shape.DIAMOND, AboveBar1, Color.red);
                if (bBT) Strategy.doSell("Close TMA Long", Strategy.CLOSE, Strategy.THISBAR, LotSize);
            }
        }
    }
    
    if (vPosition == 1) setBarBgColor(Color.lightgrey);
    
    return new Array(getSeries(xMA), sVol_1, nNight.toFixed(2));
}


function formatVol(n) {
    if (n == null) return;
    
    var sNum = "";
    var s = n.toFixed(0);
    var nLen = s.length;
    var nCount = 0;
    
    for (var i = nLen; i >= 0; i--) {
        nCount++;    
        if (nCount > 3 && i != 0) {
            sNum = "," + s.substr(i, 1) + sNum;
            nCount = 1;
        } else {
            sNum = s.substr(i, 1) + sNum;
        }
    }
    
    return sNum;
}


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;
}