Partial Sell Order not working  [SOLVED]

Questions about MultiCharts and user contributed studies.
User avatar
johnsel
Posts: 7
Joined: 11 Aug 2011
Has thanked: 8 times

Partial Sell Order not working

Postby johnsel » 15 Apr 2015

Hi,

I'm trying to code a rebalance which requires selling a partial amount of my position sometimes.

The number of shares I want to sell is in a variable called "rebalRounded"

This order is never filled:

Code: Select all

Sell ("LX - rebal") rebalRounded contracts total from entry("LE") next bar at market;
But it does work if I remove "rebalRounded contracts total" so the code reads:

Code: Select all

Sell ("LX - rebal") from entry("LE") next bar at market;
Has anyone seen this problem? Any suggestions would be much appreciated.

Thanks,

Elliot

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Partial Sell Order not working

Postby orion » 15 Apr 2015

The following notes may be helpful for you.

There are 3 types of exits:
1) tied exit
2) untied exit
3) total exit

1) The following are tied exits. The exit is tied to a specific entry. The first sells 100 shares that were bought by specific entry named. The second sells all shares that were bought by specific entry named.

Code: Select all

sell [("exitname")] from entry ("entryname") 100 shares [order_action];
sell [("exitname")] from entry ("entryname") all shares [order_action];
2) The following are untied exits. The exit is not tied to any specific entry and it exits equal number of shares from all open entries. So the first will exit 100 shares from all open entries which means that if there are 3 open entries resulting from scaling in, then 300 shares will be sold. The secondsells all shares for all entries.

Code: Select all

sell [("exitname")] 100 shares [order_action];
sell [("exitname")] all shares [order_action];
3) The following is a total exit. It exits a total of 100 shares.

Code: Select all

sell [("exitname")] 100 shares total [order_action];

User avatar
johnsel
Posts: 7
Joined: 11 Aug 2011
Has thanked: 8 times

Re: Partial Sell Order not working  [SOLVED]

Postby johnsel » 15 Apr 2015

Thanks Orion,

I found my error...I was trying to sell a negative number of shares.

In case it's helpful to anyone, my code did this:

rebalRounded was positive (to buy more shares) or negative (to sell some shares).

I forgot to multiply it by -1 before the sell order.

Sorry for bothering everyone and thanks again Orion for your help.


Return to “MultiCharts”