PureBytes Links
Trading Reference Links
|
Steve,
If you have more than 500 data in some stock, paste in ind. builder
the
x=IIf(Cum(1)<400,Cum(1),IIf(Cum(1)>=400 AND
Cum(1)<500,2000-4*Cum(1),IIf(Cum(1)>=500 AND
Cum(1)<510,1,Cum(1)-509)));
Plot(x,"",2,1);
Y=Flip(X<Ref(X,-1),X>Ref(X,-1));Plot(100*Y,"",1,1);
Buy=Y<Ref(Y,-1);
Plot(Buy*100,"",4,2);Plot(x,"",2,8);
and you will see how it works.
Y is triggered with the first x<ref(x,-1) and remain until the first
x>ref(x,-1).
DT
--- In amibroker@xxxx, "Steve Dugas" <sjdugas@xxxx> wrote:
> DT,
>
> Wow - What a "Beautiful Mind" !!
>
> I spent hours thinking about this : - (
>
> Anyway, the charts look perfect now. I even figured out how to
adapt your formula for sell/short/cover. Thank you very much!!!!
>
> Steve
>
> ----- Original Message -----
> From: dtsokakis
> To: amibroker@xxxx
> Sent: Sunday, April 28, 2002 9:59 AM
> Subject: [amibroker] Re: can I do this without script?
>
>
> Steve,
> try
> X=MA(C,30);
> Y=Flip(X<Ref(X,-1),X>Ref(X,-1));
> Buy=Y<Ref(Y,-1);
>
> DT
> --- In amibroker@xxxx, "Steve Dugas" <sjdugas@xxxx> wrote:
> > Hello All,
> >
> > I am stuck on what was supposed to be some very simple code,
and
> grew into a problem. I wonder if someone would be kind enough to
> give me some advise. Details are below, but to make a long story
> short:
> >
> > Here is what I am trying to code (simple moving average
reversal -
> buy when average turns up):
> >
> > buy = today's MA > yesterday's MA
> > AND
> > yesterday's MA < MA of most recent day before yesterday
whose MA
> was not equal to yesterday's
> >
> > Here is what I have so far:
> >
> > buy = ma(close,30) > ref(ma(close,30),-1)
> > AND
> > ref(ma(close,30),-1) < ? (this is the tough part)
> >
> > Tomasz says that 90% (or whatever) of things can be coded
without
> using scripts. Can this one be done in AFL? It looks like I need
to
> iterate the database, right?
> >
> > OK, here comes the whole sad story for anyone who is interested:
> >
> > I originally thought this would be very simple to code, and I
coded
> it as follows:
> >
> > buy = ma(close,30) > ref(ma(close,30),-1)
> > AND
> > ref(ma(close,30),-1) < ref(ma(close,30),-2)
> >
> > After I ran this, and was looking at the resulting trade arrows
on
> the chart, it was obvious that I was missing some trades (and
some
> BIG price moves). I did a quick exploration to debug it, which
> revealed that (for many stocks, over a long period) there are
MANY
> instances where the moving average does not change for 2, 3, even
10
> or more days in a row. It remains the same right out to 9 decimal
> places! One reason for this appears to be that for some stocks,
even
> though they trade frequently enough now, they would sometimes go
for
> days without a trade in their early days. There may be other
reasons
> too, I didnt follow up on all of them. So this brings me to my
> current situation - my original simple code only works correctly
if
> the MA changes every day, which sometimes it doesnt. In order to
make
> this work properly, I need to look back, day-by-day, starting
with
> the day-before-yesterday, until I come to a day whose moving
average
> is different than yesterday's, and then use that days MA in my
> formula. Any advise is greatly appreciated. Thanks very much!
> >
> > Steve
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
|