PureBytes Links
Trading Reference Links
|
i totally get it now. i've done several arrays and combined them to get the results i need by just using Filter.
i still got one big problem though.
i havent been able to figure out how to Sum the cells in a row/array.
x [0, 1, 1, 0, 0, 0, 1] y [1, 1, 1, 1, 0, 1, 1]
i need to Sum all ones in x and divide them by all the ones in y to get a percentage. the example above should yield 3/6 = 0.5
and then output it as AddColumn(percent,"Percentage")
i've tried both Sum() and Cum() as someone here suggested but i cant get the right result. dont know why.
please any suggestions are appreciated
thanks!
--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote: > > See Andrew's reply for the solution. http://finance.groups.yahoo.com/group/amibroker/message/135499 > > Basically, you don't need a loop at all. It is actually pretty rare > that you ever need one. In the vast majority of cases, your problem > can be expressed in array manipulations across all bars > simultaneously. > > If you haven't come across this page yet, it helps to clarify things: > http://www.amibroker.com/guide/h_understandafl.html > > Mike > > --- In amibroker@xxxxxxxxxxxxxxx, "bigitop" doctormuniz@ wrote: > > > > i read the user guide thouroughly but it seems im missing something. > > i had tried "if(result == 1)" (with the equality operator) but it > > gives me the same error as in the beginning: > > > > variableX = variableY / abs(variableZ); > > result = IIf (variableX > .5, 1, 0); > > > > if(result == 1){ > > Filter = Open > 40 & Open < 60; > > } > > > > it is still seeing "result" as an array instead of as a number! > > > > "Condition in IF, WHILE, FOR statements has to be numeric or boolean > > type. You cannot use an array here, please use [] (array subscript > > operator) to access array elements" > > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "sidhartha70" <sidhartha70@> > wrote: > > > > > > You need to use == instead of =... > > > > > > i.e. change the line, > > > > > > if(result = 1){ > > > > > > to, > > > > > > if(result == 1){ > > > > > > '==' checks equality... '=' assigns a value... > > > > > > I would recommend a good read of the AFL user guide... then all > this > > > will be obvious. > > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "bigitop" <doctormuniz@> wrote: > > > > > > > > thanks for bearing with me. ok i'm making some progress but > still got > > > > new setbacks. > > > > > > > > variableX = variableY / abs(variableZ); > > > > result = IIf (variableX > .5, 1, 0); > > > > > > > > if(result = 1){ > > > > Filter = Open > 40 & Open < 60; > > > > } > > > > > > > > the problem now is that "result" is evaluating to true (1) even > when > > > > "variableX" is in reality less < .5 > > > > > > > > therefore i'm getting all tickers in the 40-60 Open range. I > only want > > > > to get the tickers where "variableX" is more > .5 > > > > > > > > does it make sense? > > > > > > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx, Andrew Senft <senft@> wrote: > > > > > > > > > > Use IIF for arrays > > > > > > > > > > bigitop wrote: > > > > > > > > > > > > > > > > > > thanks!! Ref() worked perfectly. > > > > > > > > > > > > can you please help me with one more thing > > > > > > > > > > > > i have a variable: > > > > > > > > > > > > variableX = variableY / abs(variableZ); > > > > > > > > > > > > i'm trying to use inside an if statement like this: > > > > > > > > > > > > if (variableX > .5) > > > > > > > > > > > > but it gives me the following error: > > > > > > > > > > > > "Condition in IF, WHILE, FOR statements has to be numeric or > > boolean > > > > > > type. You cannot use an array here, please use [] (array > subscript > > > > > > operator) to access array elements" > > > > > > > > > > > > i tried referencing it as variableX[0] but it doesnt work. > how > > do i > > > > > > know what's inside an array so that i can refer to it?? > > > > > > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx > > > > <mailto:amibroker%40yahoogroups.com>, > > > > > > "sidhartha70" <sidhartha70@> wrote: > > > > > > > > > > > > > > Use the Ref() function... > > > > > > > > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx > > > > > > <mailto:amibroker%40yahoogroups.com>, "bigitop" > <doctormuniz@> > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > hi, im learning AFL and need some basic help. > > > > > > > > > > > > > > > > while i'm running a script how can i reference previous > > bars and > > > > > > > > forward bars? > > > > > > > > > > > > > > > > in other words, how do i get OCHLV info from a bar(s) > that are > > > > back in > > > > > > > > time and forward in time from the current array for the > same > > > > symbol? > > > > > > > > > > > > > > > > I guess it would be something like: TimeFrameSet( > currentBar > > > - 1 ) > > > > > > > > > > > > > > > > is this possible with AB? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -------------------------------------------------------------------- > ---- > > > > > > > > > > > > > > > > > > No virus found in this incoming message. > > > > > > Checked by AVG - http://www.avg.com > > > > > > Version: 8.0.176 / Virus Database: 270.11.3/1967 - Release > Date: > > > > 2/23/2009 7:17 AM > > > > > > > > > > > > > > > > > > > > > > > > > > >
__._,_.___
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
__,_._,___
|