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

[amibroker] Re: Several timeframes



PureBytes Links

Trading Reference Links

It would be better, before the exercise, to check the formula you use.
a. 
In your basic
result = ((i-1)/i)*result + (1/i)*Ref(C,-(i-1)) ;
"result" can not be in both sides of the definition.
On the other side, a simple MA is not a recursive function.
For the simple MA(C,3) the last value is
M0=(C0+C1+C2)/3
The previous value is
M1=(C1+C2+C3)/3
As you see, C0 is not included in M1 calculation.
b. 
Since result is a function of i, there should be something like
result[i]=...
for the ith element of the result array
c.
there is a confusion in Ref(C,-(i-1)) .
The 801th element of a MA(C,3) in a 1000-bar Close array can not be a 
function of the Ref(C,-(801-1)) or the Ref(C,-800) !!!
It would help to read the EMA, AMA analytic formulas from the HELP 
manual.
Dimitris Tsokakis 
--- In amibroker@xxxxxxxxxxxxxxx, "treliff" <treliff@xxxx> wrote:
> Looping stuff.... I've had some guidance from the forum and TJ
> and 
> thought I got it, but every new loop I take on gets stuck.
> 
> I went back to the basics, as an exercise trying to write a 
function 
> loop for a simple moving average:
> 
> function MN(n)
> {
> // local result;
> result = C ;
> for (i=2;i<BarCount;i++)
> {
> result = ((i-1)/i)*result + (1/i)*Ref(C,-(i-1)) ;
> }
> return result;
> }
> Plot(MN(2),"MN(2)", colorBlue);
> Plot(MA(C,2),"MA(2)",colorRed);
> 
> Just doesn't work, my MN(n) is empty for every n. What's
> wrong?
> Thanks for your patience with me.
> 
> treliff



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/