NexusFi: Find Your Edge


Home Menu

 





random strategy - add scaling in feature


Discussion in MultiCharts

Updated
      Top Posters
    1. looks_one treydog999 with 4 posts (0 thanks)
    2. looks_two ABCTG with 4 posts (4 thanks)
    3. looks_3 sptrader with 2 posts (0 thanks)
    4. looks_4 PTJDAX with 2 posts (0 thanks)
    1. trending_up 4,584 views
    2. thumb_up 4 thanks given
    3. group 6 followers
    1. forum 12 posts
    2. attach_file 1 attachments




 
Search this Thread

random strategy - add scaling in feature

  #11 (permalink)
PTJDAX
Stockholm, Sweden
 
Posts: 3 since Jul 2016
Thanks Given: 4
Thanks Received: 0

Hi guys,

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
If currentcontracts=ContractMax then begin
ContractC=True; // ensures that once Contract Max is reached there will be no more orders that day to fill up
end;

positionsize=1;

IF InitialC AND DistanceC AND NOT ContractC THEN begin
Buy ("LONG Scale in trial") positionsize CONTRACTS next bar at Market;
END;
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".
 
Code
if currentcontracts <> 0 then begin 
	
	size1=maxlist(round(currentcontracts*0.4,0),0);
	size2=round(currentcontracts*0.333,0);
	size3=currentcontracts-size1-size2;

	Targetsize= TargetScale*entryprice;
	Stopsize=StopScale*entryprice;
	SL1 = entryprice-Stopsize;

	Target1 = Targetsize; 

	Targ= entryprice+Target1*0.75; 
	Targ2= entryprice+Target1*1.4; 
	Targ3= entryprice+Target1*1.6;

	// 
	IF (NOT Target1C) then begin // If Targ has not been hit

	sell ("Exit LONG Target1") size1 contracts Next Bar at (Targ) Limit;
	sell ("Exit LONG Target1.2") size2 contracts Next Bar at (Targ2) Limit;
	sell ("Exit LONG Target1.3") size3 contracts Next Bar at (Targ3) Limit;
	end;
	
	IF currentcontracts=size2+size3 then begin
	sell ("Exit LONG Target2") size2 contracts Next Bar at (Targ2) Limit;
	sell ("Exit LONG Target3") size3 contracts Next Bar at (Targ3) Limit;
	end;

	IF currentcontracts=size3 then begin
	sell ("Exit LONG Target2.3") size3 contracts Next Bar at (Targ3) Limit;
	end;

sell ("Exit Long SL1") currentcontracts contracts Next Bar at SL1 stop;

end;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didnt know anythin …
Psychology and Money Management
What broker to use for trading palladium futures
Commodities
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #12 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

PTJDAX,

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.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #13 (permalink)
PTJDAX
Stockholm, Sweden
 
Posts: 3 since Jul 2016
Thanks Given: 4
Thanks Received: 0


Hi ABCTG,

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.

Best Regards,

Reply With Quote




Last Updated on July 14, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts