Im attempting to write a framework for multiple time frame studies. When i have the study running in real time it works properly (pulling moving average prices from multiple time frames)
However,
When i try to run the study in bar replay mode, if i attempt to pull anything other than the current charted time frame, it returns the most recent price for that study (instead of the one in reference to wherever i am in bar replay mode.
Example:
function main () {
var cable5 = close(sym("GBP A0-FX,5")); // the symbol
var cable30 = close(sym("GBP A0-FX,30")); // the symbol
var len1 = 5; // length for the trigger ma
var len2 = 50; // length for the long ma
var len3 = 100; // length for the trend ma
trig_study = sma(len1, cable5);
long_study = sma(len2, cable5);
trend_study = sma(len3, cable5);
trig30_study = sma(len1, cable30);
long30_study = sma(len2, cable30);
trend30_study = sma(len3, cable30);
// 5 min on cable
trigma = trig_study.getValue(0);
longma = long_study.getValue(0);
trendma = trend_study.getValue(0);
// 30 min on cable
trig30 = trig30_study.getValue(0);
long30 = long30_study.getValue(0);
trend30 = trend30_study.getValue(0);
return new Array(trigma, longma, trendma,trig30,long30,trend30);
}
My chart is set on the 5 minute period. In real time the code works fine. In bar replay mode, the trig30 studies being returned are from the current price rather than the price that would be from that period in bar replay.
What should i be doing to retrieve bar replay based values?
thanks in advance
-=tam
However,
When i try to run the study in bar replay mode, if i attempt to pull anything other than the current charted time frame, it returns the most recent price for that study (instead of the one in reference to wherever i am in bar replay mode.
Example:
function main () {
var cable5 = close(sym("GBP A0-FX,5")); // the symbol
var cable30 = close(sym("GBP A0-FX,30")); // the symbol
var len1 = 5; // length for the trigger ma
var len2 = 50; // length for the long ma
var len3 = 100; // length for the trend ma
trig_study = sma(len1, cable5);
long_study = sma(len2, cable5);
trend_study = sma(len3, cable5);
trig30_study = sma(len1, cable30);
long30_study = sma(len2, cable30);
trend30_study = sma(len3, cable30);
// 5 min on cable
trigma = trig_study.getValue(0);
longma = long_study.getValue(0);
trendma = trend_study.getValue(0);
// 30 min on cable
trig30 = trig30_study.getValue(0);
long30 = long30_study.getValue(0);
trend30 = trend30_study.getValue(0);
return new Array(trigma, longma, trendma,trig30,long30,trend30);
}
My chart is set on the 5 minute period. In real time the code works fine. In bar replay mode, the trig30 studies being returned are from the current price rather than the price that would be from that period in bar replay.
What should i be doing to retrieve bar replay based values?
thanks in advance
-=tam
Comment