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

[amibroker] TJ's "Sell at the open on the first profitable day' ???



PureBytes Links

Trading Reference Links

Hi

I was given the following exit code on the forum which 'Sells at the open on the first profitable day' and was supposedly written by TJ.

I added it to a simple Gap system to test it and It works most of the time but occasionally skips one or more  profitable opens before exiting.

Can any of the experts spot why it’s inconsistent?

Any help would be appreciated!!

Peter

 

 

SetChartOptions( 0, chartShowArrows );

SetOption("AllowSameBarExit",True );

SetOption( "ActivateStopsImmediately", True );

SetOption( "Futuresmode", True );

 

Buy = Open > Ref(H,-1);

BuyPrice = Open;   

 

Sell = 0;

 

/* Exit first profitable open - Long */

 

entrybar = -1;

 

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

{

if( entrybar == -1 AND Buy[ i ] )

{

entrybar = i;

}

 

if( entrybar != -1 AND i > entrybar  AND Open[ i ] > BuyPrice [entrybar ] )

{

Sell[ i ] = 1;

SellPrice[ i ] = Open[ i ];

entrybar = -1;

}

else

{

Sell[ i ] = 0;

}

}

 

/* Exit Pints Stop- Long */

StopLossPtsPar = Param("StopLoss Pts", 30, 10,50,1);

StopLossPtsOpt = Optimize("StopLossPts", StopLossPtsPar , 10, 50, 1);

PtStop = ApplyStop(stopTypeLoss, stopModePoint, StopLossPtsOpt , 1, False, 0);

 

PositionSize =  MarginDeposit = 1;

 



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 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 Stock investment software


YAHOO! GROUPS LINKS