[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] Pyrapoint



PureBytes Links

Trading Reference Links

Dave,
Suppose we want to create the Stoch transformation for various 
arrays, say MACD() and Signal().
The first method is analytic, you have to repeat 4 lines per array
a1=Signal();t=14;
H1=HHV(a1,t);L1=LLV(a1,t);
st=100*(a1-L1)/(H1-L1);
Plot(st,"StochSignal",1,1);
a1=MACD();t=14;
H1=HHV(a1,t);L1=LLV(a1,t);
st=100*(a1-L1)/(H1-L1);
Plot(st,"StochMACD",2,1);

The function method will give the same result in an elegant form.
Define first the st-function steps and then apply for any array.
//The Stochastic transformation
 function st(array,t)
{
H1=HHV(array,t);
L1=LLV(array,t);
return 100*(array-L1)/(H1-L1);
}
Plot(st(Signal(),14),"StochSignal",1,1);
Plot(st(MACD(),14),"StochMACD",2,1);

The advantage of the function method is obvious.
Dimitris Tsokakis
PS: Note here that this st-function is a pseudo-stochastic, since the 
arrays do not have HLC. 
Expect saturated values for both 0 or 100 limits.
--- In amibroker@xxxxxxxxxxxxxxx, "Dave Merrill" <dmerrill@xxxx> 
wrote:
> I'm seeing a weird problem that I think may be the result of 
something I
> don't understand about variable scoping. Check this out:
> 
> ----------------------
> function StochTransform(array, period) {
> 	local LowValue;
> 	LowValue = LLV(array, period);
> 	return 100 * (array - LowValue) / (HHV(array, period) - 
LowValue);
> }
> 
> Diff = Signal(12, 26, 9);
> StochDiff = StochTransform(Diff, 5);
> 
> //JunkIgnored = StochTransform(C, 14);	// <<< ENABLING THIS 
CHANGES Diff,
> WHY???
> //JunkIgnored = StochTransform(Diff, 14);	// <<< BUT THIS 
DOESN'T
> ----------------------
> 
> First enter it into IB as given above, look at the chart, then 
enable the
> first of the two commented out lines at the bottom. Notice that 
Diff (blue
> histogram) changes drastically. Now enable the second one and not 
the first,
> and things go back to "normal".
> 
> I don't get this at all. It seems like it must be due to 
interaction between
> the two calls to StochTransform, and in fact, if you create a copy 
of the
> function called StochTransform2, and call that the second time, no 
problem.
> Guessing further from the fact that using the same value for 
the 'array'
> parameter in both cases also prevents the problem, most likely the 
conflict
> is with the reuse of that formal parameter when the function is 
called the
> second time.
> 
> I've never seen this behavior before, and I don't understand it. 
Among other
> things, if it's really true that you can't call the same function 
more than
> once without interactions like this, a lot of code I've written 
that I
> thought worked, didn't. Or is there some simple stupid bug in this 
test that
> I'm missing?
> 
> Ideas? Tomasz?
> 
> Dave


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/amibroker/

To unsubscribe from this group, send an email to:
 amibroker-unsubscribe@xxxxxxxxxxxxxxx

Your use of Yahoo! Groups is subject to:
 http://docs.yahoo.com/info/terms/