easylanguage question

Discussion in 'Strategy Building' started by travis, Dec 27, 2003.

  1. travis

    travis

    ExitLong Next Bar at Lowest(Low, Length) Stop;

    I gave the system a stop order to get out of a long trade at the lowest low of the last x periods, because if this was taken it would negate the reversal.

    My problem is that with this code, it doesn't consider the "lowest low of the last x periods" BEFORE the entry bar, but BEFORE the close of the moment (which keeps moving ahead).

    How do you write it so that it will only consider the x periods BEFORE the entry bar? Thank you.
     
  2. TGregg

    TGregg

    Use the BarsSinceEntry global var (or is it a function? Don't recall). For example, if your reverse failure area was 20 bars long:

    ReverseFailurePoint=lowest(low,(20+BarsSinceEntry));

    Or, if you are willing to accept a lower low since you entered the trade, but want to get the lowest low of the 20 bars prior to entry:

    OldLow=lowest(low,20)[barsSinceEntry];

    Not sure if that will work. If it doesn't try this:

    OldLow=lowest(low,20);
    SetStopLoss(OldLow[BarsSinceEntry]);

    Happy Holidays. :D
     
  3. travis

    travis

    Thank you very very much.
     
  4. I think the '[1]' added as above will work.
     
  5. travis

    travis

    Thank you both.

    I have used another method, which seems to work, but it's not as short as your code. However I understand it better, because it takes more steps to give the system the instructions. (Let me know please if you think there is anything wrong with it).

    If barssinceentry = 1 and MarketPosition <> 0 Then Begin
    Bottom = Lowest(Low, Low_Length) - (AbsValue(EntryPrice) * PrTol);
    Top = Highest(High, High_Length) + (AbsValue(EntryPrice) * PrTol);
    end;

    If Openpositionprofit < 0 Then Begin
    If close < Bottom Then ExitLong ("Low X") This Bar;
    If close > Top Then ExitShort ("High X") This Bar;
    end;