PureBytes Links
Trading Reference Links
|
Hi
Sam,
Yes
you could do it that way. Not that it is any better, but i
normally early in my code define:
Buy =
Long Entry Rule...
Short = ShortEntry rule...
Sell =
Short;
Cover = Buy;
At
this stage the system is 100% reversal and trades alternate from Long to Short,
same as you require. Later down the code however I can modify the exits, for
example with ApplyStop(), this would add an extra exit signal when a stop
occurs. However the entry signals are untouched so the system is still a
reversal system however now there is a cash position between the stop exit and
the next entry. At this point I use Equity(1) which removes all redundant
signals, cleans it up nicely. No exRem() is needed in this
procedure.
Now,
if I wanted to reverse on Stops I could add
Short
= Sell;
Buy =
Cover;
after
the ApplyStop(). This would then add an extra entry signal which again could be
cleaned up with Equity(1). Note that Equity(1) is only needed if you need clean
signals (say for plotShapes) because the backtester will remove redundant
signals anyway.
As
always there are a million ways to write code and one way is not necessarily
better than the other.
take
care,
herman.
Herman,
I think I understand re:
position. Essentially this returns a value of 1 or 0 which may be of use
if you need the system to know if you are long or short.
The reason
why I have been using:
Buy = ExRem( Buy, Short); Sell = ExRem( Sell,
Buy ); Short=ExRem(Short,Buy); Cover=ExRem(Cover,Short);
is
because I do not want to take a long position unless my last trade was a
short position and vice versa (the first trade can be either short or
long). If I implement your way, the backtester may go long, stop me out
and then go long again and stop me out and so on before it comes to a
short signal. I only want to go long once, sell at my stop and then
monitor for a short signal.
Hope this makes some sense (hope that i am
using exrem correctly as well!)
Best
regards
Sam
--- In amibroker@xxxxxxxxxxxxxxx,
"Herman van den Bergen" <psytek@xxxx> wrote: > [Sam] I didn't
understand...these don't appear to do anything since they are > not
predefined variables: > > > Position =
exRem(Buy,Short); > > You were using Buy and Short in you initial
code so they were > defined...Position here is simply a custom variable
that assumes the value > of 1 when you are Long and 0 when you are
Short - useful for a variety of > purposes; for example plotting a
Position Ribbon: > Position = exRem(Buy,Short); >
Plot(1,"Position",iif (Position,colorGreen,colorRed),styleArea|styleownscale, >
0,30); > > > LongPosition = exRem(Buy,Sell); > >
ShortPosition = exRem(Short,Cover); > > The above can be used
similarly for non-reversal systems or when you use > stops. >
> [Sam] However, I essentially want to alternate between going long
and > going short. > > Not sure how you generate your
signals... the way you toggle your positions > is new to me... my
systems always define all four signals logically and > rigidly. I do
this also so that if I add stops the system will continue to >
behave as expected. I am not sure if exRem is intended to "add"
anything in > the area of signal generation...but perhaps i
misunderstand what you are > doing. > > best
regards, > herman > > > > > >
> > > > -----Original
Message----- > From: qweds_560
[mailto:qweds_560@xxxx] > Sent: Tuesday, January 18, 2005
2:41 PM > To: amibroker@xxxxxxxxxxxxxxx >
Subject: [amibroker] Re: ExRem > > > >
Many thanks Herman, > > However, I essentially want
to alternate between going long and > going short. >
> > Buy = exRem(Buy,Sell); > > Sell
= exRem(Sell,Buy); > > Short =
exRem(Short,Cover); > > Cover =
exRem(Cover,Short); > > the above means that I have
more than 1 short or more than 1 long > position in a
sequence. > > Using: > > Buy
= ExRem( Buy, Short); > Sell = ExRem( Sell, Buy ); >
> Short=ExRem(Short,Buy); >
Cover=ExRem(Cover,Short); > > seems to alternate
between long and short positions. > > I didn't
understand: > > > Position =
exRem(Buy,Short); > > > LongPosition =
exRem(Buy,Sell); > > ShortPosition =
exRem(Short,Cover); > > these don't appear to do
anything since they are not predefined > variables. >
> Could you explain? > >
Thanks > > Sam > > > >
> > > --- In amibroker@xxxxxxxxxxxxxxx,
"Herman van den Bergen" > <psytek@xxxx>
wrote: > > Assuming you are trading a reversal system,
perhaps a more logical > way would >
> be: > > > > Buy =
exRem(Buy,Sell); > > Sell =
exRem(Sell,Buy); > > Short = Sell; >
> Cover = Buy; > > > > In some
case you can use > > > > Position =
exRem(Buy,Short); > > > > but this
assumes that you are not using any other exits
(stops), > if your > > system
include other exits you might want to use this after the >
stops have > > been processed: >
> > > Buy = exRem(Buy,Sell); > >
Sell = exRem(Sell,Buy); > > Short =
exRem(Short,Cover); > > Cover =
exRem(Cover,Short); > > > > of
course you can simply use > > > >
Equity(1); > > LongPosition =
exRem(Buy,Sell); > > ShortPosition =
exRem(Short,Cover); > > > > best
regards, > > herman > >
-----Original Message----- > > From:
qweds_560 [mailto:qweds_560@xxxx] > > Sent:
Tuesday, January 18, 2005 7:10 AM > > To:
amibroker@xxxxxxxxxxxxxxx > > Subject:
[amibroker] ExRem > > >
> > > > >
Hello, > > > > I am a
little bit confused by the Exrem function. I have the >
> following: > > >
> Buy = ExRem(Buy, Short); >
> > >
Short=ExRem(Short,Buy); > > >
> > > In English, this means to me that
the backtester > > > >
i) will go long on a buy signal and then will not buy again
till > it > > has gone
short > > > > ii) will
short on a short signal and then not go short again > till
it > > has gone long >
> > > Is this correct? Do I need to define
something for SELL and for > >
COVER? > > > >
Thanks > > > >
Sam > > > > >
> > > > > >
> > > > > Check
AmiBroker web page at: > > http://www.amibroker.com/ >
> > > Check group FAQ
at: > > http://groups.yahoo.com/group/amibroker/files/groupfaq.html >
> > > > > >
>
--------------------------------------------------------------- ---- >
--------- > > -- > >
Yahoo! Groups Links > > >
> a.. To visit your group on the web, go
to: > > http://groups.yahoo.com/group/amibroker/ >
> > > b.. To unsubscribe from
this group, send an email to: > >
amibroker-unsubscribe@xxxxxxxxxxxxxxx >
> > > c.. Your use of Yahoo!
Groups is subject to the Yahoo! Terms > of
Service. > > > > > >
Check AmiBroker web page at: > http://www.amibroker.com/ >
> Check group FAQ at: > http://groups.yahoo.com/group/amibroker/files/groupfaq.html >
> > >
------------------------------------------------------------------- --------- >
-- > Yahoo! Groups Links >
> a.. To visit your group on the web, go
to: > http://groups.yahoo.com/group/amibroker/ >
> b.. To unsubscribe from this group, send an
email to: >
amibroker-unsubscribe@xxxxxxxxxxxxxxx > >
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
Check AmiBroker web page at: http://www.amibroker.com/
Check
group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
|