[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: How to buy on multiple conditions?



PureBytes Links

Trading Reference Links

I have found a solution and am posting this in case anyone else is 
struggling with the same issue.

regards,
Tom

.
.
.
event_setup = Sector_50DMA AND Industry_50DMA AND Industry_rsi AND 
Stock_rsi;

event_buy = Sector_50DMA_buy AND Industry_50DMA_buy AND 
Industry_rsi_buy AND Stock_rsi_buy;


for(i=0;i<BarCount-1;i++)
{
  if(event_setup[i])
  { 
    for(k=i;k<BarCount-1;k++)
    {
      if(event_buy[k])
      {
       Filter[k] = Buy[k] = 1;
       k = BarCount -1;  // break out of inner loop
      }
      
    }
  }
}


--- In amibroker@xxxxxxxxxxxxxxx, "trb0428" <tombrowne34@xxx> wrote:
>
> Hi-
> 
> I want to buy when four multiple buy setup conditions rise above a  
> certain level after falling below a certain level. I can easily 
detect 
> when these setup conditions are met (all below the level) at the 
same 
> time with the  Buy statement below but I dont want to buy then. I 
want 
> to buy the first day when all four of these conditions are no 
longer 
> true (all above the level) after having been true. I have tried 
various 
> attempts using exrem and flip and  highestsince and combinations 
> thereof but I can't seem to get there. I am hoping this is a common 
> issue and someone can steer my down the right path.
> 
> Thanks,
> Tom
> 
> Sector_50DMA = Sector_ratio <= LastValue(Percentile
> (Sector_ratio,Limit_period,10));
> 
> Industry_50DMA = Industry_ratio <= LastValue(Percentile
> 
> Industry_rsi = RSIa(FC,12) <= LastValue(Percentile(RSIa(FC, 
> 12),Limit_period,10));
> 
> stock_RSI = RSI(12) <= LastValue(Percentile(RSI
(12),Limit_period,10));
> 
> BUY = Sector_50DMA AND Industry_50DMA AND Industry_rsi and stock_RSI
>



Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date: 2/14/2007 4:17 PM