[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Novice EL Question



PureBytes Links

Trading Reference Links

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