# Can MC pyramid out of a strategy?  [SOLVED]

Questions about MultiCharts and user contributed studies.
Xyzzy
Posts: 162
Joined: 19 Mar 2011
Has thanked: 43 times
Been thanked: 79 times

### Can MC pyramid out of a strategy?

I'm working on a strategy that pyramids into a market position by buying one contract per bar during a particular timeframe. I'd like it to then pyramid out of the position after a position has been open for X number of bars.

For example, let's assume that the strategy is running on hourly bars. It purchases one contract at 1:00, a second contract at 2:00 and a third contract at 3:00. I'd like to close each position after that position has been open for five hours -- i.e., it would sell one contract at 6:00, a second contract at 7:00 and a third contract at 8:00.

I currently have the following code for my entry and exit. The exit is based on the "TimeExit (Bars) LE" signal:

Code: Select all

```If Time >= EnterStart AND Time < EnterEnd then begin Buy 1 contract next bar at Close Limit; end; If BarsSinceEntry = BarToExitOn then begin Sell 1 contract next bar at market; end;```
This doesn't have the desired effect. Instead of pyramiding out of the position gradually, it sells all of the contracts at the same time, X number of bars after the first position was entered. In the example above, it will sell all three contracts at 6:00, rather than closing them sequentially over time. (Despite the "sell 1 contract" limitation.)

Is there any way to achieve this? Thanks in advance for any pointers.

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

### Re: Can MC pyramid out of a strategy?  [SOLVED]

Hello Xyzzy,

You can switch between the modes for processing exit orders using the signal attribute [SameExitFromOneEntryOnce = True/False]. It has been added in MC 8.5.

[SameExitFromOneEntryOnce = true]
Standard EasyLanguage Calculation (default) - any one exit order cannot be applied to one entry more than once. Exit order that was filled can be generated again and applied to a different entry.

[SameExitFromOneEntryOnce = false]
Fill and Kill Exit Order - any one exit order can be applied an unlimited number of times to one entry. After this exit is filled it cannot be applied again until the script recalculates and generates it again.

Code: Select all

`Sell 1 contract total next bar at market;`
Alternatively that is possible to exit from particular entry order with Sell from entry and BuyToCover from entry commands.

Xyzzy
Posts: 162
Joined: 19 Mar 2011
Has thanked: 43 times
Been thanked: 79 times

### Re: Can MC pyramid out of a strategy?

Thanks Henry! This is very helpful.