[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] sigScaleOut



PureBytes Links

Trading Reference Links

hi,
 
I asked this question to support as well but maybe someone in the group has been working on this:
 
I am working on daytrade systems on ES futures.  I have a simple setup I want to test first:
 
Long Only:
 
1) enter 2 contracts at the open, 1 bar after a buy signal
2) scale out 1 contract if profit target 1 is hit
3) exit second contract if profit target 2 is hit
4) exit position (partial or whole) if trailing stop is hit
 
First question: how does one use setPositionSize? I tried this:
 
SetPositionSize( 2, spsShares );
SetPositionSize( 1, spsShares * ( Buy == sigScaleOut ) );
 
Second question: the exit code I use is based no the example code in the manual (see below). But in my specific setup I want to define a exit price once the first target is hit. How does one do this?
 
thanks, Ed
 
 
procedure sellCoverChandelier3_proc(Buy,BuyPrice) {

global Sell
;
global SellPrice
;
global
TrailStopArray;
global
HighSinceBuyArray;
global
BuyAdjusted;
Sell = 0
;
SellPrice = 0
;
BuyAdjusted =
0
;
TrailStopArray =
Null
;
HighSinceBuyArray =
Null
;

FirstProfitTarget =
0.5; // in points

SecondProfitTarget =
1;
TrailingStop =
4
;

priceatbuy=
0
;

for( i = 0; i < BarCount
; i++ )
{

   exitType =
0
;
   
   
if ( Buy
[ i ] )
   {
   
      priceatbuy =
BuyPrice
[ i ];
      highsincebuy =
0
;
      BuyAdjusted[ i ] =
1
;
      
      
for (j = i; j < BarCount
; j++)
      {      
   
         highsincebuy =
Max( High
[ j ], highsincebuy );
         HighSinceBuyArray[ i ] = highsincebuy;
         TrailStopArray[ j ] = highsincebuy - TrailingStop;
      
         
if( exitType == 0 AND High
[ j ] >= (priceatbuy + FirstProfitTarget) )
         {
      
            
// first profit target hit - scale-out

            exitType =
1;
            
Buy[ j ] = sigScaleOut
;
         
         }
      
         
if( exitType == 1 AND High
[ j ] >= (priceatbuy + SecondProfitTarget) )
         {
      
            
// second profit target hit - exit

            exitType =
2;
            
Sell[ j ] = 1
;
            
SellPrice[ j ] = Max( Open
[ j ], (priceatbuy + SecondProfitTarget) );
            
            i = j;
            
break
;
         
         }
      
         
if( Low
[ j ] <= (highsincebuy - TrailingStop) )
         {
      
            
// trailing stop hit - exit

            
Sell[ j ] = 1;
            
SellPrice[ j ] = Min( Open
[ j ], (highsincebuy - TrailingStop) );
            
            i = j;
            
break
;
         
         }          
      }
   }
}

}
__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___