Running TS Script on 2 Seprate Charts Simultaneously

IBPlugin is further development of TWSLink.It is focused for the useage with MetaTrader. But as it is a DLL, you can use it everywhere on Windows which supports DLL, e.g. in Trade Station or C++ applications or make wrapper for Perl, Python etc.

Users who just registered, please write an email to
forum@trade-commander.de
with your username mentioned.
So we can distinguish you from bots.
Thank you
Post Reply
user108
Posts: 5
Joined: Wed Jan 05, 2022 8:25 pm

Running TS Script on 2 Seprate Charts Simultaneously

Post by user108 »

Hello all,

Can someone had some experience using the TS_SIGNAL script Admin has provided on this board SIMULTANEOUSLY on 2 Charts?

Is there a mod needed on the second script, especially for the section when opening a connection to the TWS? (section below Initialized = 0 etc).

I have tried it on 1 chart and it works well... when I try it on a second chart simultaneously... the ret_int on the SECOND one is ALWAYS 0, whilst for the first one is ALWAYS 3... 3 is good.

Anyone please help in advising how to get 2 scripts going that send their respectove orders to TWS? I have a feeling it is about the connection, but not too familiar here

Thanx

board_admin
Site Admin
Posts: 244
Joined: Mon Apr 24, 2017 3:24 pm

Re: Running TS Script on 2 Seprate Charts Simultaneously

Post by board_admin »

You should be able to attach your scripts to multiple charts.
In each script call connect with same parameters -> IP and port.

connect does nothing when you already connected (e.g. because another signal already did)

user108
Posts: 5
Joined: Wed Jan 05, 2022 8:25 pm

Re: Running TS Script on 2 Seprate Charts Simultaneously

Post by user108 »

After several days of testing - simply applying the SAME TS_SIGNAL script (with a simple if then else statement to generate an order), when applied to MORE Than one chart on the same workspace, or another workspace, it DOES NOT WORK on the second application.

What the Admin has written is a basic initialization block that blindly executes the order when it initializes (and only does that once).

In real life this is not how it happens...

Any attempt to add real life test code out side the Initialize code does not work...

@Admin - can you please post a separate example that simply incorporates the following condition so we can put it on two charts and check. This would give us a great guidance in real world implementation of different order logics

The order logic here is simply for testing

If C <> C[1] then ...
Begin
uid_order=ibgORDER_SEND_STR(connection_id,conid,0, order_attribute_str,0);
if uid_order > 0 then ret_int=ibgWAIT_FILLED(uid_order,5000);
end;

Thanx

board_admin
Site Admin
Posts: 244
Joined: Mon Apr 24, 2017 3:24 pm

Re: Running TS Script on 2 Seprate Charts Simultaneously

Post by board_admin »

Are you sure your EL condition was fullfilled?
There is no information about the order_attribute_str.

The funciton works, if it is called at all and your parameters are correct, your permissions fine, no margin problems etc.
There is no reason why the function should not work, just because called in a 2nd script.
All plugin functions are thread safe.


Perhaps check the orders logfile.
You can find it below your configuration:

C:\trade-commander.com\ibplugin\configurations\<your_config>\log\api\connection_1\channel_order.log

Examples:
C:\trade-commander.com\ibplugin\configurations\TSTN_MUCT\log\api\connection_1\channel_order.log
C:\trade-commander.com\ibplugin\configurations\default\log\api\connection_1\channel_order.log

Post Reply