PureBytes Links
Trading Reference Links
|
--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
> Hi,
> Nothing wrong with wanting to understand the mechanics. Before getting
> into that, however, I did not understand your comment
> "it starts to count wrong(should count to 3, but counts to 2 only
> considering the 1st triple of crossovers, probably due to initializing
> the EMA200) "
> What exactly do you mean by that? Can you give a specific example citing
> a specific symbol over a specific date range and indicate what you
> expected to see vs. what you are seeing?
> Looking at your original post;- Your first attempt should not be using
> AND. Two separate statements separated by ';' is the correct way to go,
> as you had done in the second attempt.
> - In your second attempt, you are using the wrong condition for
> incrementing Counter. You should be checking for "true" values (i.e. non
> zero).
> Here is a corrected version of your code. I believe that it will give
> you what you want, and, in my tests anyway, line up exactly with the non
> looping version that I sent you originally.
> /* Option 1
> EMA1 = EMA( C, 10 );
> EMA2 = EMA( C, 200 );
> Plot( EMA1, "EMA10", colorRed, styleLine );
> Plot( EMA2, "EMA20", colorBlue, styleLine );
>
> Buycross[0] = 0;
> exit[0] = 0;
>
> threshold = 3;
> multiplier = 1;
>
> Buycross = Cross( EMA1, EMA2 );
> Counter = Cum( Buycross );
>
> // start loop
>
> for ( i = 0; i < BarCount;i++ )
> {
> if ( Counter[i] == threshold*multiplier )
> {
> multiplier++;
> exit[i] = 1; // separate statements, not "AND"!
> }
> }
>
> printf( "buycross:\n" );
>
> WriteVal( Buycross, 1 );
> printf( "counter:\n" );
> WriteVal( Counter, 1 );
> printf( "multiplier:\n" );
> WriteVal( multiplier, 1 );
> printf( "exit:\n" );
> WriteVal( exit, 1 );
> */
>
>
> /* Option 2
> EMA1 = EMA( C, 10 );
> EMA2 = EMA( C, 200 );
> Plot( EMA1, "EMA10", colorRed, styleLine );
> Plot( EMA2, "EMA20", colorBlue, styleLine );
>
> Buycross[0] = 0;
> exit[0] = 0;
> COUNTER = 0;
> threshold = 3;
> multiplier = 1;
>
> Buycross = Cross( EMA1, EMA2 );
>
> // start loop
>
> for ( i = 0; i < BarCount;i++ )
> {
> if ( buycross[i] != 0 ) // Check for NOT zero!
> {
> counter++;
> }
>
> if ( Counter == threshold*multiplier )
> {
> multiplier++;
> exit[i] = 1;
> }
> }
>
> printf( "buycross:\n" );
>
> WriteVal( Buycross, 1 );
> printf( "counter:\n" );
> WriteVal( Counter, 1 );
> printf( "multiplier:\n" );
> WriteVal( multiplier, 1 );
> printf( "exit:\n" );
> WriteVal( exit, 1 );
> */
> Mike
> --- In amibroker@xxxxxxxxxxxxxxx, "Matthias" <m.kuschel31@> wrote:
> >
> >
> > Hello,
> >
> > Thanks to all for the prompt reply. (I just figured out how to format
> > this, my 1st post looked a little strange).
> >
> > EMA1 = EMA(C, 10);
> >
> > EMA2 = EMA(C, 200);
> >
> > Buycross = Cross(EMA1, EMA2);
> >
> > Counter = Cum(Buycross);
> >
> > Triples = Cross(Counter % 3 == 0, 0);
> >
> > Plot(EMA1,"EMA10", colorRed,styleLine);
> >
> > Plot(EMA2,"EMA20",colorBlue,styleLine);
> >
> > Plot(Triples, "Triples", colorGreen, styleOwnScale | styleHistogram);
> >
> > This code works absolutely fine, many thanks, only problem here: it
> > starts to count wrong(should count to 3, but counts to 2 only
> > considering the 1st triplele of crossovers, probably due to
> intializing
> > the EMA200) any suggestions? But I need you to understand where I am
> > coming from:
> >
> > Obviously you are much more experienced in writing afl than me and I
> get
> > Mike's basic concept of avoiding loops for proefficient coding and the
> > "EMA-plot-labeling" was not correct.
> >
> > You have to understand that I am trying to realize/code my ideas and
> the
> > 2nd code is where I started off and probably would start off again, be
> > it good or bad programming. I do have your solution to my problem now,
> > but I still don't understand why my "concept" does not do the job. Of
> > course I did read the articles on "How AFL works", this was were I
> > started and also got a hand on the barcount funtion which I thought
> was
> > the problem (not counting the whole OHLC-array due to faster
> processing
> > speed). I also asked my brother on this simple one, who is used to
> > programming C. As AFL is "C-based" I would have assumed this code
> should
> > work. Please help me to understand what went wrong / is wrong in my
> > logic here, I consider understanding this basic concept to be very
> > important for future purpose.
> >
> > Thanks in advance,
> >
> > Matthias
> >
>
Hi,
Mike, thanks for helping me out on this. Your code was completely right, I made a mistake counting the crossovers, I tried it with other symbols. I appreciated your help, thank you very much again, even though my questions were "starter-questions" .
Matthias
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
amibroker-digest@xxxxxxxxxxxxxxx
amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> 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/
|