PureBytes Links
Trading Reference Links
|
Alex,Thanks for the repy.I changed the code and looked at the effects on the
chart that i applied the strategy to and the new code is a 14 day high or
low trailing stop.What I was trying to acheive was use the high or low of
the entry bar as the initial stop and if he initial stop isnt taken out my
exit signal would be a cross of the DMIPlus/DIMinus.I dont think I explained
it very well in my first email,
Mark
From: Alex Matulich <alex@xxxxxxxxxxxxxx>
To: Mark Williams <mr_williams79@xxxxxxxxxxx>
CC: omega-list@xxxxxxxxxx
Subject: Re: Novice EL Question
Date: Mon, 15 Dec 2003 08:38:30 -0800 (PST)
Mark:
>Hi,I am trying to write the code so once I get a Signal from the
crossover
>of the DMIPlus & DMIMinus I can reference the High/Low of the Entry Day
>depending on if the signal is for a long or short trade and then use that
>point as the stop loss.Heres what I have come up with, any feedback would
be
>appreciated on were I am going wrong.TIA Mark
I'll insert my corrections and comments below.
>Input:Length(14);
>Vars:ADXR14(0),DIPlus(0),DIMinus(0),EntryP(0);
var: stopprice(0);
{Add a variable stopprice. You'll see why below.}
>ADXR14=ADXR(14);
>DiPlus=DMIPlus(Length);
>DiMinus=DMIMinus(Length);
>EntryP=EntryPrice(1);
{You don't need EntryP or EntryPrice anywhere in your code.}
>{STOP AND REVERSE SIGNALS}
>If ADXR14>20 AND DiPlus>DiMinus Then
begin
>Buy at Market;
stopprice = lowest(low,14);
end;
>If ADXR14>20 AND DiPlus<DiMinus Then
begin
>Sell at Market;
stopprice = highest(high, 14);
end;
>{STOP LOSS SIGNALS}
>If MarketPosition=1 Then
>ExitLong("Long Stop")at Lowest(Low,EntryPrice)stop;
{The above line won't work. The second argument to Lowest() must be
a length parameter indicating the number of bars. What you want is}
stopprice = MaxList(stopprice, Lowest(Low,14));
ExitLong("LS") at stopprice stop;
{This will calculate the lowest low of the past 14 bars (you could
make 14 a variable or a parameter) and use the greater of that or
the previous stop price as your stop order for the next bar. You don't
want the ExitLong stop to get lower, only higher, which is why you need
to compare it to the previous value.}
>If MarketPosition=-1 Then
>ExitShort("Short Stop")at Highest(High,EntryPrice)Limit;
stopprice = MinList(stopprice, Highest(High,14));
ExitShort("SS") at stopprice stop;
--
,|___ Alex Matulich -- alex@xxxxxxxxxxxxxx
// +__> Director of Research and Development
// \
// __) Unicorn Research Corporation -- http://unicorn.us.com
|