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

[amibroker] Re: Tomasz, Need Help With sigScaleOut



PureBytes Links

Trading Reference Links

Ok, this last suggestion was very helpful. Thank again.
But now I am having a situation where the system is not taking all the
entry signals in the back tester. I am trying to understand why it
might skip a valid entry signal when current position = 0 and there
are no reasons I can see why any of these signals should be skipped. 
I am questioning the last line in the scale-out example given in the
help file. Can you explain what this statement does and how it might
affect entry signals?
SetPositionSize( 50, spsPercentOfPosition * ( Buy == sigScaleOut ) ); 

Thanks.

  Pete  :-)

--- In amibroker@xxxxxxxxxxxxxxx, "Pete" <dryheat3@xxx> wrote:
>
> BuyPrice??? Interesting, I tried using the SellPrice in the scale out
> bar and that didn't work so I figured I was on the wrong trail.
> I'm not exactly sure why it should work this way, but since the scale
> out signal itself is defined as:
> Buy[i] = sigScaleOut;
> 
> I suppose it kinda makes since. But why is it working like this in the
> first place? Why would the sigScalout parameter not more logically be
> paired with the exit, like Sell[i] or Cover[i]???
> If someone could explain this it will help more fully understand how
> this section of code functions.
> Thanks.
> 
>   Pete  :-)
> 
> --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@> wrote:
> >
> > You need to define the BuyPrice at the scaleout bar
> > 
> > 
> > -- 
> > Cheers
> > Graham Kav
> > AFL Writing Service
> > http://www.aflwriting.com
> > 
> > 
> > 
> > 2009/2/2 Pete <dryheat3@>:
> > > I have spent several hours trying to implement the Scale-out
strategy
> > > using futures contracts. I have finally come to the conclusion that
> > > the example in the help file does not create a true scale out
system.
> > >
> > > Here's what I found:
> > > On the bar where a scale out is triggered, instead of reporting the
> > > target price that triggered the scale out, the back tester actually
> > > reports the open or close of that bar. (depending upon what settings
> > > are used in the trades tab). This does not match a real trading
> > > environment where you would place sell limit orders at your various
> > > targets and wait for the price to hit them.
> > >
> > > I have spent many frustrated hours trying to get it to show the
actual
> > > target price as the exit price in the back tester but so far this
> > > alludes me.
> > > Here's an example of what I am trading in real life but so far
cannot
> > > write code to duplicate in the back tester:
> > > Enter long 3 contracts.
> > > Stop loss set at buy price minus 1.25 points
> > > Target one set to buy price plus 1.25 points
> > > Target two set to buy price plus 2.5 points
> > > Remaining contract exits when close crosses below EMA(C, 20).
> > >
> > > The code below is what I have accumulated so far:
> > >
> > > Buy = <<Insert favorite buy signal here>>;
> > > Sell = 0;
> > > SystemExit = Cross(EMA(C, 20), Close);
> > > // the system will exit
> > > // 50% of position if FIRST PROFIT TARGET stop is hit
> > > // 50% of position is SECOND PROFIT TARGET stop is hit
> > > // 100% of position if TRAILING STOP is hit
> > >
> > > FirstProfitTarget = 1.25; // profit
> > > SecondProfitTarget = 2.5; // in points
> > > TrailingStop = 1.25; // also in points
> > >
> > > priceatbuy=0;
> > > highsincebuy = 0;
> > >
> > > exit = 0;
> > >
> > > for( i = 0; i < BarCount; i++ )
> > > {
> > >   if( priceatbuy == 0 AND Buy[ i ] )
> > >    {
> > >       priceatbuy = BuyPrice[ i ];
> > >    }
> > >
> > >   if( priceatbuy > 0 )
> > >    {
> > >       highsincebuy = Max( High[ i ], highsincebuy );
> > >
> > >                if( exit <= 2 AND
> > >                                SystemExit[i] )
> > >                {
> > >                //system exit hit - exit any remaining contracts
> > >                SellPrice[i] = Close[i];
> > >                exit = 3;
> > >                }
> > >
> > >      if( exit == 0 AND
> > >          High[ i ] >= FirstProfitTarget + priceatbuy )
> > >       {
> > >         // first profit target hit - scale-out
> > >         exit = 1;
> > >         Buy[ i ] = sigScaleOut;
> > >       }
> > >
> > >      if( exit == 0 AND
> > >          High[ i ] >= SecondProfitTarget + priceatbuy )
> > >       {
> > >         // second profit target hit - exit
> > >         exit = 2;
> > >         Buy[ i ] = sigScaleOut;
> > >                  //SellPrice[ i ] = Max( Open[ i ],
> SecondProfitTarget + priceatbuy );
> > >       }
> > >
> > >      if( Low[ i ] <=  priceatbuy - TrailingStop )
> > >       {
> > >         // trailing stop hit - exit
> > >         exit = 3;
> > >         SellPrice[ i ] = Min( Open[ i ], priceatbuy -
TrailingStop );
> > >       }
> > >
> > >      if( exit >= 3 )
> > >       {
> > >         Buy[ i ] = 0;
> > >         Sell[ i ] = exit + 1; // mark appropriate exit code
> > >         exit = 0;
> > >         priceatbuy = 0; // reset price
> > >         highsincebuy = 0;
> > >       }
> > >    }
> > > }
> > >
> > > SetPositionSize( 15, spsPercentOfEquity ); //Equity is set at
> 10,000.00
> > > SetPositionSize( 1/3, spsPercentOfPosition * ( Buy ==
sigScaleOut ) );
> > > // scale out 50% of position
> > >
> >
>



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

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

*********************
TO GET TECHNICAL 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

*********************************
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/