easylanguage question

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

  1. 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


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


    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:


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


    Happy Holidays. :D
  3. travis


    Thank you very very much.
  4. I think the '[1]' added as above will work.
  5. 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);

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