How to count the number of generated signals in an BUY array


The array "BUY" contains either 0 or 1. I want to count number of 1's In an array?
If any sample code is there that is much appreciated.

Thanks in advance.

cs = Cum(Buy);

Hi @fxshrat Thanks for your reply. But the variable "CS" is giving array not the number of 1s (number of buy signals) generated so far.
please find the below code.

if ( LastValue(Buy) == True AND Cum(Buy)==0)

//Place market order to buy


I am trying to place only one order per a stock.If signal is already generated for the stock i do not want to put the second order.So i am counting number of buy signals generated for a particular stock .If it is zero means there are no buy signal is generated as of now.Please correct the above code.

Thanks in advance.

Do forum search

and many more posts and threads (also take a look at old AmiBroker Yahoo groups mailing list) ....

As well as AB Knowledge base

As for array within if statement look at your other thread of few minutes ago (see below link) and many many other ones in this forum... this is old old old stuff and has been covered multiple times already. Again please use forum search!

1 Like