Import executed orders

I'm trying to import my orders and overlay it onto a chart for reviewing my trades.

It does not seem like the Import Wizard/ASCII suits what I'm trying to do.

I think I want to read in a csv file, via fopen, loop through the orders line by line and store that somewhere.
The file looks like this:

"IBAU200","IBAU200","BUY","1","10","08/08/2022 13:31:20","7025.3","-7.0253","AUD"
"IBAU200","IBAU200","BUY","1","5","11/08/2022 10:50:46","7035.25","-3.517625","AUD"
"IBAU200","IBAU200","BUY","1","5","11/08/2022 11:33:51","7045.25","-3.522625","AUD"
"IBAU200","IBAU200","BUY","1","5","11/08/2022 11:45:49","7050.38","-3.52519","AUD"
"IBAU200","IBAU200","BUY","1","5","11/08/2022 12:45:40","7041.38","-3.52069","AUD"

Then somehow, and this is where I'm stuck, plot the orders at the right time on the chart.

Everything I've seen in Amibroker so far is about plotting at a specific array index, but I want to loop through my executed orders and plot these at arbitrary indexes based on the time of execution.

I'm trying to understand how to do this in Amibroker. Any help appreciated!

Please consult Knowledge Base

2 Likes

Thanks for the link, this is exactly what I wanted. However, I'm still trying to understand how this works.

Specifically, trade_datetime is a scalar value. dt is an array where each element is set to the interval that I've defined ( eg per minute ).
So when you do newbuy = dt == trade_datetime, then newbuy produces an array where at most 1 element in that array is true and the rest is false. Is my understanding correct?

Does this mean, for each line of the csv file, the function will run through the whole Buy array and update an element if newbuy is True for that datetime? Then it will run through again for the next line and so forth until all lines are read?

             // extract data from line of text
             trade = StrExtract( line, 1 );
             trade_datetime = StrToDateTime( StrExtract( line, 2 ) );
             price = StrToNum( StrExtract( line, 3 ) );
             shares = StrToNum( StrExtract( line, 4 ) );
             //
             if ( trade == "Buy" )
             {
                 newbuy = dt == trade_datetime;
                 Buy = Buy OR newbuy; // combine previous buy signals with new
                 BuyPrice = IIf( newbuy, price, BuyPrice );
                 possize = IIf( newbuy, shares, possize );
             }

Yes scalar to array comparisons produce array. Your understanding is correct.

1 Like

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