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

[amibroker] making progress... need suggestions



PureBytes Links

Trading Reference Links

I'm slowly but surely getting it but i still need some suggestions please.

This code is meant to be run in exploration mode for ALL stocks and within a date range. It calculates the percentage of bars that meet certain criteria - in this case it's the open price - for the specified date range and outputs it to the AA window.

this is an example of the arrays

----------------------------------------------------------------------------------------
m = open > 18 < 18.5         1  0  1  1  1  0  1  1  0  1  0  0  0  1  1  0  1  1  0  0
raw total = cum(m)           1  1  2  3  4  4  5  6  6  7  7  7  7  8  9  9  10 11 11 11
bar in date range            0  0  0  0  1  1  1  1  1  1  1  1  1  0  0  0  0  0  0  0
lastvalue (cum(barinrange))  9  9  9  9  9  9  9  9  9  9  9  9  9  9  9  9  9  9  9  9
true positives               0  0  0  0  1  0  1  1  0  1  0  0  0  0  0  0  0  0  0  0
-----------------------------------------------------------------------------------------

as you can see the true positives are the number of times the "m" criteria was met WITHIN the date range.  in this case 4/9 = 44%.

the code does what is supposed to do for the INDIVIDUAL tickers in the database. but since AB loops the code from scratch for each ticker in the database, it does not output the TOTALS for ALL stocks, which is what i'm intersted in.

so what I need to do now is to sum the individual results to calculate the overall percentage.

I've tried temporarily outputting the result for each stock to the clipboard with ClipboardSet() and ClipboardGet() but it doesn't work.  here's the code.  any suggestions are appreciated!


m = Open > 18 && Open < 18.5;

rawtotal = LastValue(Cum(m));
barinrange = Status("barinrange");
totalinrange = LastValue(Cum(barinrange));
truepositives = 0;

for ( i = 0;  i < BarCount; i++ ){

    if ( barinrange[i] == 1 ){
        truepositives[i] = m[i];
    }
}

truepositives = LastValue(Cum(truepositives));
PPV = (truepositives/totalinrange) * 100;

// NEED HELP FOR THIS PART ///////////////////
// HOW CAN I TEMPORARILY KEEP THE RESULTS IN MEMORY
// SO THAT I CAN ADD THEM TO THE RESULTS OF THE NEXT TICKER?

temp = StrToNum( ClipboardGet()) + truepositives;
ClipboardSet(NumToStr(truepositives));

//////////////////////////////////////////////

Filter = m == 1;

AddColumn(Open, "open");
AddColumn(rawtotal, "Raw Total");
AddColumn(totalinrange, "Total Bars in Range");
AddColumn(truepositives, "True Positives for Ticker");
AddColumn(PPV, "PPV", 1.1);
AddColumn(temp, "Total True Positives");





__._,_.___


**** 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/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___