thanks for respond Wood. 1) It shouldn't be a problem cause i want to allow only one trade per day :) - so even is signal is redundant it shouldn't change anything (or maybe i'm wrong? ;-) ) 2) Of course it should be dnB insteed dn - my mistake ;) - it doesn't matter - sorry about that 3) I'll check it later (do't have ami on this computer) but i think that I already checked it - and it wasn't a source of the problem.
I mean - at this moment some signals doesn't work beacause they aren't first at current day. But first correct signal ( example :CurrentPos[0]=1, so first Short signal should work - and it shouldn't be important if before it was Long signal ) does,t work sometimes when wrong signal is earlier. I don't know if i show you my problem clear. raskoks On Tue, Oct 6, 2009 at 1:36 AM, woodshedder_blogspot < [email protected]> wrote: > > > 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 [email protected] <amibroker%40yahoogroups.com>, "raskoks" > <rask...@...> 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(); > > } > > > > > -- Nawet woda czasem śpi ...
