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

[amibroker] SetPositionSize and SigScaleIn - Please Help



PureBytes Links

Trading Reference Links

I am trying to set my initial position size to 100 shares. if additional conditions are met, I want to add 200 shares, 300 shares, and 400 shares.

I can't get this code to work...it will only do equal amounts of shares for each sigscalein.

Can someone PLEASE help?

SetPositionSize(100,spsShares);

Buy=buy rule
Sell=sell rule

priceatbuy=0; 
enter = 0; 

for( i = 0; i < BarCount; i++ ) 
{ 
   if( priceatbuy == 0 AND Buy[i] ) 
    { 
       priceatbuy = BuyPrice[i]; 
    } 

   if( priceatbuy > 0 ) 
    { 
      if( enter == 2 AND Close[i] < priceatbuy) 
       { 
         // add to your position 
         enter = 3;
         Buy[i] = sigScaleIn; 
//         SetPositionSize(400,spsShares);
       } 

      if( enter == 1 AND Close[i] < priceatbuy)  
       { 
         // add to your position  
         enter = 2;
         Buy[i] = sigScaleIn;
//         SetPositionSize(300,spsShares);
       } 

      if( enter == 0 AND Close[i] < priceatbuy)  
       { 
         // add to your position  
         enter = 1; 
         Buy[i] = sigScaleIn;
//         SetPositionSize(400,spsShares);
       } 

      if( Sell[i] ) 
       { 
         Buy[ i ] = 0; 
         enter = 0; 
         priceatbuy = 0; // reset price 
       } 
    } 
} 



------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/