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

[amibroker] Re: Help Limiting number of positions added per day



PureBytes Links

Trading Reference Links

Raskoks, I am not very good at this yet, but I can see a few things that might be causing problems.

1. SetBacktestMode( backtestRegularRaw2 ); Make sure that you want RegularRaw2. Raw2 does allow redundant signals.

2. newDayB=Ref(dn,-1)!= dn; I don't see where you have defined dn.

3. if ( CntBuys <= MaxBuys.....I had to take out the = sign so that it reads CntBuys<MaxBuys.

Hope this helps,
Wood

--- In amibroker@xxxxxxxxxxxxxxx, "raskoks" <raskoks@xxx> wrote:
>
> Hi,maybe someone can tell me what i do wrong. I have smth like that (code below) and i need to have max only one transaction per day. Morover every transacion is simply reversing position (always on market). But for this code signals which aren't use ( for example buy signal when i already have long position) are count to daily limit. I really don't know why :).
> Thanks for any help.
> 
> 
> CondBuy=..;
> CondShort=..;
> Buy= CondBuy ;
> Sell= CondShort ;
> Short=Sell;
> Cover=Buy;
> 
> CurrentPos[0]=0;
> MaxBuys = 1;
> dnB = DateNum();
> newDayB=Ref(dn,-1)!= dn;
> SetBacktestMode( backtestRegularRaw2 );
> SetCustomBacktestProc("");
> if ( Status( "action" ) == actionPortfolio )
> {
>    bo = GetBacktesterObject();
>    bo.PreProcess();
>    cntBuys =0;
>    for ( i = 0; i < BarCount; i++ )
>    {
> 	if(newDayB[i]==1)
>       	cntBuys = 0;
> 
>       for ( sig = bo.GetFirstSignal( i ); sig; sig =bo.GetNextSignal( i ) )
>       {
> 
>             
>             if ( CntBuys <= MaxBuys AND sig.IsLong()AND CurrentPos[0]!=1)
>             {
>                CanEnter = True;
>                CntBuys++;
> 		CurrentPos[0]=1;
>             }
> 		else if ( CntBuys <= MaxBuys AND NOT sig.IsLong()AND CurrentPos[0]!=-1)		{ 							
>                CanEnter = True;
>                CntBuys++;
> 		 CurrentPos[0]=-1;
> 
> 		} 
>             if ( ! CanEnter ) sig.Price = -1;
>          
>         }
>    bo.ProcessTradeSignals( i );
>    }
>    bo.PostProcess();
> }
>




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

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