Hi,
I am trying to make a multiple timeframe system that includes the StochF/Stoch indicator. I am having a hard time to get it to calculate a higher time frame stochastic with the built in indicator.

I created my own version of StochF and that seems to work as expected.

Am I doing something wrong or did I stumble on a bug? It seems that StochF disregards the change of TimeFrame?

This is my script. It plots standard StochF for H1 and H4 (these are identical) and my version of StochF for H1 and H4 below.

Quote:

#define D1 (1440/BarPeriod)
#define H4 (240/BarPeriod)
#define H1 (60/BarPeriod)

function raw_stochF(var k_period, var d_period) {
var close = priceClose();
var highest = HH(k_period);
var lowest = LL(k_period);

return EMA(series(100*(close-lowest)/(highest-lowest)), d_period);
}

function run() {
set(PLOTNOW);
BarPeriod = 60;

StartDate = 20130501;
EndDate = 20130513;

TimeFrame = H4;

var stoch_H4= StochF(7,2, MAType_EMA);
var r_stF_H4 = raw_stochF(7, 2);

TimeFrame = H1;

var stoch_H1= StochF(7,2, MAType_EMA);
var r_stF_H1 = raw_stochF(7, 2);

plot("StochF_H1", stoch_H1, NEW, ORANGE);
plot("StochF_H4", stoch_H4, LINE, RED);
plot("80", 80, LINE, BLACK);
plot("20", 20, LINE, BLACK);

plot("raw_StochF_H1", r_stF_H1, NEW, ORANGE);
plot("raw_StochF_H4", r_stF_H4, LINE, RED);
plot("e80", 80, LINE, BLACK);
plot("e20", 20, LINE, BLACK);
}


Please advice.

Regards
Martin