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

Re: [amibroker] Re: Actual trade bar



PureBytes Links

Trading Reference Links



Hello everyone,
Below discussion is  very interesting , i would request  mike,broman1003 to please give/put full afl..as this is very confusing to me i cant get all this stuff in my little brain [ i am new to all this]*
Thank you
//-----------------------------------------------------------------------------------------
--- On Fri, 24/7/09, Mike <sfclimbers@xxxxxxxxx> wrote:

From: Mike <sfclimbers@xxxxxxxxx>
Subject: [amibroker] Re: Actual trade bar
To: amibroker@xxxxxxxxxxxxxxx
Date: Friday, 24 July, 2009, 2:39 AM

 

Fredrik,

ProcessTradeSignals should come *after* you've done anything with the Signal objects.

Also, you may need to double check whether you are allowed to mix ProcessTradeSignals (a mid level backtester method) with ExitTrade (a low level backtester method) in the same script.

It's been a while since I'be read up on this, so see "AmiBroker Custom Backtester Interface..pdf" in the Files section for additional detail.

Mike

--- In amibroker@xxxxxxxxx ps.com, "broman1003" <fredrik_broman1003 @...> wrote:
>
> Came up with a solution. If I use Foreign and get the High/Low/Open arrays that way it works fine.
> /Fredrik
>
> --- In amibroker@xxxxxxxxx ps.com, "broman1003" <fredrik_broman1003 @> wrote:
> >
> > Ok, so I had a go at it :-) Not sure that this is how you should do things but it is my first attempt. The below code does not work because High[bar] and Low[bar] allways returns zero. Hints?
> >
> > Thanks,
> > /Fredrik
> >
> > SetOption("UseCusto mBacktestProc" ,True);
> > if( Status("action" ) == actionPortfolio )
> > {
> > bo = GetBacktesterObject ();
> > bo.PreProcess( );
> >
> > TradeEntryPrice = False;
> > ProfitTarget = False;
> > TrailingSL = False;
> >
> > for(bar=0; bar<BarCount; bar++)
> > {
> > bo.ProcessTradeSign als( bar );
> >
> > for( Sig = bo.GetFirstSignal( bar); Sig; Sig=bo.GetNextSigna l(bar) )
> > {
> > if( Sig.IsEntry( ) )
> > {
> > TradeEntryPrice = Sig.Price;
> > ProfitTarget = --something- --;
> > }// if
> >
> > if( Sig.IsExit() )
> > {
> > TradeEntryPrice = False;
> > ProfitTarget = False;
> > TrailingSL = False;
> > }// if
> > }// for
> >
> > //Profit Target
> > if (TradeEntryPrice AND High[bar]>=ProfitTa rget)
> > {
> > bo.ExitTrade( bar,"T5", Min(ProfitTarget, Open[bar] ), 2);
> > TradeEntryPrice = False;
> > ProfitTarget = False;
> > TrailingSL = False;
> > }
> >
> > ----
> > //Calculate Trailing SL
> > ----
> >
> > //Trailing SL
> > if (TradeEntryPrice AND Low[bar]<TrailingSL )
> > {
> > bo.ExitTrade( bar,"T5", Min(TrailingSL, Open[bar] ), 3);
> > TradeEntryPrice = False;
> > ProfitTarget = False;
> > TrailingSL = False;
> > }
> > } //for
> >
> > bo.PostProcess( ); // Finalize backtester
> > } // if
> >
> >
> > Buy = --- something ---
> > Sell = --- something ---
> >
> >
> > --- In amibroker@xxxxxxxxx ps.com, "broman1003" <fredrik_broman1003 @> wrote:
> > >
> > > Mike,
> > > Thanks, I'll have a go at it. I have managed to avoid using the customer backtester up till now but I guess it is time well spent learning it.
> > > Cheers,
> > > /Fredrik
> > >
> > > --- In amibroker@xxxxxxxxx ps.com, "Mike" <sfclimbers@ > wrote:
> > > >
> > > > You can get the bar index of the trade by using ValueWhen and the trade's entry date as follows (from within custom backtester code):
> > > >
> > > > bars = BarIndex();
> > > > dates = DateTime();
> > > > bo = GetBacktesterObject ();
> > > >
> > > > ...
> > > >
> > > > for ( trade = bo.getFirstOpenPos( ); trade; trade = bo.getNextOpenPos( ) )
> > > > {
> > > > entryBar = LastValue( ValueWhen( trade.EntryDateTime == dates, bars ) );
> > > >
> > > > ...
> > > >
> > > > There may be a better way of handling your stop loss, but the above should should at least answer your question.
> > > >
> > > > Mike
> > > >
> > > > --- In amibroker@xxxxxxxxx ps.com, "broman1003" <fredrik_broman1003 @> wrote:
> > > > >
> > > > > Hi,
> > > > > I would like to get hold of the bar where a trade was entered when backtesting.
> > > > > The reason I need it is that I would like to implement a trailing SL that is depending on the highest value the price has hit since the trade was initiated.
> > > > >
> > > > > All hints are appreciated.
> > > > > Thanks,
> > > > > /Fredrik
> > > > >
> > > >
> > >
> >
>



See the Web's breaking stories, chosen by people like you. Check out Yahoo! Buzz.

__._,_.___


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





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___