How to increase/decrease shares ?

Questions about MultiCharts and user contributed studies.
no erocla
Posts: 134
Joined: 31 May 2013
Has thanked: 60 times
Been thanked: 7 times

How to increase/decrease shares ?

Postby no erocla » 18 Jun 2020

Dearl all,

i'm facing a very strange issue, why the following does not work:

Code: Select all

LOT = LOT +1; buy ("buy adjustment") LOT contracts next bar at open;
MC open the first contract but does not increase the position.
There's a way to do that ?

Thank you !!
No Erocla

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

Re: How to increase/decrease shares ?

Postby TJ » 18 Jun 2020

Dearl all,

i'm facing a very strange issue, why the following does not work:

Code: Select all

LOT = LOT +1; buy ("buy adjustment") LOT contracts next bar at open;
MC open the first contract but does not increase the position.
There's a way to do that ?

Thank you !!
No Erocla
Your description is not very clear:

1. MC did not trigger another BUY?

or

2. MC triggered another BUY, but did not increment the LOT size?

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

Re: How to increase/decrease shares ?

Postby JoshM » 19 Jun 2020

MC open the first contract but does not increase the position.
In addition to what TJ said, it might also be that the strategy has scaling into positions disabled.

In order for MultiCharts to scale into positions, you'll need to enable the 'Allow up to n entry orders in the same direction as the currently held position' option from the 'Strategy Properties' window.

If that option is disabled, then no matter what your code does, the strategy will not increase positions.

no erocla
Posts: 134
Joined: 31 May 2013
Has thanked: 60 times
Been thanked: 7 times

Re: How to increase/decrease shares ?

Postby no erocla » 09 Jul 2020

MC open the first contract but does not increase the position.
In addition to what TJ said, it might also be that the strategy has scaling into positions disabled.

In order for MultiCharts to scale into positions, you'll need to enable the 'Allow up to n entry orders in the same direction as the currently held position' option from the 'Strategy Properties' window.

If that option is disabled, then no matter what your code does, the strategy will not increase positions.
Yes, this was the problem.
But, currently i just want 20% fixed exposure on certain index (take for example spx) through this code:

Code: Select all

var:SHARESS(0),balance(0),current_shares(0),current_Exposure(0),Desired_exposure(0),Desired_shares(0),weight(0); weight = 20; balance = InitialCapital+ i_ClosedEquity; current_Exposure = ROUND(CURRENTSHARES*C*50,0); Desired_shares = ROUND(((balance * weight)/100/50)/c,0); if desired_shares > CURRENTSHARES then begin SHARESS = desired_shares - CURRENTSHARES ; PRINT(" BUY " , DESIRED_SHARES , CURRENTSHARES , SHARESS ); BUY SHARESS shares next bar at o; end; if desired_shares < CURRENTSHARES then begin SHARESS = CURRENTSHARES - desired_shares ; PRINT(" SELL " , DESIRED_SHARES ,CURRENTSHARES , SHARESS ); SELL SHARESS shares TOTAL next bar at o; end;
MC bought correctly the first contracts (20% exposure), but after some trades stop to trade without any reason.
I really don't understand why.

No Erocla


Return to “MultiCharts”