Sell function

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

Sell function

Postby tradingest » 03 Jun 2016

Hi all,

I have the problem with the code below:

Code: Select all

var:
MP(0),
N(0),
CloseHalfPosition (0),
P(0);

P = Entryprice(0);
CloseHalfPosition = P + 50 point;
N = MarketPosition_at_Broker;


If N > 0 and P <> 0.0 and P > CloseHalfPosition
Then Begin
Once
print(
" P: ", P:3:5,
" N: ", N,
" N/2: ", N/2,
" close N/2: ", P + 50 point:3:5
);
Sell CloseHalfPosition contract this bar at market;
End;
Can you help me?

Thanks,
tradingest

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: Sell function

Postby tony » 04 Jun 2016

Hi all,

I have the problem with the code below:

Code: Select all

var:
MP(0),
N(0),
CloseHalfPosition (0),
P(0);

P = Entryprice(0);
CloseHalfPosition = P + 50 point;
N = MarketPosition_at_Broker;


If N > 0 and P <> 0.0 and P > CloseHalfPosition
Then Begin
Once
print(
" P: ", P:3:5,
" N: ", N,
" N/2: ", N/2,
" close N/2: ", P + 50 point:3:5
);
Sell CloseHalfPosition contract this bar at market;
End;
Can you help me?

Thanks,
tradingest
One line that jumps out is

P = Entryprice(0);
CloseHalfPosition = P + 50 point;

In other words, CloseHalfPosition = Entryprice + 50 point;

You then have

If N > 0 and P <> 0.0 and P > CloseHalfPosition

In other words EntryPrice > EntryPrice + 50 point

That would never be true.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Sell function

Postby JoshM » 04 Jun 2016

I have the problem with the code below:
To add to Tony's comment, you also use `this bar at market`, which is something that's only suited for backtesting.

Can you perhaps say what "the problem" is? That helps us to give more focused replies and to help better.


Return to “MultiCharts”