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

Re: [amibroker] Re: Best Approach to a Multipass Problem



PureBytes Links

Trading Reference Links

ta

no need for separate scan to put the newly created atc symbols into watchlist 4, just assign them to watchlist 4 as soon as you've made them

1.       First pass mRSI = RSI(14);
AddToComposite( mRSI, "~RSI-"+ Name(), "C", atcFlagDeleteValues | atcFlagEnableInBacktest | atcFlagDefaults );
CategoryAddSymbol("~RSI-"+ Name(), categoryWatchlist, 4);
Buy=0 AND InWatchList(3);

Brenton


ta wrote:
 

Thanks Mike for your input. Couple of points.

1.       First pass

mRSI = RSI(14);
AddToComposite( mRSI, "~RSI-"+ Name(), "C", atcFlagDeleteValues | atcFlagEnableInBacktest | atcFlagDefaults );
Buy=
0 AND InWatchList(3);

 

during the first pass we run a scan on all quotations on watchlist 3. The above code calculates rsi for symbols ibm, msft and intc and writes their rsi value in close field of atc files ~RSI-IBM, ~RSI-MSFT & ~ ~RSI-INTC.

Then we can run the following code (in scan mode) to assign the new atc symbols to watch list 4

 

TickerList      = CategoryGetSymbols( categoryGroup, 253);
for( i=0; (Ticker=StrExtract( TickerList, i)) != ""; i++)
   {
      
if ((StrLeft(Ticker,4)=="~RSI"))
      {
      
CategoryAddSymbol(Ticker, categoryWatchlist, 4);
      }
   }
Buy=
0;

 I then added the symbol ~minmax manually. Then I ran the following code based on your suggestion with the modification that I did not use Deltamax and Deltamin (I am interested only in max & min). The code does not create any values. I used static variables That did not produce results either.

 

currentMax = Foreign( "~minmax", "high" );
StaticVarSet("newMax", Max( C, currentMax ));
_TRACE( "symbol: " + Name() + " newMax: " + StaticVarGet("newMax"));
AddToComposite( StaticVarGet("newMax"), "~minmax", "high");

 

What do you think. The following is the put from the _trace statement.

 

currentMax = Foreign( "~minmax", "high" );
currentMin =
Foreign( "~minmax", "low" );
newMax =
Max( C, currentMax );
newMin =
Min( C, currentMin );
_TRACE( "symbol: " + Name() + " newMax: " + LastValue(newMax) + " newMin: " + LastValue(newMin) );
AddToComposite( newMax, "~minmax", "high");
AddToComposite(NewMin, "~minmax", "low");  

 

symbol: ~RSI-IBM newMax: 0 newMin: 0      Formulas\1Production\AddtoCompsiteTestMark.afl  9      100   14:43:49.21

symbol: ~RSI-INTC newMax: 0 newMin: 0     Formulas\1Production\AddtoCompsiteTestMark.afl  9      100   14:43:49.21

symbol: ~RSI-MSFT newMax: 0 newMin: 0     Formulas\1Production\AddtoCompsiteTestMark.afl  9      100   14:43:49.21

 

my AA settings

 

 

 

 

 

Testmark1.jpg

 

From: amibroker@xxxxxxxxxps.com [mailto:amibroker@yahoogroups.com] On Behalf Of Mark Hike
Sent: Tuesday, October 06, 2009 12:31 PM
To: amibroker@xxxxxxxxxps.com
Subject: Re: [amibroker] Re: Best Approach to a Multipass Problem

 

 

1. First pass
Run scan through all real tickers to generate artificial tickers for RSI (close field).

2. Second pass
Run scan through all RSI artificial tickers. Do the following:
currentMax = Foreign("~minmax", "high");
currentMin = Foreign("~minmax", "low");
newMax = max(C, currentMax);
newMin = min(C, currentMin);
deltaMax = newMax - currentMax;
deltaMin = newMin - currentMin;
AddToComposite(deltaMax, "~minmax", "high");
AddToComposite(deltaMin, "~minmax", "low");

On Tue, Oct 6, 2009 at 1:01 PM, ta <tagroups@xxxxxxxxxxnet> wrote:

 

Mike, thanks for your interest. Lets simplify the problem. Lets assume that we want to calculate the RSI for every bar for all tickers in the database. We can easily calculate rsi numbers and store them in an atc file. Then we want to find out what is the minimum and maximum values for rsi is on any given bar in our database (all tickers). For example if we have three tickers in our database and we have three bars. The calculated rsi for each ticker would be as follows:

 

IBM = 12, 1 , 6

MSFT = 10, 2, 7

INTC = 13, 9, 87

 

On bar 1  min = 10 max = 13

On bar 2 min = 1 max = 9

On bar 2 min = 6 max = 8

 

I don’t know how to program AB to find the min and max values for every bar and store in a new atc file (lets call it ~minmax). I hope this clarifies the problem. TIA

 

 

From: amibroker@xxxxxxxxxps.com [mailto:amibroker@xxxxxxxxxps.com] On Behalf Of Mike
Sent: Monday, October 05, 2009 10:09 PM
To: amibroker@xxxxxxxxxps.com
Subject: [amibroker] Re: Best Approach to a Multipass Problem

 

 

For steps 1 and 3, are you spanning symbols? In other words, do you want the min out of all symbols, or do you want the min on a symbol by symbol basis?

You might get a better response if you describe a concrete example of what you are trying to do, assuming 2-3 symbols over a handful of bars.

e.g.
AAA
Alpha = 1, 3, 5, 7
Beta = 2, 4, 6, 8

BBB
Alpha = ...
Beta = ...

CCC
Alpha = ...
Beta = ...

Now what?

Mike

--- In amibroker@xxxxxxxxxps.com, "ta" <tagroups@xxx> wrote:
>
> Well, after spending about a month on this problem. I can not figure out
> step to namely:
>
> 2. Run thru the atc files and find the min and max values for alpha
> and beta and store is in one new atc file (2nd pass thru database)
>
> Any help or direction would be much appreciated. TIA
>
>
>
> From: amibroker@xxxxxxxxxps.com [mailto:amibroker@xxxxxxxxxps.com] On Behalf
> Of ta
> Sent: Friday, September 11, 2009 4:42 PM
> To: amibroker@xxxxxxxxxps.com
> Subject: [amibroker] Best Approach to a Multipass Problem
>
>
>
>
>
> I am calculating certain characteristics for every stock than I have in my
> EOD database (approximately 3000). For the sake of clarity let's use alpha
> and Beta as characteristics. I want to :
>
> 1. calculate the min and max value of alpha & beta in my data base.
>
> 2. Then normalize the values to values between 0 and 1
>
> 3. Then calculate the sum of normalized alpha and beta and store them
> in atc file to be used in backtests
>
>
>
> I was thinking of using the following procedure:
>
> 1. Calculate alpha and beta and store the values for each stock in an
> atc file (first pass thu database)
>
> 2. Run thru the atc files and find the min and max values for alpha
> and beta and store is in one new atc file (2nd pass thru database)
>
> 3. Normalize alpha & beta for each stock using the stock's atc file
> and minmax atc file that I created during the previous step (3rd pass thru
> database)
>
>
>
>
>
> Is there a better/faster approach? Any help or suggestions is much
> appreciated. TIA
>

 



__________ Information from ESET NOD32 Antivirus, version of virus signature database 4485 (20091006) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com