File Name: strMAcrsv.efs
Description:
Moving Average Crossover
Formula Parameters:
Length Fast SMA : 20
Length Slow SMA : 40
Notes:
The Moving Average Crossover trading strategy is possibly the most popular
trading strategy in the world of trading. First of them were written in the
middle of XX century, when commodities trading strategies became popular.
This strategy is a good example of so-called traditional strategies. Traditional
strategies are always long or short. That means they are never out of the market.
The concept of having a strategy that is always long or short may be scary,
particularly in today?s market where you don?t know what is going to happen as
far as risk on any one market. But a lot of traders believe that the concept is
still valid, especially for those of traders who do their own research or their
own discretionary trading.
Download File:
strMAcrsv.efs
EFS Code:
Description:
Moving Average Crossover
Formula Parameters:
Length Fast SMA : 20
Length Slow SMA : 40
Notes:
The Moving Average Crossover trading strategy is possibly the most popular
trading strategy in the world of trading. First of them were written in the
middle of XX century, when commodities trading strategies became popular.
This strategy is a good example of so-called traditional strategies. Traditional
strategies are always long or short. That means they are never out of the market.
The concept of having a strategy that is always long or short may be scary,
particularly in today?s market where you don?t know what is going to happen as
far as risk on any one market. But a lot of traders believe that the concept is
still valid, especially for those of traders who do their own research or their
own discretionary trading.
Download File:
strMAcrsv.efs
EFS Code:
PHP Code:
/*********************************
Provided By:
eSignal (Copyright c eSignal), a division of Interactive Data
Corporation. 2009. 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:
Moving Average Crossover
Version: 1.0 03/24/2009
Formula Parameters: Default:
Length Fast SMA 20
Length Slow SMA 40
Notes:
The Moving Average Crossover trading strategy is possibly the most popular
trading strategy in the world of trading. First of them were written in the
middle of XX century, when commodities trading strategies became popular.
This strategy is a good example of so-called traditional strategies. Traditional
strategies are always long or short. That means they are never out of the market.
The concept of having a strategy that is always long or short may be scary,
particularly in today?s market where you don?t know what is going to happen as
far as risk on any one market. But a lot of traders believe that the concept is
still valid, especially for those of traders who do their own research or their
own discretionary trading.
**********************************/
var fpArray = new Array();
var bInit = false;
function preMain() {
setPriceStudy(true);
setStudyTitle("Moving Average Crossover");
setColorPriceBars(true);
setDefaultPriceBarColor(Color.black);
setPlotType(PLOTTYPE_LINE,0);
setDefaultBarFgColor(Color.red, 0);
setPlotType(PLOTTYPE_LINE,1);
setDefaultBarFgColor(Color.blue, 1);
var x=0;
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Length Fast SMA");
setLowerLimit(1);
setDefault(20);
}
var x=0;
fpArray[x] = new FunctionParameter("Length2", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Length Slow SMA");
setLowerLimit(1);
setDefault(40);
}
}
var xSMAFast = null;
var xSMASlow = null;
function main(Length, Length2) {
var nBarState = getBarState();
var nSMAFast = 0;
var nSMASlow = 0;
if (nBarState == BARSTATE_ALLBARS) {
if (Length == null) Length = 20;
if (Length2 == null) Length2 = 40;
}
if (bInit == false) {
xSMAFast = sma(Length);
xSMASlow = sma(Length2);
bInit = true;
}
nSMAFast = xSMAFast.getValue(-1);
nSMASlow = xSMASlow.getValue(-1);
if(nSMAFast == null || nSMASlow == null) return;
if (getCurrentBarIndex() == 0) return;
if(nSMAFast >= nSMASlow && !Strategy.isLong())
Strategy.doLong("Crossing Up", Strategy.MARKET, Strategy.THISBAR);
if(nSMAFast < nSMASlow && !Strategy.isShort())
Strategy.doShort("Crossing Down", Strategy.MARKET, Strategy.THISBAR);
if(Strategy.isLong())
setPriceBarColor(Color.lime);
else if(Strategy.isShort())
setPriceBarColor(Color.red);
return new Array(nSMAFast, nSMASlow);
}