Loading ...
Sorry, an error occurred while loading the content.

Re: [amibroker-afl] How to write this is the first buy signal in the past 6 bars - Thanks..That works..

Expand Messages
  • Padhu
    Hello Graham, That additional equal to made all the difference. Thank you so much for the answer. It works great. I appreciate you taking the time to solve
    Message 1 of 1 , Jul 10, 2007
    View Source
    • 0 Attachment
      Hello Graham,
       
      That additional equal to made all the difference. Thank you so much for the answer. It works great.
      I appreciate you taking the time to solve this problem.
       
      Cheers,Padhu
       
      ----- Original Message -----
      From: Graham
      Sent: Tuesday, July 10, 2007 8:19 PM
      Subject: Re: [amibroker-afl] How to write this is the first buy signal in the past 6 bars

      Here is one method

      buy=condition1 and sum(condition1, 5)==1;

      also remember that a single = means allocating a value to a variable. To check if it is equal to that value use double ==
      and unless the variable is previously defined you defined you cannot reference it in a statement, eg A=A; does not work unless A was defined above it


      --
      Cheers
      Graham
      AB-Write >< Professional AFL Writing Service
      Yes, I write AFL code to your requirements
      http://www.aflwriti ng.com


      -----Original Message-----
      From: amibroker-afl@ yahoogroups. com [mailto:amibroker-afl@yahoogroups. com] On Behalf Of Padhu
      Sent: Tuesday, July 10, 2007 5:14 PM
      To: amibroker@yahoogrou ps.com
      Cc: amibroker-afl@ yahoogroups. com
      Subject: [amibroker-afl] How to write this is the first buy signal in the past 6 bars

      Folks,

      Say i have buy = condition1;

      Alert gets generated... Now few bars later again condition1 matches and another alert gets generated.

      So i'd like add a filter that says Buy=condition1 and this is the first Buy in the past six bars so that buy signals don't repeat every other bar if the condition matches.

      I tried something like this

       buy=condition1 and ref(buy,-1)= 0 and and ref(buy,-2)= 0 and and ref(buy,-3)= 0 and and ref(buy,-4)= 0.

      But its not working.

      How do I code this in AB 4.9?. Thanks.

      cheers,Padhu




    Your message has been successfully submitted and would be delivered to recipients shortly.