Rising Prices with Rising Volumes in EasyLanguage

Discussion in 'Strategy Development' started by travis, Jun 25, 2003.

  1. travis

    travis

    I have implemented a trend filter with "data2" being the weekly timeframe on the same future. It says "If we have had, on the previous week, rising/falling prices with rising volumes then only allow long/short trades for this coming week". However, it also implies that if we had falling volumes on the previous week, the system will stay flat, no matter what, for the whole coming week. And this is not what I want, because volumes can't rise forever. Let's say we have 8 rising weeks - they can't be 8 weeks of constantly rising volumes, and yet the trend is up for all these 8 weeks, and we should be able to accept long signals from our system.

    So my question is this - how do I tell the system to accept long/short signals if we are in a positive/negative trend, and at the same time establish the trend with this rule - "if we have a reversal in the direction of price (on a weekly basis), then reverse the trend only if it comes with rising volumes, otherwise keep the previous trend position, no matter what volumes you get".

    Basically, I want to say "If we have no reversal in price, stay with the previous trend, no matter what the volume is, and the previous trend is one that only gets established by a reversal in prices coming with increasing volumes". Right now, instead, in a trend in price that's several weeks long, the system stays flat unless it gets ever rising volumes, which is impossible.


    Inputs: FastLength(x), SlowLength(y), PercentTarget(w), PercentRisk(z),
    TS1_Start(a), TS1_Stop(b), TS2_Start(c), TS2_Stop(d), TS3_Start(e), TS3_Stop(f);

    Variables: TimeAll(0), Fast(0), Slow(0);
    ...

    {*** entries ***}
    If (MarketPosition <> 0 And Openpositionprofit > (AbsValue(EntryPrice) * PercentTarget)) Or (MarketPosition = 0) Then
    Begin

    If CurrentBar > 1 And Fast Crosses Above Slow And TimeAll = 1 And (c of Data2 > c[1] of Data2 and v of Data2 > v[1] of Data2) Then
    Buy This Bar;

    If CurrentBar > 1 And Fast Crosses Below Slow And TimeAll = 1 And (c of Data2 < c[1] of Data2 and v of Data2 > v[1] of Data2) Then
    Sell This Bar;

    end;

    {*** exits ***}
    ...


    {*** stoploss ***}
    ...
     
  2. I don't fully understand what you're trying to achieve, but it sounds like you need a True/False "flag" along the lines of:

    If Condition1 and Condition2 then TrendChange = True else TrendChange = False;

    or

    If Condition1 and Condition2 then TrendChange = True;

    If Condition3 then TrendChange = False;

    You'd use the flag by adding it to entry or exit statements:

    If TrendChange = True then...

    else...

    You could also define the flag numerically, and introduce a wider range of alternatives, but you'd also have to deal with a wider range of complications ensuring that the various alternatives were on or off at the right times.
     
  3. travis

    travis

    I think I have it solved, thank you.

    As you suggested, I created a variable to simplify things, but I didn't need to use "Else", as somehow it understood what I wanted to do.

    Inputs: ...

    Variables: ...Trend(0);

    If (c of Data2 > c[1] of Data2 and v of Data2 > v[1] of Data2) Then
    Trend = 1;
    If (c of Data2 < c[1] of Data2 and v of Data2 > v[1] of Data2) Then
    Trend = -1;

    ...

    {*** entries ***}
    If (MarketPosition <> 0 And Openpositionprofit > (AbsValue(EntryPrice) * PercentTarget)) Or (MarketPosition = 0) Then
    Begin

    If CurrentBar > 1 And Fast Crosses Above Slow And TimeAll = 1 And Trend = 1 Then
    Buy This Bar;

    If CurrentBar > 1 And Fast Crosses Below Slow And TimeAll = 1 And Trend = -1 Then
    Sell This Bar;

    end;

    ---------

    It works really well on the Italian Fib future.
     
  4. I'm glad it works for you. It may be that what would have been the "else" condition is irrelevant to what you're working on or that some other element in the entry signal keeps it from mattering.

    The problem that you may run into when using flags - and that you can sometimes handle directly with "else" statements, other times might want to directly address - is that once the conditions set the flag, it remains in force even after the conditions no longer are present, until and unless something re-sets it. You can end up with entry conditions that always re-enter as soon as you're stopped out, for instance.

    Good luck, and, uh, what's an Italian Fib?
     
  5. travis

    travis

    The Fib-30 future is the future on the Italian index called Mib-30. We also have the mini-fib, which requires a margin a little higher than the E-mini Nasdaq. But this system works as well on the E-mini Nasdaq.
     
  6. Still waiting for a stupid post about Fib Ratio and Fib Index...

    Oh shit... that's me...

    :eek: :eek: :eek: