File Name: MovAvgSine_Weightd.efs
Description:
Mov Avg Sine-Weightd
Formula Parameters:
Length : 5
Thickness : 2
Line Color : Green
Display Cursor Labels : True
Notes:
Mov Avg Sine-Weightd Indicator
Patrick Lafferty's article How Smooth Is Your Data Smoother? Uses
the sine calculation to create a smoothed moving average. The basis
of the sine-weighted moving average is calculated using the sine
function in EFS.
The related article is copyrighted material. If you are not
a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
MovAvgSine_Weightd.efs
EFS Code:
Description:
Mov Avg Sine-Weightd
Formula Parameters:
Length : 5
Thickness : 2
Line Color : Green
Display Cursor Labels : True
Notes:
Mov Avg Sine-Weightd Indicator
Patrick Lafferty's article How Smooth Is Your Data Smoother? Uses
the sine calculation to create a smoothed moving average. The basis
of the sine-weighted moving average is calculated using the sine
function in EFS.
The related article is copyrighted material. If you are not
a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
MovAvgSine_Weightd.efs
EFS Code:
PHP Code:
/*********************************
Provided By:
eSignal (Copyright c eSignal), a division of Interactive Data
Corporation. 2008. 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:
Mov Avg Sine-Weightd
Version: 1.0 01/14/2009
Formula Parameters: Default:
Length 5
Thickness 2
Line Color Green
Display Cursor Labels True
Notes:
Mov Avg Sine-Weightd Indicator
Patrick Lafferty's article How Smooth Is Your Data Smoother? Uses
the sine calculation to create a smoothed moving average. The basis
of the sine-weighted moving average is calculated using the sine
function in EFS.
The related article is copyrighted material. If you are not
a subscriber of Stocks & Commodities, please visit [url]www.traders.com.[/url]
**********************************/
var fpArray = new Array();
var bInit = false;
function preMain() {
setPriceStudy(true);
setShowCursorLabel(false);
setShowTitleParameters( false );
setStudyTitle("Mov Avg Sine-Weightd");
setCursorLabelName("Sine-Weightd", 0);
setDefaultBarFgColor(Color.green, 0);
setPlotType(PLOTTYPE_LINE, 0);
setDefaultBarThickness(1, 0);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("LineColor", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("Color line");
setDefault(Color.green);
}
fpArray[x] = new FunctionParameter("ViewValue", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Display Title Value");
setDefault(true);
}
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Length");
setLowerLimit(1);
setDefault(5);
}
fpArray[x] = new FunctionParameter("Thickness", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Thickness line");
setLowerLimit(1);
setDefault(2);
}
}
var xSWMA = null;
function main(Length, LineColor, Thickness, ViewValue) {
var SWMA = 0;
if ( bInit == false ) {
setDefaultBarFgColor(LineColor, 0);
setDefaultBarThickness(Thickness, 0);
setShowCursorLabel(ViewValue);
xSWMA = efsInternal("Calc_SWMA", Length);
bInit = true;
}
SWMA = xSWMA.getValue(0);
if (SWMA == null) return;
return SWMA;
}
function Calc_SWMA(Length){
var nRes = 0;
var Numerator = 0;
var Denominator = 0;
var Factor = 180 / 6;
var pi = 3.1415926;
if (getCurrentBarCount() < Length) return;
for (var i = 0; i <= Length; i++) {
Numerator += Math.sin(pi * (i * Factor) / 180) * close(-(Length-i));
Denominator += Math.sin(pi * (i * Factor) / 180);
}
if (Denominator != 0 ) {
nRes = Numerator / Denominator;
}
if (nRes == null) return;
return nRes;
}