hi,

I believe these type of problems are usually solved using static variables. 
This example below would avoid two signals to be sent within the same hour and 
minute. Didn't test it but along these lines it can be done, regards Ed

buycondition1=rule1;
buycondition2=rule2;

if (buycondition1 and buycondition2) {

    myvar = StaticVarGet( hour() + minute() ); 

    if ( myvar != 1 ) {

        Alertif   ( buycondition1 and buycondition2);
        StaticVarSet( hour() + minute(), 1);

    }

} else if ( buycondition1 and NOT buycondition2 ) {

    myvar = StaticVarGet( hour() + minute() ); 

    if ( myvar != 1 ) {

        Alertif   ( buycondition1 and NOT buycondition2);
        StaticVarSet( hour() + minute(), 1);

    }

}



  ----- Original Message ----- 
  From: Padhu 
  To: [email protected] ; [EMAIL PROTECTED] 
  Sent: Wednesday, August 01, 2007 7:27 AM
  Subject: [amibroker] Best practices on avoiding multiple alerts being 
triggered on the same bar



  Hello,

  I see that sometimes when there is a multiple rule match on the same bar, 
Alertif generates consective Buy signals for rule1 and rule2.

  For now I have a work around:
  buycondition1=rule1;
  buycondition2=rule2;

  Alertif   ( buycondition1 and buycondition2)
  Alertif   ( buycondition1 and NOT buycondition2)

  and so on...Problem is I have 4 buy rules and this method is not 
scalable...Unless I build so many permutations /combinations.

  Is there a better way to handle this so that if Alert is triggered, ONLY the 
first buy alert is sent to the output/email and  then subsequent alerts for the 
same timestamp on that bar are suppressed?.

  I see in the doc about 

  Buy = ExRem(Buy,Sell);

  Can this help here?. 
  Something like Buy=Exrem(buycondition1,buycondition2);   Will this work?.



   Thanks.

  Cheers,Padhu



   

Reply via email to