MarketPosition at Broker for The Strategy  [SOLVED]

Questions about MultiCharts and user contributed studies.
waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

MarketPosition at Broker for The Strategy

Postby waldem » 22 Jan 2015

hallo, i cannot understend completely this command.

shouldn't be better "MarketPosition at Broker for The SYMBOL"?

if i have the same strategy running in more instruments one flat and the secon at market, maybe i got 1 as results even if i'm flat on this specific instrument?

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: MarketPosition at Broker for The Strategy

Postby Andrew MultiCharts » 22 Jan 2015

Hello waldem,

It is not for the symbol, becuase it is for a particular chart, where the strategy is calculating. More details can be found here.

DTorSwing
Posts: 62
Joined: 13 Jan 2015
Has thanked: 15 times
Been thanked: 2 times

Re: MarketPosition at Broker for The Strategy

Postby DTorSwing » 22 Jan 2015

Hello waldem,

It is not for the symbol, becuase it is for a particular chart, where the strategy is calculating. More details can be found here.

MarketPosition_at_Broker_for_The_Strategy. Returns MC auto-trading engine position.

This should mean anything for the AA mode and not SA mode though, Andrew
per your answer on the other thread

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: MarketPosition at Broker for The Strategy

Postby Andrew MultiCharts » 23 Jan 2015

1 minute chart "AAPL" + signal code "Code1" = Strategy "Strategy1".
1 hour chart "AAPL" + signal code "Code1" = Strategy "Strategy2".
  • "MarketPosition" keyword in the signal code "Code1" on the 1 minute chart "AAPL" returns visual* market position of 1 minute chart "AAPL".
  • "MarketPosition" keyword in the signal code "Code1" on the 1 hour chart "AAPL" returns visual* market position of 1 hour chart "AAPL".
  • "MarketPosition_at_broker" keyword in the signal code "Code1" on the 1 minute chart "AAPL" returns actual market position of "AAPL" from broker.
  • "MarketPosition_at_broker" keyword in the signal code "Code1" on the 1 hour chart "AAPL" returns actual market position of "AAPL" from broker.
  • "MarketPosition_at_broker_for_the_Strategy" keyword in the signal code "Code1" on the 1 minute chart "AAPL" returns inner market position of the strategy "Strategy1" that is working on 1 minute chart "AAPL".
  • "MarketPosition_at_broker_for_the_Strategy" keyword in the signal code "Code1" on the 1 hour chart "AAPL" returns inner market position of the strategy "Strategy2" that is working on 1 hour chart "AAPL".
*visual = market position formed by displayed executed orders on the chart, NOT the horizontal drawing showing market position from broker.

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: MarketPosition at Broker for The Strategy

Postby waldem » 27 Jan 2015

hallo all, i am very sorry, but i still cannot understand.

someone could make me a bit training session pls, i'm very sad! :(

first of all, as you can see in image attached, i'm long since yesterday with 868 stocks but i cannot retrieve this to the brocker.

MarketPosition_at_broker_for_the_Strategy command say ZERO.

Team, should be dialogue problem with my broker?
simple marketposition is correctly 1 and the other 2 are null.
there is also one sell for half of position that in reality does not occour because i was not first on the tick. (but this is another problem).

second: i have tryed to use the function "Show the assign the initial position at the broker dialogue" "Show always", but if i put correctly 868 at 11.53 MC understand that Today at open i was long at 11.53, and does not fill the exit strategy.

i feel myself stupid, some kind guy should guide me maybe with code exhample?
i have no problem to send my code, in private.
Attachments
MarketPosition_at_broker_for_the_Strategy.png
(221.63 KiB) Downloaded 1035 times

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: MarketPosition at Broker for The Strategy

Postby waldem » 27 Jan 2015

i've seen that if i turn on the strategy it works something.
MarketPosition at Broker is correctly 868 instead MarketPosition at Broker for The Strategy is still zero.
Attachments
image 3.png
(220.85 KiB) Downloaded 1054 times

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: MarketPosition at Broker for The Strategy

Postby Andrew MultiCharts » 27 Jan 2015

first of all, as you can see in image attached, i'm long since yesterday with 868 stocks but i cannot retrieve this to the brocker.

MarketPosition_at_broker_for_the_Strategy command say ZERO.

Team, should be dialogue problem with my broker?
simple marketposition is correctly 1 and the other 2 are null.
there is also one sell for half of position that in reality does not occour because i was not first on the tick. (but this is another problem).
It looks like your code is not auto-trading, that is why the MarketPosition_at_broker_for_the_Strategy returns "0".
second: i have tryed to use the function "Show the assign the initial position at the broker dialogue" "Show always", but if i put correctly 868 at 11.53 MC understand that Today at open i was long at 11.53, and does not fill the exit strategy.
If exit orders are not sent to broker after you start auto-trading and assign initial market position for the strategy, something in the code of the strategy must be wrong. Please analyze order generation and values invlolved in it. Here is an example how to do this.

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: MarketPosition at Broker for The Strategy

Postby waldem » 28 Jan 2015

Hi Andrew, thanks.

yes is an auto trading strategy, you can see from the picture that i'm using in RT, the problem is that is working with new order, but as before i cannot sincronyze after nigth stop.

i've tried to apply you portion of code to print the order status, but i cannot understand why:
1 the order in chart change (that's crazy, because you code including only print!!!!)
2 my PowerLanguage Editor crash.

since this question i think are recurring from user, souldn't be possible for the Team to create one video to explain to all how to sincronyze the strategy with brocker?
or second suggestion: souldn't be possible to create a button "sincronyze" easy for all?
Attachments
Immagine1.png
(1.17 MiB) Downloaded 1047 times

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: MarketPosition at Broker for The Strategy

Postby Andrew MultiCharts » 28 Jan 2015

1 the order in chart change (that's crazy, because you code including only print!!!!)
Adding prints to your code should not change the logic of the signal, unless you accidentaly changed that manually when added the prints.
2 my PowerLanguage Editor crash.
If the issue still persists, please come to our live chat during working hours (6:30 am – 2:45 pm EST) to let our operators connect to your computer remotely and help you.
since this question i think are recurring from user, souldn't be possible for the Team to create one video to explain to all how to sincronyze the strategy with brocker?
or second suggestion: souldn't be possible to create a button "sincronyze" easy for all?
Here is the step-by-step instruction of how to sync your strategy position with broker position:
  1. When MC is up and you chart with the strategy is plotted, please make a right-click on the chart --> Format Signals… --> Properties… --> Auto Trading (tab) --> select "Entries/Exits are based on the execution confirmation by the broker (Sync)" in "Mode Selection" --> select "Do not Show the Assign the Initial Market Position at the Broker Dialogue: Use the actual position at the broker" --> OK.
  2. DO NOT start auto-trading yet. Make sure that there are no pending orders at broker at this market. All orders must be cancelled.
  3. Start auto-trading.
  4. DO NOT place any manual order in or outside of MultiCharts at the same market.
  5. DO NOT auto-trade at the same market from any other chart.
Result: strategy, chart and broker prositions should be in sync.

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: MarketPosition at Broker for The Strategy

Postby waldem » 29 Jan 2015

thank you, is very clear.

now, if i would like to put one target for half of position, the command "currentshares" is able to read the position at blroker?

if not should be corret something like:

Code: Select all

if marketposition_at_broker <> 0 then begin
Sell ("LTprof") marketposition_at_broker/2 shares next bar at TargetL limit;

if currentshares < MyTrdQty then begin
tgt=1;
end;
end;

if marketposition_at_broker = 0 then begin
Sell ("LTprof") currentshares/2 shares next bar at TargetL limit;

if currentshares < MyTrdQty then begin
tgt=1;
end;
end;

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: MarketPosition at Broker for The Strategy

Postby Andrew MultiCharts » 29 Jan 2015

now, if i would like to put one target for half of position, the command "currentshares" is able to read the position at blroker?
If we are talking about auto-trading in a broker account the best option is to use the "MarketPosition_at_broker" and "Total" keywords:

Code: Select all

Sell ("LTprof") marketposition_at_broker/2 shares total next bar at TargetL limit;

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: MarketPosition at Broker for The Strategy

Postby waldem » 04 Feb 2015

Hallo Andrew, i have thought a lot on your words and finally is quite clear how to synchronize, but i still have one doubt:
all my target or stop level are based on entryprice, but the entryprice function is impossible to retrieve from broker.

for eg. my Target is:
TargetLL = JK_Math_RoundToNearest (entryprice * TgtL,tick);

i did this very simple code, but entryprice is zero:

Code: Select all

Inputs:Capital(10000);
vars:
Current_Capital(0),
tgt(0);


if MarketPosition_at_Broker > 0 then begin
Current_Capital= IntPortion(Close * MarketPosition_at_Broker );
value1=entryprice;
end;


if Current_Capital < Capital then tgt = 1 else tgt = 0;


//-------------------------------------------------------------
//-------------------------------------------------------------
{EXPERT COMMENTARY}
If AtCommentaryBar then begin
Vars:Str("");{Dichiaro una variabile stringa e la inizializzo come vuota}

Str=Str+" Current_Capital: "+NumToStr(Current_Capital,2)+NewLine;
Str=Str+" tgt : "+NumToStr(tgt ,2)+NewLine;
Str=Str+" value1 : "+NumToStr(value1 ,2)+NewLine;
Commentary(str);
end;
could you tell me if is possible to retrieve from chart or from brocker this value?

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: MarketPosition at Broker for The Strategy

Postby waldem » 04 Feb 2015

also if i put in AA mode the entryprice is ZERO, that make no sense for me.
how could i get this value from broker?

i read in this answer that entryprice should work therefore maybe i will contact you in chat to see my problem.

viewtopic.php?f=1&t=15952

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: MarketPosition at Broker for The Strategy  [SOLVED]

Postby Andrew MultiCharts » 06 Feb 2015

As per our email correspondence:

The issue you are having is due to the fact you combine SA mode + Assign Market Position At Broker feature + Synchronizer strategy. If you get rid of the Synchronizer strategy and will use the Assign Market Position At Broker feature correctly, there will be no problems.


Return to “MultiCharts”