I wrote a test C# console app to test the IPC "Pipe" and messaging. So far so good, however I could not get the "plot trend line" to work. Strangely, after trying to, afterwards, if I right clicked on the chart, "Delete All Studies" was available, as if it had been plotted by the pipe message, but I couldn't see it on the chart. Additionally, if I drew a trend line myself manually, I was then able to delete it remotely via pipe message, so that worked as intended.
As far as other functions, I confirmed being able to change between multiple AB instances locally, getting and setting symbols to chart, and even remote to an AB running on a networked machine.
I would share it, but can't upload the solution zip here.
Very interesting! But to be honest, I am quite lost when it comes to this new feature.
I use Tick Databases and my Trading Chart will have the "OLE Focus". So when I open my 2nd instance of Amibroker, also a tick database, to look at the recent historical data that my 5 Million ticks Trading Chart doesn't cover, I can't use OLE to import my historical Tick Data.
So if I understand this correctly with Pipe, using it I should be able to choose a Start Date and and End Date and import my Historical Data in my 2nd instance of AB using:
you don't need to set up a pipe server, that is done by AB when it starts for each of its instance.
which language/script do you use externally?
There are 2 ways to interact with the pipe,
one is quick write-directional way to send a request. This leverages the file-open-write because Windows Named Pipes behave like in-memory files just like the filesystem.
second is more complex where you have bi-directional comm with the instance. when you need return values like get_symbol_list
I purposely choose 2 dates of recent swing lows, months months apart (I was looking at), I even tried different symbols, layers and databases. I even instituted a timer, so I could make AB and the chart the active window and not the console window. Also tried refresh in AB, different color lines etc. I sent the project zipped up to share with you, but the email bounced back.
Yeah, I toggled all layers on and off, the default and intra-day layers being enabled to start with. Nothing, I even tried your "Price (all in one)" basic chart formula, in case it was my charting formula script code. Let me look to see if I can use AFL to get the coordinates of whatever was added, because AB thinks something is there, due to "Delete all studies" being available.
That sound good- no need to setup any pipe server! I guess in my case I could use the quick method since I am only importing files with tick data.
Now I use: AB = CreateObject( "Broker.Application" ); and AB.import( 0, file, "TickData.format" ); But can, as we know, only be used on the DB in focus.
So do I just have to replace those 2 lines, with the 3 example lines?:
First and foremost there is absolutely ZERO difference in speed when you import via OLE vs pipe.
It makes absolutely no sense to change your existing workflow if you are just importing data.
Examples are there already. From C# you just call CallNamedPipe like in CPP example:
Again I am somewhat surprised that people want to use these named pipes directly.
The purpose of adding Named Pipes to the mix is mainly easy interfacing with Python and with MCP server, as Python is bad with OLE.
I need to import tick data to my 2nd intsnace of the AB. The OLE is in my AFL code and it works great for many years. So I have to use another coding language for the Pipes import solution?
In general, using the Windows environment, writing to Named Pipes is analogous to File write ops. (The QUICK way)
Using OLE from AFL is rather discouraged, but AB internals have guard rails that allows this to work.(just a side note, ole is meant to be used externally)
While this bit is untested by me specifically for your import case(yet to upgrade AB), in theory it should work as I use it to write to my pipes:
cmd1 = "{\"action\": \"data_import\",\"filename\": \"C:\\\\Data\\\\quotes.txt\",\"import_def\": \"C:\\\\path\\\\MyImport.format\"}";
if ( pipebool ) { // some guard to prevent multi execs
fh = fopen( "\\\\.\\pipe\\AmiBroker_<PID>", "w" );
if( fh ) {
fputs( cmd1, fh );
fclose( fh );
}
pipebool = 0;
}
make sure to get you back-slashes right, for import def file, i have used full path too, so set all accordingly.
Set AB PID for 2nd instance as well. You can get it from windows task manager.
Yes, I rememeber that OLE should be used externally, but it has worked fine for me to use it within AB for years.
I am good at AFL coding, but that's about it. So this with pipes is very confusing to me, so thank you very much for the code example! So I checked the task manager and I found a PID number there. But this change every time I start the AB, so is it anyway to get it automatically or I have to manually put it in every time?
how often do you restart?
I use sleep/hibernate so AB instances are always open, and because I use my WebSocket plugin so it I restart PC only when windows updates force me to.
AB is very efficient coupled with my settings, so it idles well and it auto-frees up RAM too because scans are not running.
Regarding PID, it becomes hard to find another static unique identifier. Db_Name is not reliable.