• Australian (ASX) Stock Market Forum

Hello and welcome to Aussie Stock Forums!

To gain full access you must register. Registration is free and takes only a few seconds to complete.

Already a member? Log in here.

Amibroker Question: Delay buying signal until second condition is verified

Discussion in 'Software and Data' started by dari08ab, Mar 11, 2013.

  1. dari08ab

    dari08ab

    Posts:
    4
    Likes Received:
    0
    Joined:
    Feb 26, 2013
    Dear All,

    I am trying to implement a simple logic:

    1) Find a bar for which MA(C,5) crosses above MA(C,15)
    2) From that bar, wait until MA(RSI(),5) crosses above MA(C,15)
    3) If 2) happens within 10 bars, then execute a buy otherwise skip

    I wrote the following AFL code:

    Crossma = Cross(MA(C, 5), MA(C, 15));
    Crossrsi = Cross(MA(RSI(), 5), MA(RSI(), 15));
    Buy = Crossma AND Crossrsi ;

    The problem is that, it seems to me that, Amibroker tests both the conditions on the same bar, where I would like to use the crossover of MA(C) as setup and pull the trigger within the following 10 bars, only if MA(RSI,5) crosses above MA(RSI,15).

    Any suggestion on how this could it be done?

    Thanks
    Davide
     
  2. AlterEgo

    AlterEgo

    Posts:
    500
    Likes Received:
    7
    Joined:
    May 24, 2008
    Try:

    Buy = BarsSince(Crossma) <= 10 AND Crossrsi ;
     
Loading...

Share This Page