Code to manage on the position  [SOLVED]

Questions about MultiCharts and user contributed studies.
tradingest
Posts: 283
Joined: 05 Dec 2014
Location: Italy
Has thanked: 53 times
Been thanked: 3 times

Code to manage on the position

Postby tradingest » 15 May 2016

Hi all,

I want write the code to manage and exit automatic. The entry position is manual. The code below but the compiling is an error:

Code: Select all

variables:

vMktPos( MarketPosition_at_Broker ),
Ingresso(0),
N(0);

Ingresso = entryprice;
N = currentcontracts;

If vMktPos = 1
Then Begin
sell N/2 contract at Ingresso + 10 PointValue;
End;
Thanks,
tradingest

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Code to manage on the position

Postby sptrader » 15 May 2016

Try something like this:
(you may have to use the "round" function to get an even number of contracts..what if N = 3 etc)

Code: Select all

If vMktPos = 1
Then Begin
sell N/2 contracts next bar at Ingresso + 10 points limit;
End;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Code to manage on the position

Postby TJ » 15 May 2016

Hi all,

I want write the code to manage and exit automatic. The entry position is manual. The code below but the compiling is an error:
::
Please make a screenshot of the error message.

tradingest
Posts: 283
Joined: 05 Dec 2014
Location: Italy
Has thanked: 53 times
Been thanked: 3 times

Re: Code to manage on the position

Postby tradingest » 16 May 2016

Hi,

with the code below generate the following error

Code: Select all

if MarketPosition = 1
then begin
If currentcontracts = 50
Then begin
setbreakeven(45);
setstoploss(200);
setprofittarget(60);
setDollarTrailing(30);
End;

If currentcontracts = 100
Then begin
setbreakeven(50);
setstoploss(200);
setprofittarget(60);
setDollarTrailing(30);
End;
end;
Image

Probably it depends on the non-alignment between strategy and real positions as shown below

Image

Can you help me?

Thanks,
tradingest
Attachments
Immagine 007.png
(22.39 KiB) Downloaded 1045 times
Immagine 006.png
(3.73 KiB) Downloaded 1052 times

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

Re: Code to manage on the position

Postby Henry MultiСharts » 16 May 2016

Hello tradingest,

That is a known issue related to the FXCM connection. It has nothing to do with the code. We are currently working together with FXCM to have this issue resolved.

tradingest
Posts: 283
Joined: 05 Dec 2014
Location: Italy
Has thanked: 53 times
Been thanked: 3 times

Re: Code to manage on the position

Postby tradingest » 16 May 2016

Hi Henry,

the same code with an other broker should works without problem right?

Very thanks Henry,
tradingest

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

Re: Code to manage on the position  [SOLVED]

Postby Henry MultiСharts » 16 May 2016

Hi Henry,

the same code with an other broker should works without problem right?

Very thanks Henry,
tradingest
Other brokers do not have outstanding issues of such kind.


Return to “MultiCharts”