Position Controler, Global Variables

Questions about MultiCharts and user contributed studies.
jondo
Posts: 9
Joined: 17 Jul 2015
Has thanked: 1 time
Been thanked: 2 times

Position Controler, Global Variables

Postby jondo » 17 Jul 2015

Hello,

I would like to create an indicator which is going to control number of contracts compering strategy and broker position.

I was considering an option of using functions "MarketPosition_at_Broker" or "MarketPosition_at_Broker_for_The_Strategy" which should provide information regarding number of contracts for specific symbol. Then I would sum through strategies in multiple charts, number of open contracts and if mismatch occur, alert me. No further specific action is required, only alert.

Do you have a personal experience using those market position functions, do they work reliable using Interactive Brokers?

By tha way, what is the difference between "MarketPosition" and "MarketPosition_checked". I have tested these function in real-time. In enclosed file where you can see values in from one day trading, you find those functions returning same values. What is strange is that "MP_at_broker" and "MP_at_broker_for_strategy" doesn't return same values trading one contract in only one strategy! In this example, only "this bar on close" orders are used, lines are written only when any MP change occurs.


Thank you very much,
John
Attachments
basicprint.txt
(729 Bytes) Downloaded 576 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Position Controler, Global Variables

Postby Henry MultiСharts » 21 Jul 2015

Hello John,

MarketPosition_at_Broker - number of contracts and the type of position at the broker for the symbol.
MarketPosition_at_Broker_for_the_Strategy - number of contracts and the type of position at the broker for the strategy (MC auto-trading engine position).
MarketPosition - current strategy position on a given chart.
CurrentContracts - number of contracts or shares held in the current strategy position on a given chart.

If you are trading the same instrument from different strategies/manually then mismatch of "MP_at_broker" and "MP_at_broker_for_strategy" can be expected.

As for the difference between "MarketPosition" and "MarketPosition_checked" - you need to pay attenation to the Notes in the reserved word description:
If PosBack value is greater that the real number of previously opened positions, MarketPosition_Checked will generate an error.

jondo
Posts: 9
Joined: 17 Jul 2015
Has thanked: 1 time
Been thanked: 2 times

Re: Position Controler, Global Variables

Postby jondo » 21 Jul 2015

Regarding Global variables, installation is just putting "ELCollections.dll" file into: "C:\Program Files\TS Support\MultiCharts64" destination and using it in following manner:

Signal sender (one window):
GVSetNamedDouble("CC", CC);
GVSetNamedDouble("MP2 ", MP2 );


Signal or any indicator receiver, function:
GVGetNamedDouble("CC ", CC );
GVGetNamedDouble("MP2 ", MP2 );

Plot1(CC,"CC");
Plot2(MP2,"MP2");


This procedure doesn't work, I must be missing something. Printing variables in sender contains values for sure, but probably nothing is received by GVGetNamedDouble. Am I missing something in installation process, more files are needed?

Thank you,

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Position Controler, Global Variables

Postby Henry MultiСharts » 21 Jul 2015

GlobalVariables.dll already comes with MultiCharts. In order to get all of the GV functions - please import the Global Variable22.zip attached to this post: viewtopic.php?t=2483#p8174
You need to save the file, unzip it, import GV 2-2.ELD per instructions:
https://www.multicharts.com/trading-sof ... ng_Studies


Return to “MultiCharts”