February 2007
TRADERS' TIPS

Here is this month's selection of Traders' Tips, contributed by various developers of technical analysis software to help readers more easily implement some of the strategies presented in this and other issues.

You can copy these formulas and programs for easy use in your spreadsheet or analysis software. Simply "select" the desired text by highlighting as you would in any word processing program, then use your standard key command for copy or choose "copy" from the browser menu. The copied text can then be "pasted" into any open spreadsheet or other software by selecting an insertion point and executing a paste command. By toggling back and forth between an application window and the open Web page, data can be transferred with ease.

This month's tips include formulas and programs for:

AMIBROKER: MOVING AVERAGE CROSSOVERS
TRADESTATION: MOVING AVERAGE CROSSOVERS
METASTOCK: MOVING AVERAGE CROSSOVERS
eSIGNAL: MOVING AVERAGE CROSSOVERS
WEALTH-LAB: MOVING AVERAGE CROSSOVERS
NEUROSHELL TRADER: MOVING AVERAGE CROSSOVERS
NEOTICKER: MOVING AVERAGE CROSSOVERS
AIQ: MOVING AVERAGE CROSSOVERS
SNAPSHEETS: MOVING AVERAGE CROSSOVERS
STRATASEARCH: MOVING AVERAGE CROSSOVERS
ENSIGN WINDOWS: MOVING AVERAGE CROSSOVERS
TRADECISION: MOVING AVERAGE CROSSOVERS
OMNITRADER PRO: MOVING AVERAGE CROSSOVERS
MULTICHARTS: MOVING AVERAGE CROSSOVERS
TRADE NAVIGATOR/TRADESENSE: MOVING AVERAGE CROSSOVERS
Investor/RT AND MARKETDELTA: VOLUME BREAKDOWN INDICATOR
VT TRADER: MOVING AVERAGE CROSSOVERS

or return to February 2007 Contents


AMIBROKER: MOVING AVERAGE CROSSOVERS

Editor's note: In "Anticipating Moving Average Crossovers" in this issue, author Dimitris Tsokakis already provided code in AmiBroker formula language for his technique, so readers should look for the code in the article and also visit the Subscriber Area of www.Traders.com, https://technical.traders.com/sub/sublog.asp, to copy it into AmiBroker.

GO BACK


TRADESTATION: MOVING AVERAGE CROSSOVERS

Dimitris Tsokakis' article in this issue, "Anticipating Moving Average Crossovers," offers a technique for predicting crosses of two simple moving averages. The article also suggests a method for checking the accuracy of the predictions.

We have translated these techniques into EasyLanguage as two indicators and one ShowMe study. The first indicator shows the proximity of the calculated crossover price to the actual price. The second indicator plots the author's statistics in RadarScreen. Finally, the ShowMe study locates predicted and actual crosses. See Figure 1.

FIGURE 1: TRADESTATION, MOVING AVERAGE CROSSOVERS. In this sample TradeStation chart, the upper subgraph in the upper chart of MSFT shows bars on which predicted and actual moving average crosses occurred. Just below the price bars, in the lower subgraph of the chart, the price required for a cross to take place is plotted as a blue line. The lower window pane is a RadarScreen window. It displays a log of the predicted and actual crosses.
To download this code, go to the Support Center at TradeStation.com. Search for the file "Tsokakis.ELD."
 
ShowMe:  Tsokakis AMAC ShowMe
inputs:
    p( 20 ),
    k( 30 ) ;
variables:
    MAp( 0 ),
    MAk( 0 ),
    kLess1( 0 ),
    MAkLess1( 0 ),
    pLess1( 0 ),
    MApLess1( 0 ),
    TC( 0 ) ;
MAp = Average( Close, p ) ;
MAk = Average( Close, k ) ;
kLess1 = k - 1 ;
MAkLess1 = Average( Close, kLess1 ) ;
pLess1 = p - 1 ;
MApLess1 = Average( Close, pLess1 ) ;
TC = ( p * kLess1 * MAkLess1 - k * pLess1 * MApLess1 ) /
 ( k - p ) ;
if TC crosses over Close then
    Plot1( Close, "TCxOver" )
else if TC crosses under Close then
    Plot2( Close, "TCxUnder" ) ;
if MAp crosses over MAk then
    Plot3( Close, "MApxOver" )
else if MAp crosses under MAk then
    Plot4( Close, "MApxUnder" ) ;
Indicator: Tsokakis AMAC
inputs:
    p( 20 ),
    k( 30 ) ;
variables:
    kLess1( 0 ),
    MAkLess1( 0 ),
    pLess1( 0 ),
    MApLess1( 0 ),
    TC( 0 ) ;
kLess1 = k - 1 ;
MAkLess1 = Average( Close, kLess1 ) ;
pLess1 = p - 1 ;
MApLess1 = Average( Close, pLess1 ) ;
TC = ( p * kLess1 * MAkLess1 - k * pLess1 * MApLess1 ) /
 ( k - p ) ;
Plot1( Close, "Close" ) ;
Plot2( TC, "TC" ) ;
Indicator: Tsokakis AMAC log
inputs:
    p( 20 ),
    k( 30 ) ;
variables:
    MAp( 0 ),
    MAk( 0 ),
    kLess1( 0 ),
    MAkLess1( 0 ),
    pLess1( 0 ),
    MApLess1( 0 ),
    TC( 0 ),
    AscCrossPred( false ),
     DescCrossPred( false ),
     ConfirmedDesc( false ),
    ConfirmedAsc( false ),
    DescTotalPred( 0 ),
    Acc0DescPred( 0 ),
    Acc1DescPred( 0 ),
    Acc2DescPred( 0 ),
    UselessDescPred( 0 ),
    AscTotalPred( 0 ),
    Acc0AscPred( 0 ),
    Acc1AscPred( 0 ),
    Acc2AscPred( 0 ),
    UselessAscPred( 0 ),
    Desc0( 0 ),
    Desc1( 0 ),
    Desc2( 0 ),
    UselessDesc( 0 ),
    FalseDesc( 0 ),
    Asc0( 0 ),
    Asc1( 0 ),
    Asc2( 0 ),
    UselessAsc( 0 ),
    FalseAsc( 0 ) ;
MAp = Average( Close, p ) ;
MAk = Average( Close, k ) ;
kLess1 = k - 1 ;
MAkLess1 = Average( Close, kLess1 ) ;
pLess1 = p - 1 ;
MApLess1 = Average( Close, pLess1 ) ;
TC = ( p * kLess1 * MAkLess1 - k * pLess1 * MApLess1 ) /
 ( k - p ) ;
if TC crosses under Close then
    begin
    AscCrossPred = false ;
    DescCrossPred  = true ;
    end
else if TC crosses over Close then
    begin
    AscCrossPred = true ;
    DescCrossPred  = false ;
    end
else
    begin
    AscCrossPred = false ;
    DescCrossPred  = false ;
    end ;
if MAk crosses under MAp then
    begin
    ConfirmedAsc = false ;
    ConfirmedDesc = true ;
    end
else if MAk crosses over MAp then
    begin
    ConfirmedAsc = true ;
    ConfirmedDesc = false ;
    end
else
    begin
    ConfirmedAsc = false ;
    ConfirmedDesc = false ;
    end ;
if DescCrossPred then
    DescTotalPred = DescTotalPred + 1 ;
if ConfirmedDesc and DescCrossPred[1] then
    Acc0DescPred = Acc0DescPred + 1 ;
if ConfirmedDesc and DescCrossPred[2] then
    Acc1DescPred = Acc1DescPred + 1 ;
if ConfirmedDesc and DescCrossPred[3] then
    Acc2DescPred = Acc2DescPred + 1 ;
if ConfirmedDesc and DescCrossPred then
    UselessDescPred = UselessDescPred + 1 ;
if AscCrossPred then
    AscTotalPred = AscTotalPred + 1 ;
if ConfirmedAsc and AscCrossPred[1] then
    Acc0AscPred = Acc0AscPred + 1 ;
if ConfirmedAsc and AscCrossPred[2] then
    Acc1AscPred = Acc1AscPred + 1 ;
if ConfirmedAsc and AscCrossPred[3] then
    Acc2AscPred = Acc2AscPred + 1 ;
if ConfirmedAsc and AscCrossPred then
    UselessAscPred = UselessAscPred + 1 ;
if DescTotalPred <> 0 then
    begin
    Desc0 = 100 * Acc0DescPred / DescTotalPred ;
    Desc1 = 100 * Acc1DescPred / DescTotalPred ;
    Desc2 = 100 * Acc2DescPred / DescTotalPred ;
    UselessDesc = 100 * UselessDescPred /
     DescTotalPred ;
    end ;
FalseDesc = 100 - Desc0 - Desc1 - Desc2 - UselessDesc ;
if AscTotalPred <> 0 then
    begin
    Asc0 = 100 * Acc0AscPred / AscTotalPred ;
    Asc1 = 100 * Acc1AscPred / AscTotalPred ;
    Asc2 = 100 * Acc2AscPred / AscTotalPred ;
    UselessAsc = 100 * UselessAscPred / AscTotalPred ;
    end ;
FalseAsc = 100 - Asc0 - Asc1 - Asc2 - UselessAsc ;
 
Plot1( Close, "Close" ) ;
Plot2( TC, "TC" ) ;
if LastBarOnChart and GetAppInfo( aiApplicationType ) =
 2 { indicator is applied to RadarScreen } then
    begin
    Plot3( DescTotalPred, "TotalPred" ) ;
    Plot4( Desc0, "Desc0" ) ;
    Plot5( Desc1, "Desc1" ) ;
    Plot6( Desc2, "Desc2" ) ;
    Plot7( UselessDesc, "UselessDesc" ) ;
    Plot8( FalseDesc, "FalseDesc" ) ;
    Plot9( AscTotalPred, "TotalAscPred" ) ;
    Plot10( Asc0, "Asc0" ) ;
    Plot11( Asc1, "Asc1" ) ;
    Plot12( Asc2, "Asc2" ) ;
    Plot13( UselessAsc, "UselessAsc" ) ;
    Plot14( FalseAsc, "FalseAsc" ) ;
    end ;
--Mark Mills
TradeStation Securities, Inc.
www.TradeStation.com


GO BACK


METASTOCK: Moving Average Crossovers

Dimitris Tsokakis' article in this issue, "Anticipating Moving Average Crossovers," introduces a new indicator and two explorations to analyze it. The formula for the indicator and the instructions for adding it to MetaStock are as follows:

1. In the Tools menu, select Indicator Builder.
2. Click New to open the Indicator Editor for a new indicator.
3. Type the name of the formula.
4. Click in the larger window and type in the formula.
5. Click OK to close the Indicator Editor.
Name: the TC graph
Formula:
y:=Input("short MA time periods", 2, 200, 20);
z:=Input("long MA time periods", 3, 200, 30);
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
test:=If(z-y=0,-9999,z-y);
tc:=If(test=-9999, 0,
(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/test);
tc;
C
This indicator will prompt for the time periods of the two moving averages, but it defaults to the values suggested in the article. The explorations and instructions for recreating them in MetaStock are as follows:
1. Select Tools > the Explorer.
2. Click New
3. Enter a name, "SMA cross stats - ascending"
4. Select the Column A tab and enter the following formula.
y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
Cum(ascxpred);
5. Click in the Col Name box and enter the text: "Total."
6. Select the Column B tab and enter the following formula.
 
y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
asctotpred:=Cum(ascxpred);
acc0ascxpred:=Cum(confascx AND Ref(ascxpred,-1));
100*(acc0ascxpred/asctotpred)
7. Click in the Col Name box and enter the text: "1 day".
8. Select the Column C tab and enter the following formula.
 
y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
asctotpred:=Cum(ascxpred);
acc1ascxpred:=Cum(confascx AND Ref(ascxpred,-2));
100*(acc1ascxpred/asctotpred)
9. Click in the Col Name box and enter the text: "2 day."
10. Select the Column D tab and enter the following formula.
 
y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
asctotpred:=Cum(ascxpred);
acc2ascxpred:=Cum(confascx AND Ref(ascxpred,-3));
100*(acc2ascxpred/asctotpred)
11. Click in the Col Name box and enter the text: "3 day."
12. Select the Column E tab and enter the following formula.
 
y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
asctotpred:=Cum(ascxpred);
uslsascxpre:=Cum(confascx AND ascxpred);
100*(uslsascxpre/asctotpred)
13. Click in the Col Name box and enter the text: "useless."
14. Select the Column F tab and enter the following formula.
 
y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
asctotpred:=Cum(ascxpred);
acc0ascxpred:=Cum(confascx AND Ref(ascxpred,-1));
acc1ascxpred:=Cum(confascx AND Ref(ascxpred,-2));
acc2ascxpred:=Cum(confascx AND Ref(ascxpred,-3));
uslsascxpre:=Cum(confascx AND ascxpred);
100-(100*(acc0ascxpred+acc1ascxpred+acc2ascxpred+uslsascxpre)/asctotpred)
15. Click in the Col Name box and enter the text: "false"
16. Click OK to close the exploration editor.

I also suggest that before closing the editor, adding the following text to the Notes field to provide a more detailed description of the column names:

Columns descriptions:
1: total ascending predictions
2: percent confirmed 1 day later
3: percent confirmed 2 days later
4: percent confirmed 3 days later
5: percent useless (confirmed same day as prediction)
6: percent of false predictions

The second exploration is added in the same manner, but the formulas and notes are different. The column names are the same. The steps to create it are:

1. Select Tools > the Explorer.
2. Click New
3. Enter a name, "SMA cross stats - descending"
4. Select the Column A tab and enter the following formula.
 

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
Cum(decxpred);
5. Click in the Col Name box and enter the text: "Total".
6. Select the Column B tab and enter the following formula.
 
y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
destotpred:=Cum(decxpred);
acc0desxpred:=Cum(confdecx AND Ref(decxpred,-1));
100*(acc0desxpred/destotpred)
7. Click in the Col Name box and enter the text: "1 day".
8. Select the Column C tab and enter the following formula.
 
y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
destotpred:=Cum(decxpred);
acc1desxpred:=Cum(confdecx AND Ref(decxpred,-2));
100*(acc1desxpred/destotpred)
9. Click in the Col Name box and enter the text: "2 day".
10. Select the Column D tab and enter the following formula.
 
y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
destotpred:=Cum(decxpred);
acc2desxpred:=Cum(confdecx AND Ref(decxpred,-3));
100*(acc2desxpred/destotpred)
11. Click in the Col Name box and enter the text: "3 day".
12. Select the Column E tab and enter the following formula.
 
y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
destotpred:=Cum(decxpred);
uslsdesxpred:=Cum(confdecx AND decxpred);
100*(uslsdesxpred/destotpred)
13. Click in the Col Name box and enter the text: "useless".
14. Select the Column F tab and enter the following formula.
 
y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
destotpred:=Cum(decxpred);
acc0desxpred:=Cum(confdecx AND Ref(decxpred,-1));
acc1desxpred:=Cum(confdecx AND Ref(decxpred,-2));
acc2desxpred:=Cum(confdecx AND Ref(decxpred,-3));
uslsdesxpre:=Cum(confdecx AND decxpred);
100-(100*(acc0desxpred+acc1desxpred+acc2desxpred+uslsdesxpre)/destotpred)
15. Click in the Col Name box and enter the text: "false"
16. Click OK to close the exploration editor.

The recommended notes for this exploration are:

Columns descriptions:
1: total descending predictions
2: percent confirmed 1 day later
3: percent confirmed 2 days later
4: percent confirmed 3 days later
5: percent useless (confirmed same day as prediction)
6: percent of false predictions

It should also be noted that MetaStock version 10 users can put all 12 columns -- both explorations -- into a single exploration. It would only require changing the column names a bit in order to easily tell which ones are for the ascending crosses and which ones are for the descending crosses. The second exploration would then have its formulas put in columns G through L.
--William Golson
MetaStock Support Representative
Equis International (A Reuters Company)
801 265-9998, www.metastock.com


GO BACK


eSIGNAL: MOVING AVERAGE CROSSOVERS

For this month's Traders' Tips contribution based on Dimitris Tsokakis' article, "Anticipating Moving Average Crossovers," we've provided the formula, "SMA_CrossPredictor.efs."

There are two formula parameters that may be configured through the Edit Studies option in the Advanced Chart to change the periods used for the two moving averages.  A sample chart is shown in Figure 2.

FIGURE 2: eSIGNAL, TOMORROW'S CLOSE MOVING AVERAGE CROSSOVER. Here is a demonstration of Dimitris Tsokakis' TC indicator in eSignal.
/***************************************
Provided By : eSignal (c) Copyright 2006
Description:  Anticipating Moving Average Crossovers
              by Dimitris Tsokakis
Version 1.0  12/05/2006
Notes:
* Feb 2007 Issue of Stocks and Commodities Magazine
* Study requires version 8.0 or later.
Formula Parameters:                     Default:
Fast MA Periods                         20
Slow MA Periods                         30
*****************************************************************/
function preMain() {
    setStudyTitle("SMA Cross Predictor ");
    setShowTitleParameters(false);
    setCursorLabelName("Close", 0);
    setCursorLabelName("Fast MA", 1);
    setCursorLabelName("Slow MA", 2);
    setCursorLabelName("TC", 3);
 
    setDefaultBarFgColor(Color.black, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarFgColor(Color.red, 2);
    setDefaultBarFgColor(Color.magenta, 3);
 
    setDefaultBarThickness(2, 0);
    setDefaultBarThickness(1, 1);
    setDefaultBarThickness(1, 2);
    setDefaultBarThickness(2, 3);
 
    setDefaultFont("Arial", 11);
    var fp1 = new FunctionParameter("MAlen1", FunctionParameter.NUMBER);
        fp1.setName("Fast MA Periods");
        fp1.setLowerLimit(2);
        fp1.setDefault(20);
    var fp2 = new FunctionParameter("MAlen2", FunctionParameter.NUMBER);
        fp2.setName("Slow MA Periods");
        fp2.setLowerLimit(2);
        fp2.setDefault(30);
}
// Global Variables
var bVersion  = null;    // Version flag
var bInit     = false;   // Initialization flag
var xMA1 = null;        // fast MA
var xMA2 = null;        // slow MA
var xTC  = null;        // Tomorrow's close
function main(MAlen1, MAlen2) {
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;
    //Initialization
    if (bInit == false) {
        xMA1 = sma(MAlen1);  // fast MA
        xMA2 = sma(MAlen2);  // slow MA
        xTC = efsInternal("calcTC", MAlen1, MAlen2);
        bInit = true;
    }
    var nC = close(0);
    var nTagID = rawtime(0);
    var nMA1_0 = xMA1.getValue(0);
    var nMA1_1 = xMA1.getValue(-1);
    var nMA2_0 = xMA2.getValue(0);
    var nMA2_1 = xMA2.getValue(-1);
    var nTC_0 = xTC.getValue(0);
    var nTC_1 = xTC.getValue(-1);
    if (nMA1_1 == null || nMA2_1 == null || nTC_1 == null) return;
 
    // MA-crossover
    if (nMA1_0 > nMA2_0 && nMA1_1 <= nMA2_1) {
        // cross up
        drawText("MA", AboveBar2, Color.green, Text.BOLD|Text.FRAME|Text.CENTER, "MA"+nTagID);
        drawShape(Shape.UPARROW, AboveBar1, Color.green, nTagID);
    } else if (nMA1_0 < nMA2_0 && nMA1_1 >= nMA2_1) {
        // cross down
        drawText("MA", BelowBar2, Color.red, Text.BOLD|Text.FRAME|Text.CENTER, "MA"+nTagID);
        drawShape(Shape.DOWNARROW, BelowBar1, Color.red, nTagID);
    } else {
        removeShape(nTagID);
        removeText("MA"+nTagID);
    }
 
    // TC cross
    if (nTC_0 > nC && nTC_1 < close(-1)) {
        drawShapeRelative(0, nTC_0, Shape.CIRCLE, null, Color.red, null, "TC"+nTagID);
    } else if (nTC_0 < nC && nTC_1 > close(-1)) {
        drawShapeRelative(0, nTC_0, Shape.CIRCLE, null, Color.green, null, "TC"+nTagID);
    } else {
        removeShape("TC"+nTagID);
    }
 
    return new Array(nC, nMA1_0.toFixed(4), nMA2_0.toFixed(4), xTC.getValue(0));
}
// TC Globals
var bInitTC = false;
var xTCMA1 = null;
var xTCMA2 = null;
function calcTC(Pfast, Kslow) {
    // k > p
    //TC = Pfast*(Kslow-1) * MA(Kslow-1) - Kslow*(Pfast-1) * MA(Pfast-1)  /  Kslow-Pfast;
 
    if (bInitTC == false) {
        xTCMA1 = sma((Pfast-1));
        xTCMA2 = sma((Kslow-1))
        bInitTC = true;
    }
 
    var nTC = null;
    var nMAfast = xTCMA1.getValue(0);
    var nMAslow = xTCMA2.getValue(0);
    if (nMAslow == null || nMAfast == null) return;
 
    if (Kslow-Pfast == 0) {
        nTC = ( (Pfast*(Kslow-1) * nMAslow) - (Kslow*(Pfast-1) * nMAfast) ) /  1;
    } else {
        nTC = ( (Pfast*(Kslow-1) * nMAslow) - (Kslow*(Pfast-1) * nMAfast) ) /  (Kslow-Pfast);
    }
 
    return nTC;
}
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=https://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;
}
--Jason Keck
eSignal, a division of Interactive Data Corp.
800 815-8256, www.esignalcentral.com
GO BACK

WEALTH-LAB: MOVING AVERAGE CROSSOVERS

The WealthScript code given here is based on Dimitris Tsokakis' article in this issue, "Anticipating Moving Average Crossovers." By anticipating the same closing price precisely one day earlier, Tsokakis' clever derivation bests the reversed-engineered RevEngSMAClose custom indicator that already exists in the Wealth-Lab Code Library. Accordingly, we added a new library indicator named RevEngSMA_TC, where TC = tomorrow's close. Clearly, it won't always be more profitable to enter the market long/short a bar early (price may drop/rise that day), so we tested two strategies to determine if, in general, it is advantageous to do so.

Simplifying, we concentrate on only long signals where TC crossed the closing price one bar earlier than the Sma crossover. The first strategy, zero, buys following the TC crossover, holds overnight, and then sells at the close of the next day. Strategy 1 enters the market after the Sma crossover and sells at the close on the same day. Consequently, in both cases, the trade is exited at the same point in time for the trading gain comparison.

Since we expect the results to vary somewhat with the choice of moving average periods, we set up to run both strategies in the Optimizer Tool using three fast and three slow periods (nine permutations). Using fixed $10,000 sizing and ignoring commissions, the average per-symbol results for the last five years of the S&P 100 are shown in Figure 3.

FIGURE 3: WEALTH-LAB, TOMORROW'S CLOSE CROSSOVER. This demonstrates the Optimizer's tab view showing average per-symbol values, such as average total profit, for both strategies. #OptVar1 indicates the strategy tested, 0 or 1, whereas the other OptVars control the periods of the averages.
For the same combination of periods tested, the results clearly favor Strategy 0 -- that is, entering the market one bar early via the TC crossover trigger signal.
 
WealthScript code:
{$I 'RevEngSMA_TC'}
{#OptVar1 0;0;1;1}
{#OptVar2 10;10;20;5}
{#OptVar3 30;30;50;10}
var Strategy: integer = #OptVar1;
var P: integer = #OptVar2;
var K: integer = #OptVar3;
var Bar, LP, C, hFast, hSlow, hTC, Pane1: integer;
C := #Close;
hFast := SMASeries( C, P );
hSlow := SMASeries( C, K );
hTC := RevEngSMA_TCSeries( C, P, K );
PlotSeries( hFast, 0, #Green, #Thin );
PlotSeries( hSlow, 0, #Red, #Thin );
Pane1 := CreatePane( 75, true, true );
PlotSeriesLabel( hTC, Pane1, #Red, #Thick, 'Tomorrow''s Close (Anticipated)' );
PlotSeriesLabel( C, Pane1, #Black, #Thin, 'Today''s Close' );
for Bar := K + 1 to BarCount - 1 do
  if CrossUnder( Bar - 1, hTC, C ) and CrossOver( Bar, hFast, hSlow ) then
    if BuyAtMarket( Bar + Strategy, '' ) then
      SellAtClose( Bar + 1, LastPosition, '' );
-- Robert Sucher
www.wealth-lab.com


GO BACK


NEUROSHELL TRADER: MOVING AVERAGE CROSSOVERS

Tomorrow's close crossover indicator described by Dimitris Tsokakis in his article in this issue, "Anticipating Moving Average Crossovers," can be easily implemented in NeuroShell Trader by combining a few of NeuroShell Trader's 800-plus indicators (Figure 4). To implement the indicator, select "New Indicator …" from the Insert menu and use the Indicator Wizard to create the following indicator:
 

Divide (Subtract(Mult3(P, K-1, MovAvg(Close,K-1)), Mult3(K, P-1, MovAvg(Close,K-1))), Subtract (K, P))


For more information on NeuroShell Trader, visit www.NeuroShell.com.

FIGURE 4: NeuroShell, TOMORROW'S CLOSE CROSSOVER
--Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com


GO BACK


NEOTICKER: MOVING AVERAGE CROSSOVERS

Indicators that calculate prediction and return statistics, such as those discussed in Dimitris Tsokakis' article in this issue, "Anticipating Moving Average Crossovers," can be implemented using the NeoTicker formula language. The formula language indicator named "Tasc Sma Cross Prediction Statistic" (Listing 1) has two parameters, fast and slow, with seven return values TC (prediction value), Total # Prediction, Acc0 %, Acc1 %, Acc2 %, Useless %, and False %.

When the Sma cross prediction indicator is applied to a chart, only prediction values are plotted by default (Figure 5).

FIGURE 5: NEOTICKER, TC INDICATOR. When the SMA cross prediction indicator is applied to a chart, only prediction values are plotted by default. To show remaining plots on the chart, click on the "visual" checkbox at the "visual" tab in the indicator setup window.
To show remaining plots on the chart, click on the "visual" checkbox at the Visual tab in the indicator setup window.

Use the pattern scanner to show all Nasdaq 100 calculation results in a table format (Figure 6). Different plot values within the same indicator are shown using the "plot value" indicator so that plot calculation values can be seen in different display columns in the pattern scanner.

FIGURE 6: NEOTICKER, TC INDICATOR CALCULATION RESULTS. Use the pattern scanner to show all Nasdaq 100 calculation results in a table format.
A downloadable version of this formula language indicator and NeoTicker group will be available at the NeoTicker blog site (https://blog.neoticker.com).
 
LISTING 1
$P := param1; 'fast SMA period
$K := param2; 'slow SMA period
TC := ($P*($K-1)*average(data1,$K-1) - $K*($P-1)*average(data1,$P-1))/($K-$P);
PerdictionX := absvalue(xcross(data1,TC));
$ActualX := absvalue(xcross(average(data1,$P), average(data1,$K)));
Useless := PerdictionX > 0 and $ActualX > 0;
Acc0 := Useless(1) = 0 and PerdictionX(1) > 0 and $ActualX > 0;
Acc1 := Useless(2) = 0 and Acc0(1) = 0 and
        PerdictionX(2) > 0 and $ActualX > 0;
Acc2 := Useless(3) = 0 and Acc0(2) = 0 and Acc1(1) = 0 and
        PerdictionX(3) > 0 and $ActualX > 0;
$TotPerd := cum(PerdictionX);
$Acc0Num := cum(Acc0);
$Acc1Num := cum(Acc1);
$Acc2Num := cum(Acc2);
$UselessNum := cum(Useless);
plot1 := TC;
plot2 := $TotPerd; 'Total number of Perdictions
plot3 := if($TotPerd = 0, 0, $Acc0Num/$TotPerd*100); 'Acc0 %
plot4 := if($TotPerd = 0, 0, $Acc1Num/$TotPerd*100); 'Acc1 %
plot5 := if($TotPerd = 0, 0, $Acc2Num/$TotPerd*100); 'Acc2 %
plot6 := if($TotPerd = 0, 0, $UselessNum/$TotPerd*100); 'Useless %
plot7 := if($TotPerd = 0, 0,
         ($TotPerd-$Acc0Num-$Acc1Num-$Acc2Num-$UselessNum)/$TotPerd*100);
--Kenneth Yuen, TickQuest Inc.
www.tickquest.com


GO BACK


AIQ: MOVING AVERAGE CROSSOVERS

Given here are the AIQ code for the TC indicator introduced by Dimitris Tsokakis in his article, and a related trading system that I devised to test the indicator.

I used the NASDAQ 100 list of stocks and two simple trading systems. The first uses the traditional crossover of two moving averages and buys when the shorter moving average crosses up from below the longer moving average. I used the author's suggested parameters of 20 and 30 days. I also set up a trading system that uses the TC indicator in the way the author suggests, visually, when the TC crosses down through the closing price, then a buy signal is generated. Short sale trades use the reverse of these rules. I coded but did not include the tests for the short side. My objective was to see if the approximate one-day lead on the crossovers that the TC usually provides would show a better return than using the traditional crossover of the two moving averages.

Using the AIQ EDS module, which tests all the trades on a one-share basis, I compared the long-side trades for fixed holding periods of one, two, three, five, 10, and 20 days. No other exit criteria were used. My hypothesis was that the one-day lead would have an effect only for the first few days of the trade, and then, as the holding period is lengthened, the advantage to the TC indicator would fade. In Figure 7, I show the results of these fixed-period tests. My hypothesis was correct and the advantage of the TC indicator peaks around the two- to three-day holding period and then actually reverses at the 20-day holding period.

FIGURE 7: AIQ, MOVING AVERAGE CROSSOVERS VS. TC CROSSOVERS. Here are the results of a fixed-period test. It appears that the advantage of the TC indicator peaks around the two- to three-day holding period and then actually reverses at the 20-day holding period.
I also simulated trading the two systems with a fixed two-day exit on the NASDAQ 100 list of stocks using the AIQ Portfolio Manager for the period 10/1/2002 to 12/6/2006. I ran the same two systems that were tested in the Eds module using the two-day exit, applying 20% of capital to each trade, three trades per day with a total of five positions at any one time. The results of these two tests are shown in Figure 8. The blue line is the Amax-2 system that uses the TC indicator and the red line is the Amax-1 system that uses the traditional crossover of two moving averages for an entry signal. The Amax-2 system with the TC indicator clearly outperforms the traditional crossover system with a return of 24.22% and a Sharpe ratio of 0.71 versus 8.38% and a Sharpe ratio of 0.18. I also tested the period from 10/01/2000 to 10/01/2002, and both systems show negative returns with large drawdowns (not shown). Before trading this system on stocks, it appears that a market-timing filter should be added.
FIGURE 8: AIQ, MOVING AVERAGE CROSSOVERS. Here are comparative equity curves for the AMAX-1 system using traditional moving average crossovers (red line) versus the crossovers using the TC indicator (blue line).
The code can be downloaded from the AIQ website at www.aiqsystems.com or copied and pasted from here:
 
!! ANTICIPATING MOVING AVERAGE CROSSOVERS
! Author: Dimitris Tsokakis, TASC, February 2006
! Coded by: Rich Denning 12/06/06
C    is [close].
P    is 20.
K    is 30.
MAP    is simpleavg(C,P).
MAK    is simpleavg(C,K).
MAP_1    is simpleavg(C,P-1).
MAK_1    is simpleavg(C,K-1).
TC is (P * (K-1)* MAK_1 - K*(P-1)* MAP_1) / (K - P).
! MA CROSS OVERS SYSTEM (TRADITIONAL)
LExu    if MAP > MAK and valrule(MAP < MAK,1).
SExd    if MAP < MAK and valrule(MAP > MAK,1).
! TC CROSS OVER SYSTEM
LEtcxd    if TC < C and valrule(TC > C,1).
SEtcxu    if TC > C and valrule(TC < C,1).
--Richard Denning
AIQ Systems
richard.denning@earthlink.net


GO BACK


SNAPSHEETS: MOVING AVERAGE CROSSOVERS

For the article by Dimitris Tsokakis in this issue, "Anticipating Moving Average Crossovers," we've created a SnapSheet, which is available in the SnapSheets web library. To load the SnapSheet, open the SnapSheets program, then click the Open SnapSheet button. Click Web Library, then double-click on the Traders' Tips folder.

No coding or cutting and pasting is required to use this SnapSheet. You may view and edit the logic behind each onscreen element by opening its Block Diagram. Just click the corresponding label on the legends at the top of each pane.

You can QuickEdit the periods of the short and long moving averages by single-clicking the ShortAvg and LongAvg labels at the top of the Price History pane and the Tomorrow's Close (TC) pane. Make sure the moving average periods in both panes match.

In Figure 9, a sample SnapSheets chart is shown. Green arrows on the TC pane show where the TC line crosses down through price -- a prediction that the short moving average will cross up through the long moving average. Green arrows on the Price History pane point to where the moving average crossover (confirmation) actually occurred.

FIGURE 9: SNAPSHEETS, MOVING AVERAGE CROSSOVERS. Green (red) arrows on the TC pane show where the TC line crosses down (up) through price. Green/red arrows on the Price History pane point to where the moving average crossover (confirmation) actually occurred.
Red arrows on the TC pane show where the TC line crosses up through price -- a prediction that the short moving average will cross down through the long moving average. Red arrows on the Price History pane point to where the moving average crossover (confirmation) actually occurred.

The legend on the TC pane shows the total number of descending (TC) and ascending (TC) predictions for all available history on the active symbol and what percentage of each were confirmed by actual moving average crossovers. If you click on the "% Confirmed" labels on the legend, you can change "how many days later" the system checks for confirmations. Setting "Days to Confirm" to zero will show you the percentage of predictions that were confirmed on the same day, what Tsokakis refers to as "useless predictions." Setting "Days to Confirm" to 1 will show you the percentage of predictions that were confirmed the next market day. Setting it to 2 will show the percentage of predictions that were confirmed two days later, 3 for three days later, and so on.

To discuss this SnapSheet, please visit the discussion forums at www.SnapSheets.com. Our online trainers will be happy to assist you.

--Patrick Argo and Bruce Loebrich
Worden Brothers, Inc.
(800) 776-4940, www.worden.com


GO BACK


STRATASEARCH: MOVING AVERAGE CROSSOVERS

The tomorrow's close (TC) crossover technique described by Dimitris Tsokakis in his article in this issue is a clever way of anticipating crossovers before they happen and eliminating a lot of the lag commonly associated with moving averages. In our testing of the two crossover methods, the overall returns were not significantly different. However, what we did notice is that the TC crossover tended to shift the system toward better returns per trade, while slightly decreasing the percentage of trades profitable. This is indeed what one would expect from an indicator with less lag. A sample StrataSearch chart is shown in Figure 10.

FIGURE 10: STRATASEARCH, MOVING AVERAGE CROSSOVERS
While the TC crossover may have limited use on its own, it can be a integral piece of a robust trading system when combined with additional indicators. StrataSearch allows you to automatically run and test the TC crossover alongside a variety of other indicators and trading rules. With this approach, you can easily identify supporting indicators that work well in conjunction with the TC crossover.

As with all other Traders' Tips, additional information -- including plug-ins -- can be found in the Shared Area of our user forum. This month's plug-in contains a number of prebuilt trading rules that will allow you to include this indicator in your automated searches. Simply install the plug-in and launch your automated search.
 

//****************************************************************
// Anticipating Moving Average Crossovers - TC Line
//****************************************************************
p = parameter("P Value");
k = parameter("K Value");
MAp = mov(close, p, simple);
MAk = mov(close, k, simple);
TC = (p*(k-1)*mov(close, k-1, simple)-k*(p-1)*mov(close, p-1, simple))/(k-p);
AMA_TC = TC;
--Pete Rast
Avarin Systems, Inc.
www.StrataSearch.com
GO BACK

ENSIGN WINDOWS: MOVING AVERAGE CROSSOVERS

A significant feature in Ensign Windows is our PriceFinder technology that can be used with any study. PriceFinder is a selection in our Design Your Own study feature. It can be used to solve for tomorrow's close and plot the price that would cause the two moving averages to cross.

Figure 11 is a chart similar to one shown in Dimitris Tsokakis' article in this issue, "Anticipating Moving Average Crossovers." The green line is the same curve shown in the article's Figure 1 (that is, the TC chart), except that it was calculated using Ensign's PriceFinder instead of the formula presented in the article. The advantage and power of PriceFinder is that it can be used with any study. See www.ensignsoftware.com for additional examples of using PriceFinder with Bollinger bands, commodity channel index, and the relative strength index.

FIGURE 11: ENSIGN WINDOWS, PRICE FINDER
Recreating the crossover price curve required two lines in Ensign's Design Your Own study:

The Line A selection is a Boolean flag for the moving average lines. It will have a "true" value when the first line (20-bar average) is above the second line (30-bar average). Line B uses the PriceFinder technology to calculate the next bar's close that would cause the Boolean flag from Line A to change states. This price is plotted using a green line.

Figure 12 is the same chart shown in Figure 11, only the scale has been changed to show more clearly the relationship of the bars, the two moving average lines, and the price curve that causes the two moving average lines to cross. When the blue line (20-bar average) is below the red line (30-bar average), a higher price is needed to raise the blue line to cross the red line. The green line is showing the price for tomorrow that is needed to cause the two moving averages to cross. Once the blue line is above the red line, the next bar's price (green line) would naturally be below the two averages. A lower price is needed to cause the blue line to descend to cross the red line.

FIGURE 12: ENSIGN WINDOWS, MOVING AVERAGE CROSSOVER. The blue line is a 20-day moving average and the red line is a 30-day moving average.
A free seven-day trial of Ensign Windows is available for download from Ensign Software's website.
--Howard Arrington
Ensign Software
www.ensignsoftware.com
GO BACK

TRADECISION: MOVING AVERAGE CROSSOVERS

In his article "Anticipating Moving Average Crossovers," Dimitris Tsokakis explains how to analyze and apply the moving average crossover behavior to financial instruments, as well as how to reduce the lag of the moving average crossovers.

Tradecision's Indicator Builder allows you to create a custom indicator using this method (Figure 13).

FIGURE 13: TRADECISION. This daily chart of the NASDAQ 100 (NDX) shows the 20-day moving average (red) and the 30-day moving average (yellow). The closing prices of NDX and the TC line are plotted on the subchart.
Here is the code for tomorrow's close (TC) custom indicator:
 
input
     p:"P",20;
     k:"K",30;
end_input
var
   MAp:=SMA(C,p);
   MAk:=SMA(C,k);
end_var
return (p*(k-1)*SMA(C,k-1)-k*(p-1)*SMA(c,p-1))/(k-p);


To insert the closing price of the NASDAQ 100 into a subchart, create a custom indicator using the following expression:

return External("C","NASDAQ-100");
To import the indicator into Tradecision, visit the "Traders Tips from Tasc Magazine" area at https://tradecision.com/support/tasc_tips/tasc_traders_tips.htm or copy the code from above.
--Alex Grechanowski
Alyuda Research, Inc.
sales@alyuda.com, 510 931-7808
www.alyuda.com, www.tradecision.com
GO BACK

OMNITRADER PRO: MOVING AVERAGE CROSSOVERS

For this month's article by Dimitris Tsokakis, "Anticipating Moving Average Crossovers," we have provided the TC indicator and a basic trading system as a starting point for users. The first file, "TC.txt," calculates the tomorrow's close (TC) indicator and plots it along with closing prices in a separate pane (Figure 14). The second file, "TCSystem.txt," fires long and short signals based on the crossover of the current closing price and the TC indicator.

FIGURE 14: OMNITRADER, TC INDICATOR. Here is a daily price chart of CSCO, with the tomorrow's close (TC) indicator plotted in the lower pane. TC is in green and the day's close is in red.
To use the indicator, first copy the files "TC.txt" and "TCSystem.txt" to the respective Indicators and Systems subdirectories of C:\Program Files\Nirvana\OT2006\/VBA\. Next, open OmniTrader and click Edit:OmniLanguage. You should see the TC and TCSystem in the Project Pane. Click compile. Now the code is ready to use. Here is what the code looks like:
 
'**************************************************************
'*   TC (TC.txt)
'*     by Jeremy Williams
'**************************************************************
#Param "ShortPeriods",14
#Param "LongPeriods",21
Dim myShortPeriods    As Integer
Dim myLongPeriods     As Integer
Dim ShortMA        As Single
Dim LongMA         As Single
Dim myTC        As Single
' Calculate the intermediate moving averages
myShortPeriods = ShortPeriods - 1
myLongPeriods = LongPeriods -1
ShortMA = SMA(myShortPeriods)
LongMA  = SMA(myLongPeriods)
' Implement the calculation
If LongPeriods < ShortPeriods Then
myTC = (ShortPeriods*myLongPeriods*LongMA
        -LongPeriods*myShortPeriods*ShortMA)
       /(LongPeriods-ShortPeriods)
Else
    myTC = 0
End If
'Plot the indicator and the current close in its own pane
Plot("TC",myTC)
Plot("Close",C)
'Return the value of the TC indicator
Return myTC
For more information and complete source code, visit https://www.omnitrader.com/ProSI.
--Jeremy Williams, Trading Systems Researcher
Nirvana Systems, Inc.
www.omnitrader.com, www.nirvanasystems.com


GO BACK


MULTICHARTS: MOVING AVERAGE CROSSOVERS
Here is the code for MultiCharts based on Dimitris Tsokakis' article in this issue, "Anticipating Moving Average Crossovers."
 

inputs: p(20), k(30);
var: TC(0);
TC = (p * (k - 1) * average(close, k - 1) - k * (p - 1) * average(close, p - 1)) / (k - p);
plot1(close, "close");
plot2(TC, "TC")


The result of applying this strategy to MultiCharts is demonstrated in Figure 16. To discuss this article or download a complete copy of the formulas, please visit our discussion forum at forum.tssupport.com.

--Stanley Miller
TS SUPPORT, LLC
www.tssupport.com
GO BACK

TRADE NAVIGATOR/TRADESENSE: MOVING AVERAGE CROSSOVERS

In Trade Navigator Gold or Platinum, you can create a function and a study to display the moving average crossover prediction indicator described in Dimitris Tsokakis' article, "Anticipating Moving Average Crossovers." If you wish to see the statistical results in Trade Navigator, you can create several functions to use in criteria that can be displayed in the Symbol Grid.

To help you set up the functions and criteria needed to recreate the moving average crossover prediction indicator and statistical results in Trade Navigator, we've provided step-by-step instructions, shown in full at the Stocks & Commodities website and abbreviated here.

Here is the basic formula to recreate the TC indicator:
 

 (p * (k - 1) * MovingAvg (Close , k - 1) - k * (p - 1) * MovingAvg (Close , p - 1)) / (k - p)
Click on the Verify button. This will open an Add Inputs window. Click on the Add button. Set P to "20" and K to "30." Click on Save, type in a name for the function, and then click the OK button.

For your convenience, Genesis has created a special file that will add the Anticipating Moving Average Crossovers functions, criteria, and study to Trade Navigator for you. Simply download the free special file "SC0207" using your Trade Navigator and follow the upgrade prompts.

--Michael Herman
Genesis Financial Technologies
https://www.GenesisFT.com


GO BACK


INVESTOR/RT AND MARKETDELTA: VOLUME BREAKDOWN INDICATOR

For this tip, we'll write about an indicator called the volume breakdown. The volume breakdown (VB) is a powerful and flexible indicator used to gauge buying and selling pressure and has attracted quite a bit of attention in recent months. It looks inside each bar, breaking down and classifying each tick and then accumulating the results. Further, it gives the user a variety of statistical measures (including all built-in technical indicators) to apply to these results.

The most common use of the VB indicator is to calculate the delta -- that is, the difference between the buy (ask-traded) and sell (bid-traded) volume -- of each bar. Positive deltas signify more buying pressure, while negative deltas signify more selling pressure. The magnitude of the delta determines the strength of that pressure. Expect to see positive deltas during uptrends and negative deltas during downtrends, but look for delta turning negative at highs or turning positive at lows: a sign of possible market turns and good entry/exit points.

With the VB indicator, the delta can be computed, accumulated, and run through a variety of statistical/indicator computations.

The VB indicator is unique in that it loads tick data (when initially computing), regardless of the time frame of the chart, in order to break down the volume of each trade. It makes a calculation for each tick. While it may take a few moments to initially add VB to a chart, or to load a chart that involves VB, the VB indicator is designed to calculate very efficiently on a tick-by-tick basis, regardless of the combination of settings selected. Figure 17 shows a variety of implementations of the VB indicator.

FIGURE 17: MARKETDELTA, VOLUME BREAKDOWN INDICATOR
--Chad Payne, Linn Software
info@linnsoft.com, www.linnsoft.com
sales@marketdelta.com, www.marketdelta.com


GO BACK


VT TRADER: MOVING AVERAGE CROSSOVERS

This month's Traders' Tips subject, "Anticipating Moving Average Crossovers" by Dimitris Tsokakis, features a simple moving average crossover trading system (with a twist). Tsokakis discusses the benefits of moving averages as trend-following indicators, but he acknowledges that they tend to lag. He outlines a way to decrease the lag of a simple moving average (SMA) by one day by basing the SMA on a simple mathematical observation. This observation allows the user to solve for "tomorrow's predicted close" (TC) price. The theory is that a crossing of the actual closing price and the TC can potentially predict the crossing of the SMAs in the next price bar.

A sample chart is shown in Figure 15:

FIGURE 15: VT TRADER, EUR/USD 15-Minute Candlestick chart with trading system. Small arrows indicate the SMA predictions, while larger arrows indicate the actual SMA crossings. The Inspect Window allows the user to view the SMA cross prediction statistics.


We'll be offering this trading system for download in our user forums. To learn more about VT Trader, visit www.cmsfx.com. The VT Trader code and instructions for recreating the TC indicator are also shown here (input variables are parameterized to allow customization):

1. Navigator Window>Tools>Trading Systems Builder>[New] button

2. In the Indicator Bookmark, type the following text for each field:

Name: TASC - 02/2007 - "Anticipating Moving Average Crossovers"
Short Name: vt_AMAC
Label Mask: TASC - 02/2007 - "Anticipating Moving Average Crossovers"


3. In the Input Bookmark, create the following variables:
 

[New] button... Name: _p , Display Name: MAp Periods , Type: integer , Default: 20
[New] button... Name: _k , Display Name: MAk Periods , Type: integer , Default: 30


4. In the Formula Bookmark, copy and paste the following formula:
 

{Provided By: Visual Trading Systems, LLC (c) Copyright 2007}
{Description: Anticipating Moving Average Crossovers by Dimitris Tsokakis}
{Notes: February 2007 Issue - Why Did The Technician Cross The Average?}
{Aniticipating Moving Average Crossovers}
{vt_AMAC Version 1.0}
{The TC Indicators}
MAp:= mov(C,_p,S);
MAk:= mov(C,_k,S);
_Close:= C;
TC:= (_p*(_k-1)*mov(C,_k-1,S)-_k*(_p-1)*mov(C,_p-1,S))/(_k-_p);
{SMA Cross Prediction/Confirmation Signals}
DescCrossPrediction:= Cross(TC,_Close);
AscCrossPrediction:= Cross(_Close,TC);
ConfirmedDesc:= Cross(MAk,MAp);
ConfirmedAsc:= Cross(MAp,MAk);
{SMA Cross Prediction Statistics}
DescTotalPredictions:= Cum(DescCrossPrediction);
Accurate0DescPredictions:= Cum(ConfirmedDesc AND Ref(DescCrossPrediction,-1));
Accurate1DescPredictions:= Cum(ConfirmedDesc AND Ref(DescCrossPrediction,-2));
Accurate2DescPredictions:= Cum(ConfirmedDesc AND Ref(DescCrossPrediction,-3));
UselessDescPredictions:= Cum(ConfirmedDesc AND DescCrossPrediction);
AscTotalPredictions:= Cum(AscCrossPrediction);
Accurate0AscPredictions:= Cum(ConfirmedAsc AND Ref(AscCrossPrediction,-1));
Accurate1AscPredictions:= Cum(ConfirmedAsc AND Ref(AscCrossPrediction,-2));
Accurate2AscPredictions:= Cum(ConfirmedAsc AND Ref(AscCrossPrediction,-3));
UselessAscPredictions:= Cum(ConfirmedAsc AND AscCrossPrediction);
Acc0Desc:= 100*Accurate0DescPredictions/DescTotalPredictions;
Acc1Desc:= 100*Accurate1DescPredictions/DescTotalPredictions;
Acc2Desc:= 100*Accurate2DescPredictions/DescTotalPredictions;
UselessDesc:= 100*UselessDescPredictions/DescTotalPredictions;
FalseDesc:= 100-Acc0Desc-Acc1Desc-Acc2Desc-UselessDesc;
Acc0Asc:= 100*Accurate0AscPredictions/AscTotalPredictions;
Acc1Asc:= 100*Accurate1AscPredictions/AscTotalPredictions;
Acc2Asc:= 100*Accurate2AscPredictions/AscTotalPredictions;
UselessAsc:= 100*UselessAscPredictions/AscTotalPredictions;
FalseAsc:= 100-Acc0Asc-Acc1Asc-Acc2Asc-UselessAsc;
{Create Auto-Trading Functionality}
OpenBuy:= AscCrossPrediction and (eventCount('OpenBuy')=eventCount('CloseBuy'));
CloseBuy:= DescCrossPrediction and (eventCount('OpenBuy')>eventCount('CloseBuy'));
OpenSell:= DescCrossPrediction and (eventCount('OpenSell')=eventCount('CloseSell'));
CloseSell:= AscCrossPrediction and (eventCount('OpenSell')>eventCount('CloseSell'));


5. In the Output Bookmark, create the following variables:
 

[New] button...
Var Name: MAp
Name: MAp
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: blue
Line Width: slightly thicker
Line Style: solid
Placement: Price Frame
[OK] button...
[New] button...
Var Name: MAk
Name: MAk
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: red
Line Width: slightly thicker
Line Style: solid
Placement: Price Frame
[OK] button...
[New] button...
Var Name: _Close
Name: Close Price
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 1
[OK] button...
[New] button...
Var Name: TC
Name: TC
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: red
Line Width: thin
Line Style: dashed
Placement: Additional Frame 1
[OK] button...
[New] button...
Var Name: DescCrossPrediction
Name: DescCrossPrediction
Description: Decending MA Cross Prediction
* Checkmark: Graphic Enabled
* Checkmark: Alerts Enabled
Select Graphic Bookmark
Font […]: Down Arrow
Size: small
Color: dark red
Symbol Position: Above price plot
Select Alerts Bookmark
Alerts Message: Decending MA Cross Prediction
Choose sound for audible alert
[OK] button...
[New] button...
Var Name: AscCrossPrediction
Name: AscCrossPrediction
Description: Ascending MA Cross Prediction
* Checkmark: Graphic Enabled
* Checkmark: Alerts Enabled
Select Graphic Bookmark
Font […]: Exit Sign
Size: small
Color: dark blue
Symbol Position: Below price plot
Select Alerts Bookmark
Alerts Message: Ascending MA Cross Prediction
Choose sound for audible alert
[OK] button...
[New] button...
Var Name: ConfirmedDesc
Name: ConfirmedDesc
Description: Decending MA Cross Confirmed!
* Checkmark: Graphic Enabled
* Checkmark: Alerts Enabled
Select Graphic Bookmark
Font […]: Down Arrow
Size: medium
Color: red
Symbol Position: Above price plot
Select Alerts Bookmark
Alerts Message: Decending MA Cross Confirmed!
Choose sound for audible alert
[OK] button...
[New] button...
Var Name: ConfirmedAsc
Name: ConfirmedAsc
Description: Ascending MA Cross Confirmed!
* Checkmark: Graphic Enabled
* Checkmark: Alerts Enabled
Select Graphic Bookmark
Font […]: Exit Sign
Size: medium
Color: blue
Symbol Position: Below price plot
Select Alerts Bookmark
Alerts Message: Ascending MA Cross Confirmed!
Choose sound for audible alert
[OK] button...
[New] button...
Var Name: DescTotalPredictions
Name: Total # of Desc Predictions
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: Acc0Desc
Name: Acc0 Desc %
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: Acc1Desc
Name: Acc1 Desc %
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: Acc2Desc
Name: Acc2 Desc %
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: UselessDesc
Name: Useless Desc %
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: FalseDesc
Name: False Desc %
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: AscTotalPredictions
Name: Total # of Asc Predictions
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: Acc0Asc
Name: Acc0 Asc %
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: Acc1Asc
Name: Acc1 Asc %
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: Acc2Asc
Name: Acc2 Asc %
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: UselessAsc
Name: Useless Asc %
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: FalseAsc
Name: False Asc %
* Checkmark: Indicator Output
Select Indicator Output Bookmark
Color: black
Line Width: thin
Line Style: solid
Placement: Additional Frame 5
[New] button...
Var Name: OpenBuy
Name: OpenBuy
Description: Automated Open Buy Trade Command
* Checkmark: Trading Enabled
Select Trading Bookmark
Trade Action: Buy
Traders Range: 5
Hedge: no checkmark
EachTick Count: 1
[OK] button...
[New] button...
Var Name: CloseBuy
Name: CloseBuy
Description: Automated Close Buy Trade Command
* Checkmark: Trading Enabled
Select Trading Bookmark
Trade Action: Sell
Traders Range: 5
Hedge: no checkmark
EachTick Count: 1
[OK] button...
[New] button...
Var Name: OpenSell
Name: OpenSell
Description: Automated Open Sell Trade Command
* Checkmark: Trading Enabled
Select Trading Bookmark
Trade Action: Sell
Traders Range: 5
Hedge: no checkmark
EachTick Count: 1
[OK] button...
[New] button...
Var Name: CloseSell
Name: CloseSell
Description: Automated Close Sell Trade Command
* Checkmark: Trading Enabled
Select Trading Bookmark
Trade Action: Buy
Traders Range: 5
Hedge: no checkmark
EachTick Count: 1
[OK] button...


6. Click the "Save" icon to finish building this trading system. To attach this trading system to a chart right-click with the mouse within the chart window, select "Add Trading System" -> "TASC - 02/2007 - "Anticipating Moving Average Crossovers" " from the list. Once attached to the chart, the parameters can be customized by right-clicking with the mouse over the displayed trading system label and selecting "Edit Trading Systems Properties."

--Chris Skidmore
Visual Trading Systems, LLC (courtesy of CMS Forex)
(866) 51-CMSFX, trading@cmsfx.com
www.cmsfx.com
 

GO BACK

Return to February 2007 Contents

Originally published in the February 2007 issue of Technical Analysis of STOCKS & COMMODITIES magazine. All rights reserved. © Copyright 2007, Technical Analysis, Inc.