Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I just joined the forum and was looking for a solution to a scale-in/scale-out problem similar as described in this thread. Like this:
(Platform: Multicharts)
1) I have a strategy that enters with 10 contracts All-in, sets 3 targets with different size. And this works fine.
2) I want to instead investigate how I can enter at multiple bars, 1 contract at a time. I thought this would be easy, but even though the contract accumulation is working correctly, all contracts are dumped on the first target even though I have monitored the size variable and it is set correctly.
Posting the code below. I am sure that this is a piece of cake many of you more experienced guys. Any help is really appreciated. Hope that I can help you guys with other things down the road.
Code for accumulating contracts. This works as expected.
Code for calculating size and targets. I have monitored the 3 different sizes, and the calculations are correct.
However all 10 contracts are sold on "EXIT Long Target1".
Can you help answer these questions from other members on NexusFi?
you can look into the reserved word "total". This is the explanation from the manual:
Total
Used in strategy exit statements, following a numerical expression and the words Shares or Contracts, to indicate that only the number of contracts or shares specified by the numerical expression is to be sold or covered in total, regardless of the number of open entries. The contracts or shares will be sold or covered in the same order they were bought or shorted: First In, First Out. If the word Total is not used, the number of contracts or shares specified by the numerical expression will be sold or covered for each one of the open entries.
If this doesn't give you the desired result you will have to tie the exit orders to specific entry orders. For example you can dynamically change the entry name for each order, so each entry is unique. You can for example add the number of contracts at the time of the entry (converted to a string).
This will also ensure that an exit is not re-used.
That is really excellent advice. I just added "total" and it works as expected now.
Your second suggestion is also a good one and I'll keep that in mind for future work.
Many thanks once again, Vielen Dank nochmal, I really appreciate it.