Hello, 

Just curious if below lines can solve your problem or not, I'm a beginnger just 
for practicing  (in reference to page 154 of Amibroker 4.90 User Guide in which 
sigScaleIn and sigScaleOut were first introduced..): 

// assume pcq is the indicator whose exact formula is not clear to me

// for PCQ to jump say from 25% to over 75%,  positionsize will become 75% < 
100%
// in the process PCQ will pass thru 50%, so the first scaleIn is triggered, 
(ie 50% now), then when pass thru 75%, another 25% scalein will be triggered
// so the positionSize is always 25% 
// Due to this reason, I think a loop is not needed? 

SetPositionSize(25, spsPercentOfEquity); 
Buy = Cross(pcq, 25) or Cross(pcq,50) or Cross(pcq,75) ; 
Sell = Cross(25,pcq) or Cross(50,pcq) or Cross(75, pcq); 
ScaleInConditionsLong = Cross(pcq,50) or Cross(pcq,75);
ScaleOutConditionsLong = Cross(25,pcq) or Cross(50,pcq) or Cross(75,pcq); 
InTrade = Flip(Buy,Sell);
DoScaleIn = ExRem(InTrade AND scaleInConditionsLong, Sell);
DoScaleOut = ExRem(InTrade AND scaleOutConditionsLong,Sell);
Buy = Buy + sigScaleIn * DoScaleIn + sigScaleOut * DoScaleOut; 
 
// By symmetry the short trade
Short = Cross(-25,pcq) or Cross(-50,pcq) or Cross(-75, pcq); 
Cover = Cross(pcq, -25) or Cross(pcq,-50) or Cross(pcq,-75) ; 
ScaleInConditionsShort = Cross(-50,pcq) or Cross(-75,pcq); 
ScaleOutConditionsShort = Cross(pcq,-25) or Cross(pcq,-50) or Cross(pcq,-75);
InShortTrade = Flip(Short,Cover);
DoScaleInShort = ExRem(InShortTrade AND scaleInConditionsShort, Sell);
DoScaleOutShort = ExRem(InShortTrade AND scaleOutConditionsShort,Sell);
Short = Short + sigScaleIn * DoScaleInShort + sigScaleOut * DoScaleOutShort; 
 
Regards
SW




________________________________
From: dallen2507 <[email protected]>
To: [email protected]
Sent: Tuesday, March 31, 2009 7:27:54 AM
Subject: [amibroker] Scale IN OUT


Hi,

I have an indicator PCQ that has levels of -100, -75, -50, -25, 0 , 25, 50, 75 
100. I want to use the indicator to scale in and out of a single stock. 
I want to Buy when PCQ goes positive with the % of equity equal to the value of 
PCQ. So, if PCQ goes from -50 to +25, I want to cover my short at -50% and then 
go long 25%.
Basically, I want to scale in or out of the position when PCQ changes levels, 
and have a % investment long or short equal to the PCQ level. So, if PCQ goes 
from +25 to +75, I want to scale from 25% long to 75% long.
I have tried to use setpositionsize and sigscaleIn and sigscaleOut in buy and 
sell rules, but I clearly don't understand how to do this. I have wasted 
several days on this.
Can this be done with arrays or do I need to loop? I could not find any 
examples.
Any suggestions on how to do this would be much appreciated.

Regards,
Dan Allen





      

Reply via email to