marketposition question

Questions about MultiCharts and user contributed studies.
Thomas Mann
Posts: 173
Joined: 25 Aug 2007

marketposition question

Postby Thomas Mann » 04 Dec 2008

Hi,
Could someone please show me a easy way to use marketposition to initially get into a trade on either side, then use the marketposition to cover the last trade and flip on the opposite signal. I have tried everything I could find in the forums and think of yet my script always leaves me flat.. This was my last attempt.
Thanks
if Trigger crosses under wave then
begin
if MarketPosition = 0 then
begin
Buy ( "Buy" ) next bar at market ;
end;

if MarketPosition = -1 then
begin
buytocover("CoverS") next bar at market ;
Buy("ReverseL") next bar at market ;
end;

Alert("Buy Alert Up Direction ");
end;



if Trigger crosses over wave then
begin
if marketposition = 0 then
begin
Sell("Short") next bar at market ;
end;

if MarketPosition = 1 then
begin
sell("CoverL") next bar at market ;
Sell("ReverseS") next bar at market ;

end;

Alert("Sell Alert Dn Direction ");
end;

SUPER
Posts: 622
Joined: 03 Mar 2007
Has thanked: 99 times
Been thanked: 80 times

Postby SUPER » 04 Dec 2008

if MarketPosition = -1 then
begin
Buy("ReverseL") next bar at market ;
end;

if MarketPosition = 1 then
begin
Sell("ReverseS") next bar at market ;
end;


Try above code and see it makes any difference.

Regards
super

Thomas Mann
Posts: 173
Joined: 25 Aug 2007

Postby Thomas Mann » 04 Dec 2008

Thanks Super

That part works, but what I am tryin to achieve is to cover a position if I am not flat then reverse so effectively if I was Long I would sell 2 contracts which would make reverse with 1 contract Short. If I was short I would buy 2 contracts. I tried using the contracts word and a few others with no success.

SUPER
Posts: 622
Joined: 03 Mar 2007
Has thanked: 99 times
Been thanked: 80 times

Postby SUPER » 04 Dec 2008

the posted code will do exactly what you are looking for in your case for example you are long one contract then it issues order to sell two contract effectively reversing your position.

maybe there is something I am missing out in your explanation, maybe you can provide me with some simple example, if not me then some one else can help you out.

regards
Super

Thomas Mann
Posts: 173
Joined: 25 Aug 2007

Postby Thomas Mann » 04 Dec 2008

Thanks for the help. I will play with it.

Thomas Mann
Posts: 173
Joined: 25 Aug 2007

Auto stop trail

Postby Thomas Mann » 05 Dec 2008

Hi,
Does anyone have a example of auto chasing a stop on orders once they are going in the right way ?

Thanks

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 08 Dec 2008

Hi Thomas Mann,

setpercenttrailing and setdollartrailing do just that. I would recommend checking MC help for details. And here's a simple example below:

----------------------------------
buy next bar market ;

setstopcontract;
setdollartrailing(10*pointvalue);


Return to “MultiCharts”