Issue with position sync and assigning initial position

Questions about MultiCharts and user contributed studies.
ventus
Posts: 45
Joined: 14 May 2010
Location: NYC
Has thanked: 1 time
Been thanked: 6 times

Issue with position sync and assigning initial position

Postby ventus » 10 May 2011

I have a strategy that is currently in a position. I turn off the strategy automation and then turn it back on to assign the initial market position. I input the position details and then MC shows that I'm in the correct position in the order and position tracker window. But then the strategy sends another order to enter the position again, doubling the position.

I think there's an issue with how MC is matching the assigned initial position to the correct Marketposition_at_Broker_for_the_Strategy.

My code is very very simple, since I'm just testing this out...

if Marketposition_at_Broker_for_the_Strategy = 0 then begin
buy ("B1") next bar at highest(high,20) stop;
sellshort ("S1") next bar at lowest(low,20) stop;
end;



I wanted to see what the MC team comes up with before adding this to the project management page. Thanks in advance

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 300 times

Re: Issue with position sync and assigning initial position

Postby Stan Bokov » 17 May 2011

Marketposition_at_Broker_for_the_Strategy checks what the MP is for all orders sent by this strategy. Since when you turn it on there are no orders sent by the strategy, the condition of Marketposition_at_Broker_for_the_Strategy = 0 is met.

You should use the MarketPosition_at_Broker keyword.

ventus
Posts: 45
Joined: 14 May 2010
Location: NYC
Has thanked: 1 time
Been thanked: 6 times

Re: Issue with position sync and assigning initial position

Postby ventus » 17 May 2011

thanks stan. the thing with using marketposition_at_broker is that i have multiple strategies trading the same contract and need the strategy to account for only its position and not positions triggered by the other strategies.

any suggestions on how to go about this? everything works fine until i turn strategy automation off and on and try to sync the positions. luckily, this doesn't happen too often but it is still definitely a very important aspect to handling automated trading.

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 300 times

Re: Issue with position sync and assigning initial position

Postby Stan Bokov » 17 May 2011

Are you using SA or AA mode?

ventus
Posts: 45
Joined: 14 May 2010
Location: NYC
Has thanked: 1 time
Been thanked: 6 times

Re: Issue with position sync and assigning initial position

Postby ventus » 17 May 2011

SA mode


Return to “MultiCharts”