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

Re: [amibroker] Need more help with Price Indicators



PureBytes Links

Trading Reference Links

Sorry incomplete copy and paste
better this one

stephane


function f(n) 
{
return log(C/Ref(C,-n))/(StDev(log(C/Ref(C,-1)),n)*sqrt(n));
}
n=10;
Plot(f(n),"",2,1);
ff=f(n);

lookback=30;

for (i=0; i<BarCount; i++)
{
 if (i<(n+lookback)) 
 g[i]=Null;
 else
 {
  for(j=0;j<lookback;j++)
  {
   g[i]=g[i]+ff[i-j];
  }
 } 
}

Plot(g,"",colorBlue,1);

 









<s.carrasset@xxxx> wrote:
> pêrhaps something like
> 
> Plot(f(n),"",2,1);
> ff=f(n);
> 
> lookback=30;
> 
> for (i=0; i<BarCount; i++)
> {
>  if (i<(n+lookback)) 
>  g[i]=Null;
>  else
>  {
>   for(j=0;j<lookback;j++)
>   {
>    g[i]=g[i]+ff[i-j];
>   }
>  } }
> 
> Plot(g,"",colorBlue,1);
> 
> > 
> > I'm no real programmer myself but I think that if you want to 
learn 
> about
> > simple loopings and simple coding that you can use in Amibroker 
you 
> could
> > read a basic book about any programming language almost since 
they 
> are
> > pretty similar with treating the basics. Myself a studied a 
little 
> Java and
> > I program a little in IDL (interactive data language) and I want 
to 
> learn to
> > be able to use JScript more than I am able to currently.
> > 
> > I would suggest a basic book on JScript because you can use 
JScript 
> inside
> > Amibroker. Also there is a lot on the internet about JScript.
> > 
> > regards, Ed
> > 
> > 
> > ----- Original Message ----- 
> > From: "treliff" <treliff@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Tuesday, March 09, 2004 10:37 AM
> > Subject: [amibroker] Re: I need some loop-programming help
> > 
> > 
> > > Ed, thanks so much, it works, though this is at first a piece of
> > > inscrutable code for me. A closer look though reveals the 
> mechanics.
> > >
> > > Tell me if you will, you wouldn't happen to know some concise
> > > document (possibly on the net) that reveals how to write these
> > > codes? (I'm not a programmer, is this C++, Pascal, other?)
> > >
> > > I considered purchasing some programming manual but will 
probably
> > > get much more information than in need for use in AB. Any
> > > suggestions?
> > >
> > > Thanks again,
> > >
> > > Treliff
> > >
> > >
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, "ed2000nl" <pablito@xxxx> 
wrote:
> > > > hi,
> > > >
> > > > this is one way to do it (the AddColumn is just for testing
> > > purposes):
> > > >
> > > >
> > > > function fff(n) {
> > > >
> > > > return  log(C/Ref(C,-n))/(StDev(log(C/Ref(C,-1)),n)*sqrt(n));
> > > >
> > > > }
> > > >
> > > >
> > > > function ggg(n) {
> > > >
> > > > g = 0;
> > > >
> > > > if (n >= 10) {
> > > >
> > > > for (i = 10; i <= n; i++) {
> > > >
> > > > g = g + fff(i);
> > > >
> > > > }
> > > >
> > > > }
> > > >
> > > > return g;
> > > >
> > > > }
> > > >
> > > >
> > > > Filter = 1;
> > > > AddColumn(ggg(10),"ggg(10)");
> > > > AddColumn(ggg(11),"ggg(11)");
> > > > AddColumn(ggg(12),"ggg(12)");
> > > >
> > > >
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "treliff" <treliff@xxxx> 
> wrote:
> > > > > Thanks Graham,
> > > > >
> > > > > I tried your suggestion but changing "g" to "gr" within the 
> code
> > > is
> > > > > not the solution since now it returns a syntax error re. "gr
> > > (10)".
> > > > > The problem is in the brackets I think but I wouldn't know 
how
> > > to
> > > > > code without brackets to initiate the loop.
> > > > >
> > > > > Possibly indeed the use one function within another is a
> > > problem,
> > > > > though I suspect this should be possible.
> > > > >
> > > > > Treliff
> > > > >
> > > > >
> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Graham" <gkavanagh@xxxx>
> > > wrote:
> > > > > > I think the problem comes that you are using the 
functioning
> > > you
> > > > > are trying
> > > > > > to define within the function itself. Try changing that g
()
> > > > inside
> > > > > the
> > > > > > function. Also I am not sure if you can use another 
function
> > > > > within a
> > > > > > function ie f(n) within g(n) ?
> > > > > >
> > > > > > function g(n)
> > > > > > {
> > > > > > gr(10) = f(10);
> > > > > > for (n=11;n<=30,n++)
> > > > > > {
> > > > > > gr(n) = gr(n-1) + f(n);
> > > > > > }
> > > > > > return gr(n);
> > > > > > }
> > > > > >
> > > > > > Cheers,
> > > > > > Graham
> > > > > > http://e-wire.net.au/~eb_kavan/
> > > > > >
> > > > > > -----Original Message-----
> > > > > > From: treliff [mailto:treliff@x...]
> > > > > > Sent: Tuesday, March 09, 2004 4:04 PM
> > > > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > > > Subject: [amibroker] I need some loop-programming help
> > > > > >
> > > > > > Hi,
> > > > > > I need some loop-programming help.
> > > > > >
> > > > > > I have already defined a function f(n) (n are integers
> > > 10,11,...)
> > > > > > and now I want to define function g(n) such that
> > > > > >
> > > > > > g(10) = f(10)
> > > > > > g(11) = f(10) + f(11)
> > > > > > g(12) = f(10) + f(11) + f(12)
> > > > > > ...
> > > > > > etc. say up to g(30)
> > > > > >
> > > > > > As a clumsy mathematician (not a programmer) I would write
> > > > > something
> > > > > > like:
> > > > > >
> > > > > > function g(n)
> > > > > > {
> > > > > > g(10) = f(10);
> > > > > > for (n=11;n<=30,n++)
> > > > > > {
> > > > > > g(n) = g(n-1) + f(n);
> > > > > > }
> > > > > > return g(n);
> > > > > > }
> > > > > >
> > > > > > but this is obviously wrong, the first syntax error is 
the 
> use
> > > of
> > > > > > "g(10)" within the code.
> > > > > >
> > > > > > Can anyone help me get this code right? Thanks much in 
> advance.
> > > > > >
> > > > > > PS
> > > > > > Though this seems irrelevant to my question, the function 
f 
> is
> > > > > > defined as follows:
> > > > > >
> > > > > > function f(n)
> > > > > > {
> > > > > > return  log(C/Ref(C,-n))/(StDev(log(C/Ref(C,-1)),n)*sqrt
> (n)) ;
> > > > > > }
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Send BUG REPORTS to bugs@xxxx
> > > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > > -----------------------------------------
> > > > > > 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
> > >
> > >
> > >
> > > Send BUG REPORTS to bugs@xxxx
> > > Send SUGGESTIONS to suggest@xxxx
> > > -----------------------------------------
> > > 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
> > >
> > >
> > >
> > >
> > >



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/