Thanks again David. You have been very helpful Ron
--- In [email protected], "dbw451" <[EMAIL PROTECTED]> wrote: > > Yes, I use a stop and profit target all the time just like you have coded > (except I would call myStop2 something like myProfitTarget). > > > > Regards, > > > > David > > > > _____ > > From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf > Of booker_1324 > Sent: 03/03/2007 10:41 AM > To: [email protected] > Subject: [amibroker] Re: fixed stop loop??????????? > > > > Hi Dave, > > Thank you for the Applystop explanation as I have struggled with the > proper use of Applystop and this helps a lot. > > One more question if I may. Is it possible to have both of these > statements > > ApplyStop(stopTypeLoss, stopModePoint, myStop1, 1); > ApplyStop(stopTypeProfit, stopModePoint, myStop2, 1); > > In the same program without the latter overriding the former, > effectively creating a bracket trade? > > Thx > > Ron > > --- In [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com, > "dbw451" <dbw451@> wrote: > > > > Hi Ron, > > > > > > > > This is more code than it needs to be, but hopefully it makes a way > to set > > Buy and Short fixed stops clear (please note: I wrote this for this > as an > > example for this post and have not tested the code): > > > > > > > > myBuyEntryPrice = ValueWhen(Buy,C); // substitute equation for > your buy > > entry price > > > > myBuyStopPrice = Ref(LLV(L,FXLbak),-1); // substitute equation for > your buy > > stop price > > > > > > > > myShortEntryPrice = ValueWhen(Short,C); // substitute equation for > your > > short entry price > > > > myShortStopPrice = Ref(HHV(H,FXLbak),-1);// substitute equation for > your > > short stop price > > > > > > > > myBuyStop = myBuyEntryPrice - myBuyStopPrice; // Buy stop > in points > > > > myShortStop = myShortStopPrice - myShortEntryPrice; // Short > stop in > > points > > > > > > > > myStop = IIf(Buy,myBuyStop,IIf(Short,myShortStop,Null)); > > > > > > > > ApplyStop(stopTypeLoss, stopModePoint, myStop, 1); > > > > > > > > Regards, > > > > > > > > David > > > > > > > > _____ > > > > From: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com > [mailto:[EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com] > On Behalf > > Of booker_1324 > > Sent: 03/02/2007 11:46 PM > > To: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com > > Subject: [amibroker] Re: fixed stop loop??????????? > > > > > > > > Hi David, > > > > How would you code mystop if short and cover was also in the code > > along with buy and sell? > > > > Thx > > > > Ron > > > > --- In [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> > ps.com, > > "dbw451" <dbw451@> wrote: > > > > > > Hi Ian, > > > > > > > > > > > > All you have to do is determine the number of points between your > > entry > > > price and your stop price and use the ApplyStop function. Here's > > an example > > > using your code (which would be placed at the end of your code): > > > > > > > > > > > > myStop = ValueWhen(Buy,C) - Ref(LLV(L,FXLbak),-1); > > > > > > ApplyStop(stopTypeLoss, stopModePoint, myStop, 1); > > > > > > > > > > > > Regards, > > > > > > > > > > > > David > > > > > > _____ > > > > > > From: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> > ps.com > > [mailto:[EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> > ps.com] > > On Behalf > > > Of ianjw2 > > > Sent: 03/02/2007 7:53 PM > > > To: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> > ps.com > > > Subject: [amibroker] fixed stop loop??????????? > > > > > > > > > > > > Hi all, > > > > > > Below is code for a system that I'm using, however, I want to > > > introduce a Fixed Stop Loss. To be fixed on the Entry Signal day. > > > > > > Problem is, I do not have the faintest idea how to do it. > > > > > > As written, the value works like a trailing stop loss. I suspect > it > > > may need a loop. But my AFL skills still need a lot of improving > I'm > > > afraid. It would be great if someone could point me in the right > > > direction. > > > > > > Cheers > > > Ian > > > > > > /*Liquidity..........*/ > > > MinTo=2000000; > > > LastDay=2000000; > > > MinPrice=.40; > > > > > > TurnOv=MA(C,21)*MA(V,21)>MinTo AND V*C>Lastday AND C>Minprice; > > > > > > //Entry Signal > > > TrendMA=MA(C,20);//Trend moving average > > > EnSig=C>TrendMA;//Entry signal - Buy triggered on confirmation > > > > > > //Fixed Stop Loss > > > //FXLbak=2; > > > //FXStop=L<Ref(LLV(L,FXLbak),-1);// Fixed Stop Loss - Fixed from > > Entry > > > Signal day > > > > > > // Sell Signal > > > LBak=20;// Lookback periods > > > ExSig=L<Ref(LLV(L,LBak),-1);// Exit signal - Sell on confirmation > > > > > > Buy=TurnOv AND EnSig; > > > Sell=ExSig; > > > Buy=ExRem(Buy,Sell); > > > Sell=ExRem(Sell,Buy); > > > > > >
