https://trade-commander.com/wp-content/ ... nSetup.exe
This version is a major update and has in parts a changed interface. So using it, means update some code (not much).
It has a complete help and also some Video Tutorials with examples for TradeStation / MultiCharts and MetaTrader.
The new version is inspired by MetaTrader regarding getting order and position information.
You can now do a NON FLAT position snapshot and cycle over positions with a zero based index
to get information about position: contract/symbol/size/avg. price/etc.
MetaTrader 4/5 code example:
Code: Select all
// --------------------------------------------
// [#2] List all non zero positions:
Print("+++ positions START");
// create a snapshot of current non zero positions (resolution down to (sub-) account)
int total_objects=ibgCREATE_POSITION_SNAPSHOT(__connection_id);
Print("#positions=",total_objects );
// list all positions by index
for(int idx=0;idx < total_objects;++idx)
{
// print out a string fingerprint of positions (12 is id of position fingerprint;4 id of signed position;5 id of avg. entry price)
string fingerprint=ibgPOSITION_INFO_STR(idx,tcpi_str_dmp);
Print(fingerprint);
// to get double values returned use function <ibgPOSITION_INFO_DBL>
}
Print("--- positions END");
(each pending order gets also deleted, to demonstrate this function)
Code: Select all
// -----------------------------------------------
// [#3] List all pending orders placed by this client
// (The <clientid> passed to ibplugin.dll function selects the
// orders that can be seen and mastered by an API client.
// Each ibplugin.dll instance is an API client.
// Normally, you do not set the clientid or just pass -1 as the
// IB trader does it: This will create a clientid based on hash value
// of your configuration. This way, you be sure to control all orders
// that have been created by this configuration.
total_objects=ibgCREATE_PENDING_ORDER_SNAPSHOT (__connection_id, 0,1);
Print("+++ pending orders START. #=",total_objects);
long uid_order=0;
// list all positions by index
for(int idx = 0;idx < total_objects;++idx)
{
// print out a string fingerprint of order (1020 is id of order fingerprint)
// (the order attribute identifiers are usually listed in help file:
// C:/Program Files/trade-commander.com/IBPlugin/documentation/tbl_order_attributes.html )
string fingerprint=ibgORDER_INFO_STR(idx,1020);
Print(fingerprint);
// to get double values returned, use function <ibgPOSITION_INFO_DBL>
// to get int64 values (order uids) returned, use function <ibgPOSITION_INFO_INT64>
// to get int values returned, use function <ibgPOSITION_INFO_INT>
// -----------------------------
// cancel current order[idx]
// get its uid
uid_order=ibgORDER_INFO_INT64(idx,1011);
if(uid_order > 0)
{
// [#3.1]
int ret_int=ibgORDER_DELETE(__connection_id,uid_order);
}
}
Print("--- pending orders END");
- // Installation
https://youtu.be/me3K0iFTpq8
- // Symbol mapping
https://youtu.be/anCcZpmr_kQ
- // MetaTrader example
https://youtu.be/s7wuJjPVyig
- // TradeStation / MultiCharts example
https://youtu.be/lH3GE_pDm48