"i_MarketPosition_at_Broker" and "Chart Trading"

Questions about MultiCharts and user contributed studies.
NW27
Posts: 177
Joined: 25 Dec 2010
Has thanked: 40 times
Been thanked: 85 times

"i_MarketPosition_at_Broker" and "Chart Trading"

Postby NW27 » 05 Sep 2011

Hi,

How do I make i_MarketPosition_at_Broker work when I'm using "Chart Trading"?

What I would like to do is create some additional information about my trades that does not appear to be available else where in MC7.
As an example, I would like to create a CSV file for each trade with the following detail -
Entry Date
Entry Time
Long/Short (1 or -1)
Entry Price
Exit Price
MFE
MAE
Initial Stop
Reason for exit ie Initial Stop,Break Even or Trailing Stop.
Actual Profit/Loss for this trade.

Some of these details are available on the Order and Positioning tracking Tab but unfortunately, not all.
One of the failings with the Order and Positioning tracking Tab, is that it does not group the orders together into the actual trade. TWS Does this but doesn't tell me the other above info but at least it gives me a Trade Profit/Loss including commissions.

Neil.

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

Re: "i_MarketPosition_at_Broker" and "Chart Trading"

Postby Henry MultiСharts » 09 Sep 2011

Hello Neil.
i_MarketPosition_at_Broker will work only if the auto trading is enabled.
Using this word in your script will return the same market position that you can see on the Manual trading panel.

There are two possibilities to achieve your goal that I can recommend.
You can apply the signal !From Broker To Strategy MP Synchronizer!, turn on the auto-trading.
Then you are trading manually from the Manual trading panel.
The orders on the chart would be dubbed, as they will be synchronized with the broker (but at the broker there will be only the orders placed manually).
You can see the detailed information about your trading in the Strategy performance report (View->Strategy performance report). You can export this information to a file or print.

The other way to achieve your goal is to write a script that will use "Print(File("C:\test.txt"),xxx,xxx);" in the code and output the information to a file.

NW27
Posts: 177
Joined: 25 Dec 2010
Has thanked: 40 times
Been thanked: 85 times

Re: "i_MarketPosition_at_Broker" and "Chart Trading"

Postby NW27 » 10 Sep 2011

Hi Henry,
I'm not sure what you mean?
What exactly are the two methods?

I have put this code together and it works to a degree -
I have the following signal "NWT Trade Log" applied to the chart. Without a signal applied to the chart, I'm unable to turn ON Auto Trading. Is this correct?

Code: Select all

inputs: LECondition( C > 100000 ) ;
if LECondition then
buy Next Bar 100000 Stop ;
I have the following indicator "NWT Trade Log" also applied to the chart.

Code: Select all

variables : intrabarpersist MP(0),
intrabarpersist EntryP(0),
intrabarpersist ExitP(0),
intrabarpersist MAE(0),
intrabarpersist MFE(0);

MP = i_MarketPosition_at_Broker ;

If MP[1]=0 AND MP <> 0 then begin
EntryP=close;
MFE = EntryP;
MAE = EntryP;
End;

If MP = 1 then
begin
If High > MFE then
MFE = High ;
If Low < MAE then
MAE = Low ;
End;

If MP = -1 then
begin
If High > MAE then
MAE = High ;
If Low < MFE then
MFE = Low ;
End;

If (MP[1] <> 0) AND MP=0 then
Print(Date:10:0,Time:10:0,"Trade Entry=",EntryP:5:0, "MAE=",MAE:5:0, "MFE=", MFE:5:0,"Exit =", Close);
The trouble is, the Trade Entry does not equal the ACTUAL trade Entry Price and I'm enable to use the actual "EntryPrice" variable in an indicator. Ditto for the trade exit.


Without an Actual MC signal creating the trade, The "Strategy performance report" is blank.

So for "Chart Trading" (manual trades) how do I create reports showing the above required information as per my first post?

Neil.

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

Re: "i_MarketPosition_at_Broker" and "Chart Trading"

Postby Henry MultiСharts » 13 Sep 2011

Hello Neil.
You need to have a signal applied to the chart to be able to turn on the Auto Trading. That is correct.
You can use the script of your indicator in the signal. In this case you won't have to apply two studies to the chart.
If you want to have the Entry Price in the script you can use one of these code words:
entryprice
avgentryprice
i_avgentryprice (available only for the indicator).
Their functionality and usage is described in the Multicharts help file.
Please come to our live chat Monday-Friday 6:30 am - 2 pm EST so that I will be able to demonstrate you the methods I have described in the Post#2.


Return to “MultiCharts”