This code takes 10 minutes to calculate on ~2800 bars:
/************************************************** **************************************************
Sine-weighted Moving Average
************************************************** ************************************************** */
function preMain() {
setPriceStudy(true);
setDefaultBarThickness(2);
setDefaultBarFgColor(Color.green);
}
var sin1 = Math.sin(Math.PI/6);
var sin2 = Math.sin(Math.PI/3);
var sin3 = Math.sin(Math.PI/2);
var sin4 = Math.sin(Math.PI*2/3);
var sin5 = Math.sin(Math.PI*5/6);
function main() {
var S1 = 0.0;
var S2 = 0.0;
var S3 = 0.0;
var S4 = 0.0;
var S5 = 0.0;
var Num = 0.0;
var Dem = 0.0;
S1 = sin1*close(0,1);
S2 = sin2*close(-1,1);
S3 = sin3*close(-2,1);
S4 = sin4*close(-3,1);
S5 = sin5*close(-4,1);
Num = S1+S2+S3+S4+S5;
Den = sin1+sin2+sin3+sin4+sin5;
return Num/Den;
}
but only 3 seconds in Tradestation (using EasyLanguage version).
?????
atlas
/************************************************** **************************************************
Sine-weighted Moving Average
************************************************** ************************************************** */
function preMain() {
setPriceStudy(true);
setDefaultBarThickness(2);
setDefaultBarFgColor(Color.green);
}
var sin1 = Math.sin(Math.PI/6);
var sin2 = Math.sin(Math.PI/3);
var sin3 = Math.sin(Math.PI/2);
var sin4 = Math.sin(Math.PI*2/3);
var sin5 = Math.sin(Math.PI*5/6);
function main() {
var S1 = 0.0;
var S2 = 0.0;
var S3 = 0.0;
var S4 = 0.0;
var S5 = 0.0;
var Num = 0.0;
var Dem = 0.0;
S1 = sin1*close(0,1);
S2 = sin2*close(-1,1);
S3 = sin3*close(-2,1);
S4 = sin4*close(-3,1);
S5 = sin5*close(-4,1);
Num = S1+S2+S3+S4+S5;
Den = sin1+sin2+sin3+sin4+sin5;
return Num/Den;
}
but only 3 seconds in Tradestation (using EasyLanguage version).
?????
atlas
Comment