PureBytes Links
Trading Reference Links
|
If I recall correctly, this code would not be expected to work.
Since you're adding a large number to all PositionScores and saying
Buy when greater than zero, you are effectively saying always buy.
Similarly, when subtracting a large number from all PositionScores
and saying Short when less than zero, you are effectively saying
always short.
To summarize, what you are effectively saying is:
Buy=FirstHourUp AND true;
Short=FirstHourUp AND true;
At this point, all your PositionScores are negative (for Buys and for
Shorts) since the last thing you did to the array was subtract a
large number. All your PositionScore are equal to PS - 1000, which
can give the highest absolute value to the *worst* performers when
all PS values were positive to start out with.
Now, AmiBroker will see that you have a maximum allowance of 2 open
positions, so it will sort using the absolute value of PositionScore
and store double the number of max positions. So, because of the way
you've done your PostionScore, you may be left with the scores of the
4 worst performers going in to the final stage.
At the final stage, AmiBroker will see that Buy and Short are set to
true for *all* symbols meeting the FirstHourUp criteria. What I think
is happening is that by default you cannot have multiple positions
open on the same sybol, and that Buy takes precedence over Short. So,
all signals are tagged as Buy (of which you are only taking 1) and
you have no Short signals at all.
So, not only are you only getting Buys, but you may also be getting
the *worst* Buy since your PositionScore last favored the lowest PS
value.
This, of course, is all speculation until tested. I could be way off.
Mike
--- In amibroker@xxxxxxxxxxxxxxx, "claudecaruana" <claudecaruana@xxx>
wrote:
>
> Thanks for your feedback.
>
> this might sound crazy, but I am still getting only longs with this
> code....
>
> FirstHourUp = IIf (TimeNum() == 103000,True,False);
> numbars=13;
> SetOption("MaxOpenPositions", 2);
> SetOption("MaxOpenLong", 1 );
> SetOption("MaxOpenShort",1);
> SetOption("SeparateLongShortRank", True );
> PS = ROC(C,NumBars)/ATR(250);
> PositionScore=ps+1000;
> Buy= FirstHourUp AND PositionScore > 0;
> PositionScore=ps-1000;
> Short=FirstHourUp AND PositionScore < 0;
>
>
> Sell = TimeNum() == 113000;
> SellPrice = C;
> Cover = TimeNum() == 113000;
> CoverPrice = C;
>
> Is anybody willing to try it out?
>
> Cheers,
> Claude
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Ron Rowland" <rowland@> wrote:
> >
> > Just take the negative of the ABS value of the lowest
PositionScore.
> > Or force it by subtracting a large number. You will also need to
> > account for the times when the best score is neagive. For
example:
> >
> > PS = ROC(C,NumBars)/ATR(250);
> > PositionScore = PS +1000; // force everthing to be positive
> > // Buy longs here
> > PositionScore = PS -1000; // invert the list from absolute value
> > perspective
> > // Buy shorts here
> >
> >
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "vlanschot" <vlanschot@> wrote:
> > >
> > > One way of solving this would be to deduct an average ROC from
some
> > > aggregate index from each of your individual scores, e.g. if
your
> > > stocks belong to the S&P500, deduct its ROC from each of your
> > > individual ROCs (you can also create one yourself). You are
correct
> > > in using the new functionality to seperate your shorts from
your
> > > longs via the MaxOpenLong and MaxOpenShort functions.
> > >
> > > Hope this helps.
> > >
> > > PS
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, "claudecaruana"
<claudecaruana@>
> > > wrote:
> > > >
> > > > Hi,
> > > >
> > > > Actually the code I supplied on my original message already
does
> > > > this.. Works ok if the positionscores for each iteration
contain
> > > both
> > > > positive and negative values. If they are all positive or all
> > > negative
> > > > the code below would fail.
> > > >
> > > > BR
> > > > C
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "Joe" <j0etr4der@> wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > This bit me, too. From the AFL Reference Manual, section
on
> > Using
> > > > > Position Score, "...AmiBroker will use the absolute value of
> > > > > PositionScore variable to decide which trades are
preferred."
> > > > >
> > > > > Try this (untested):
> > > > >
> > > > > PS = ROC(C,NumBars)/ATR(250);
> > > > > PositionScore = PS;
> > > > > .
> > > > > .
> > > > > .
> > > > > Buy=FirstHourUp AND PS > 0;
> > > > > Short=FirstHourUp AND PS < 0;
> > > > >
> > > > >
> > > > > Good luck,
> > > > >
> > > > > Joe
> > > > >
> > > > >
> > > > >
> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "claudecaruana"
> > <claudecaruana@>
> > > > > wrote:
> > > > > >
> > > > > > hi All,
> > > > > >
> > > > > > I am trying to implement a very simple intraday system
using
> > > > > > PositionScore, which buys the strongest symbol at a
> > particular
> > > time
> > > > > > and shorts the weakest. Exit is at some particular time
> > later.
> > > > > >
> > > > > > I am using ROC to determine strength. The code below
works
> > fine
> > > when
> > > > > > the symbols backtested have mixed positive and negative
> > ROC's,
> > > but if
> > > > > > on a particular day all ROC's are positive, the short
trade
> > is
> > > missed
> > > > > > and vice versa for all ROC's negative.
> > > > > >
> > > > > > I think I understand why this is happening, however I
cannot
> > get
> > > > > > around solving it!
> > > > > >
> > > > > > Here is the code: (I am using V5.17)
> > > > > >
> > > > > > FirstHourUp = IIf (TimeNum() == 103000,True,False);
> > > > > > numbars=13;
> > > > > >
> > > > > > SetOption("SeparateLongShortRank", True );
> > > > > > SetOption("MaxOpenPositions", 2);
> > > > > > SetOption("MaxOpenLong", 1 );
> > > > > > SetOption("MaxOpenShort",1);
> > > > > >
> > > > > > PositionScore = ROC(C,NumBars)/ATR(250);
> > > > > >
> > > > > > Buy=FirstHourUp AND PositionScore > 0;
> > > > > > Short=FirstHourUp AND PositionScore < 0;
> > > > > >
> > > > > > Sell = TimeNum() == 113000;
> > > > > > Cover = TimeNum() == 113000;
> > > > > >
> > > > > >
> > > > > > Note: If I replace the buy/sell lines with the following:
> > > > > >
> > > > > > Buy=FirstHourUp ;
> > > > > > Short=FirstHourUp ;
> > > > > >
> > > > > > then I get no short signals at all. I am not sure why.
> > > > > >
> > > > > > Any ideas on what I can do to resolve the issue?
> > > > > >
> > > > > > Thanks for any feedback,
> > > > > > Claude
> > > > > >
> > > > >
> > > >
> > >
> >
>
------------------------------------
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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
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/
<*> 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:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto: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/
|