PureBytes Links
Trading Reference Links
|
If I'm understanding the problem correctly, it sounds like one I
finally solved for myself, using "normal" (non-looping, non-
Composite) AFL. In English, my "thing" was: If the "buy" condition
is met today, "buy", but only if the last "buy" signal would have
resulted in a losing trade.
I used the ValueWhen function to find the entry and exit points on
the trade previous to the one currently being signaled, then made
reference to them as a condition of the new trade being signalled.
The distinction being that I wasn't referring to an actual "trade"
but "the conditions under which the previous trade would have been
made." Another tip, the latest signal is the most recent occurrence
of a "buy" condition, but the previous "buy" signal is the 2nd-most
recent occurrence, and that was an important point in defining the
previous condition.
The difficulty I had wasn't with coding, which was straightforward,
but with my own mistakes in simply-but-precisely defining the
conditions I was looking for. What helped me solve the problem was
to display the code that I started with as buy/sell arrows on a
chart, so that I could eyeball the signals for errors and zero-in on
where my definitions weren't correct.
Hope that helps give you an idea how to solve your "deal.":)
Luck,
Sebastian
--- In amibroker@xxxxxxxxxxxxxxx, neurotic self <neuroticself@xxxx>
wrote:
> Figured it out somehow
>
> Running the code via Scan after adding
>
> AddToComposite(Indicator, "~Indicator", "X");
>
> and then plotting the resulting symbol with Foreign instead of
> plotting Indicator directly I can see that the correct adjustment
have
> been made.
>
> I guess that for the sake of efficiency the bars used when graphing
> are less than when scanning (there I have full control of the period
> used), I tried
>
> SetBarsRequired(-100000, 100000);
>
> in the graph also but it didn't seem to work
>
> Still it would have been nice to obtain this with VALUEWHEN to look
at
> the past instead of looping, if somebody feels like giving
> suggestions... I'm beginning to think it can't be made w/o loop
>
> On 9/10/05, neurotic self <neuroticself@xxxx> wrote:
> > Maybe somebody could have a look at what's wrong with this code?
runs
> > ok, but I don't get the indicator adjusted
> >
> > remember that:
> > > Trying to build an indicator along the following lines:
> > > if price at bar satisfies condition Cond1 then Indicator = 1
> > > UNLESS the price did NOT satisfy Cond2 from last time Indicator
was 1
> > > AND Close was == Close at bar, in which case Indicator = 0
> >
> > Indicator = IIf(Cond1, 1, 0); // first just check Cond1 on all
history
> >
> > //adjust for Cond2
> > for (i= 1; i < BarCount; i++) {
> >
> > if ( Cond1[i] )
> > for (k=i-1; k > 0 ; k--) { // looking at the past of bar i
> > if ( Close[k] == Close[i] AND Cond1[k] ) { Indicator[i] =
0; j
> > = 0;} // adjust bar i, exit loop
> > if ( Cond2[k] ) k = 0; // Cond 2 met, exit loop
> >
> > }
> >
> > }
> >
> > On 9/9/05, neurotic self <neuroticself@xxxx> wrote:
> > > This is causing me a big headache, hope I can express my
problem clearly...
> > >
> > > Trying to build an indicator along the following lines:
> > > if price at bar satisfies condition Cond1 then Indicator = 1
> > > UNLESS the price did NOT satisfy Cond2 from last time Indicator
was 1
> > > AND Close was == Close at bar, in which case Indicator = 0
> > >
> > > I thought of using ValueWhen so
> > >
> > > bi = BarIndex();
> > > Indicator[0] = Cond1[0];
> > > Indicator = IIf (ValueWhen(bi, Ind == 1 AND Close ==
CloseAtBar) <
> > > ValueWhen(bi, Cond2 ), Cond1, 0)
> > >
> > > Can't find a way to reference CloseAtBar, tried via Barindex()
with
> > > C[Barindex()] but that makes no sense given that Barindex() is
an
> > > array and can't be used as a subscript
> > >
> > > Also tried to explicitly loop back in the past from current bar
to
> > > check if Cond2 was met before price touched again price at bar
and
> > > Indicator was 1, kind of like
> > >
> > > for (i=BarIndex() ; i > 0; i--) {...
> > >
> > > but again Barindex() is not the "current" bar but an array
> > >
> > > Maybe I should loop all the history
> > >
> > > for( i = 1; i < BarCount ; i++)
> > >
> > > and compute Indicator bar by bar? I did something similar with
the
> > > custom backtester but I'd really like a simplier solution, feel
like
> > > valuewhen could do the job, but that function always escaped me
> > > somehow :(
> > >
> > > Thanks for any help
> > > n.
> > >
> > > --
> > > Janeczko for President!
> > >
> >
> >
> > --
> > Janeczko for President!
> >
>
>
> --
> Janeczko for President!
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a difference. Find and fund world-changing projects at GlobalGiving.
http://us.click.yahoo.com/PcNrnD/PbOLAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~->
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.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/
|