Hi, I have maybe a simple question. In Tradestation and other such packages, I can reference the values of variables in my calculations/studies from previous days via something like:
variable_x(10) // Tradestation
// variable_x's value 10 days ago in same formula
PREV // Metastock
// Value of formula from previous bar
I cannot seem to find a way to do this with eSignal formula script.
A simple example should demonstrate what I mean:
///////////////////////////////////
// Exponential Moving Average study
///////////////////////////////////
function preMain() {
setPriceStudy(true);
}
var ema = 0.0;
var ema_avg = 0.0;
function main(nInputLength) {
// ema is calculated here
// now we calculate the ema average
ema_avg = (ema(0) + ema(1) + ema(2) + ema(3)) / 4;
return ema_avg;
}
At the end, I want to return the average of the value of ema within the same formula of the _past_ four days. How can I do this without calculating all four averages every single bar?
Christian
variable_x(10) // Tradestation
// variable_x's value 10 days ago in same formula
PREV // Metastock
// Value of formula from previous bar
I cannot seem to find a way to do this with eSignal formula script.
A simple example should demonstrate what I mean:
///////////////////////////////////
// Exponential Moving Average study
///////////////////////////////////
function preMain() {
setPriceStudy(true);
}
var ema = 0.0;
var ema_avg = 0.0;
function main(nInputLength) {
// ema is calculated here
// now we calculate the ema average
ema_avg = (ema(0) + ema(1) + ema(2) + ema(3)) / 4;
return ema_avg;
}
At the end, I want to return the average of the value of ema within the same formula of the _past_ four days. How can I do this without calculating all four averages every single bar?
Christian
Comment