Looking for python API similar code in amibroker


I am looking for the similar code of python in amibroker. The below code is in python.

records= historical_data(instrument_token, from_date, to_date, interval)

records= historical_data("AAPL", today's Date, today's Date, "5 minute")

The above code usually gives the historical 5 minutes data of a stock on a particular day.

In the same way in amibroker i need just close prices of a particular stock and store it in a array.
How to achieve this in AFL.

AmIBroker is not Python. Python is just a language. It relies on external libraries to do anything useful. AmiBroker on the other hand is complete technical analysis system with integrated database so all data are already there in the database and current symbol data are already in OHLC arrays while other symbols data can be accessed via Foreign http://www.amibroker.com/?foreign and you get access to ALL data already padded and aligned to current symbol.

@Kum001 if you plan to work with AmiBroker you should start to think in the AmiBroker way!

In my past working experience, I have seen that many coders, when learning a new language, tend to approach many problems like they did in their previous programming environments.
This happened to me too with AmiBroker and I still struggle to get rid of my old coding habits that will often produce verbose and sub-optimal solutions compared to the ones developed by longtime users.

In any case, the best way to get useful help here in the forum is to clearly explain your goal: for instance, in your message, you state that you want to store the data in an array.

As @Tomasz said, using AmiBroker, this data is already entirely available to you: just use the Close price array.

Do you truly need to operate exclusively on the data of a specific date?

AmiBroker offers multiple ways to identify the bars of a certain day/time interval, so you will be certainly able to replicate your Python code result, but the approach may be a different one.

1 Like

In addition to @beppe's helpful comments, you may wish to explore the TimeFrame* functions like TimeFrameSet() and TimeFrameCompress(). These will be helpful if your base time interval is something shorter than 5 minutes but you want to operate on 5 minute data.

1 Like

He has been using them already but not correctly.

1 Like