Custom Data and using Split String (StrExtract)

Hi,
I have created a Custom data using Phyton for my requirements so that i can backtest using some more parameters apart from the regular (OHLCV, OI etc). Basically my data has 11 Columns like below:
21-JUN-2021,16235.0,16749.85,16235.0,16573.65,11063,5780,4091,51,35,27

But On Bar by bar basis there are ONLY 9 fields in Amibroker as below:
Date/Time, Open, High, Low, Close, Volume, OpenInt, Aux1 and Aux2

So i changed my custom data feed into 9 columns by clubbing the last three fields with | seperator. So the new data feed look like below:
21-JUN-2021,16235.0,16749.85,16235.0,16573.65,11063,5780,4091,51|35|27

My idea was to put the last variable into Aux2 and then split the string with StrExtract

But in the AFL code when i use the below code to split it says "the 1st argument is expected to be string, but found and array" :frowning:

StrExtract( Aux2, 0, '|' );

Is there any other way to split the Aux2 Variable?

Regards,
Ravi

1 Like

Hello,

Can you please confirm that you could import the AUX2 field data with the Pipe Character.
As I think that (Apart from the Symbol and Date) the data is supposed to have Numeric Values.
You may check it by: Menu > Symbol > Quote Editor.

With Regards

Sanjiv Bansal

PS: In General - the StrExtract() function is supposed to work on Strings - and AUX2 holds Numbers - So you first have to convert the Numbers to Strings.

@YRK, in general, when you have to deal with extra numeric fields, the recommended approach is to use some artificial tickers.
To learn more about how other people use them, please, search the forum for "artificial tickers".

2 Likes

@Sumangalam Yes i was able to Import without any failures.

@beppe Yes Artificial tickers seems to be one option. But the point i have is the Artificial tickers is a ticker anyways (Like ~MyStuffAAPL). Will it not impact the backtest result? Also this means each ticker that we have must have another artificial ticker which looks a little bad :slight_smile:
If only the split would have worked the AUX would be very valuable variable in Ami :slight_smile: .

For Future: One additional Variable needs to be there that is a barwise String which we spilt and do all the extra processing. Maybe Amibroker owner's can give it a thought @Tomasz

@YRK: You may think you imported a string with pipe delimited data, but I'm pretty sure that's not the case as AUX1 and AUX2 contain numeric data, not string data. If you look in the quote editor as suggested by @Sumangalam , I think you will find that the only thing imported was the set of digits before the first pipe.

If the values you need to store are relatively small, you could always encode them similarly to the way an AmiBroker DateNum is encoded, for example:

aux=val1*10000 + val2*100 + val3*100

Just keep in mind that AB floating point numbers only have 7 significant digits, so if the aux value is too large you'll start to lose precision. The suggestion from @beppe is a good one, and is the way that people usually store excess data in the database.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.