PureBytes Links
Trading Reference Links
|
Psst, I am going to go to bed now, but I would appreciate
it if you could figure out why Valuewhen seems to ignore my instructions as
described in my recent post intitled VALUE WHEN IGNORES
ME. TIA Ron D.
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Phsst
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Sunday, October 26, 2003 11:40
PM
Subject: [amibroker] Re: trailing stop
question from new user
Jim,Yes, you have missed something obvious here...Tomasz
told you twice that in order to accomplish what you want, thenyou must use
something similar to the example looping code he postedin his first
response.And I made a post with the Subject line of "Trailing Stop
Example",that gave you an even closer solution to what you want to
accomplish.But you don't seem to want follow the suggested approach,
so youcontinue to try to fit a square peg into a round hole.In
order to backtest a trailing stop condition as you described, you*MUST*
resort to the looping approach that was presented to you. Thereis no other
choice based upon the current capabilities of AB.I can tell you from
experience that if you don't understand why thisis so, then there is
something fundamental that you don't understandabout AB AFL... and in that
case then go back and make a 2nd or 3rdpass thru the AFL
Tutorial.Regards,Phsst--- In <A
href="">amibroker@xxxxxxxxxxxxxxx,
"jwilsonp2a" <j1wilson@x...>
wrote:> Tomasz,> > I understand your first point about
Volatile=True. As far as > modifying BuyPrice and SellPrice, I took
those two lines:> > BuyPrice=Max(BuySTOP,Low);>
SellPrice=Min(SellSTOP,High);> > directly from the user guide.
Am I missing something obvious here?> > Thanks, Jim>
> > > --- In <A
href="">amibroker@xxxxxxxxxxxxxxx, "Tomasz
Janeczko" <amibroker@x...> >
wrote:> > Hello,> > > > No the code is
incorrect.> > If you use Volatile = False (and you do in your
code)> > the value of stop is locked at entry bar it> > it
does not change during the trade.> > > > You would need to
use Volatile = True.> > > > Second error is modifying
BuyPrice and SellPrice arrays.> > These are reserved variable names.
Should be used> > as INPUT for backtester to change the prices of
ordinary> > entries/exits (not exits by stop).> > >
> As I wrote already the stop you want to achieve could> > be
programmed with the loop that I already posted code for.> > >
> Best regards,> > Tomasz Janeczko> >
amibroker.com> > ----- Original Message ----- > > From:
"jwilsonp2a" <j1wilson@x...>>
> To: <<A
href="">amibroker@xxxxxxxxxxxxxxx>>
> Sent: Saturday, October 25, 2003 3:08 AM> > Subject:
[amibroker] Re: trailing stop question from new user> > >
> > > > > > > Tomasz,> > > >
> > Can you please comment on this, from my earlier post?> >
> > > > I seem to have a workaround, after finding that I
could> > > vary the trailing stop percentage with a
variable:> > > (comments please !!)> > > >
=====================================================================>
> > >
=====================================================================>
> > SellSTOP=(ValueWhen(Buy,Ref(High,-1),N=1));> > > /*
LOCK IN A FIXED STOP PRICE ON DAY OF ENTRY */> > > > >
> BuyPrice=Max(BuySTOP,Low);> > >
SellPrice=Min(SellSTOP,High);> > > > > >
profit_percent=((100 * (High - BuyPrice)/BuyPrice) >= 10);> >
> > > > trail_stop_percent=IIf(profit_percent,3,100);>
> > > > >
ApplyStop(2,1,trail_stop_percent,True,False);> > > /* IF PROFIT
IS AT LEAST 10%, USE 3% TRAILING STOP, ELSE 100% */> > > >
> > Sell=Close < SellSTOP;> > > /* OTHERWISE USE
ABSOLUTE STOP LOSS OF Inside Day High ON SETUP > */> > >
> > > >
=====================================================================>
> > >
=====================================================================>
> > > > > > > > >
=====================================================================>
> > >
=====================================================================>
> > > > > --- In <A
href="">amibroker@xxxxxxxxxxxxxxx, "Tomasz
Janeczko" > <amibroker@x...>
> > > wrote:> > > > Hello,> > > >
> > > > ApplyStops can be either enabled or disabled.>
> > > You can not change this bar-by-bar.> > > >
> > > > Instead write a code that uses a loop as shown in the
User's > Guide > > > for profit target.> > >
> > > > > /* a sample low-level implementation of
Profit-target stop in > AFL: > > > */> > >
> Buy = Cross( MACD(), Signal() );> > > > > >
> > priceatbuy=0;> > > > > > > > for( i
= 0; i < BarCount; i++ )> > > > {> > >
> if( priceatbuy == 0 && Buy[ i ] )
> > > > priceatbuy = BuyPrice[ i
];> > > > > > >
> if( priceatbuy > 0 && SellPrice[
i ] > 1.1 * priceatbuy )> > >
> {> > >
> Sell[ i ] = 1;> >
> > SellPrice[ i ] = 1.1 *
priceatbuy;> > > >
priceatbuy = 0;> > > > }>
> > > else> > >
> Sell[ i ] = 0;> >
> > }> > > > > > > > Best
regards,> > > > Tomasz Janeczko> > > >
amibroker.com> > > > ----- Original Message ----- >
> > > From: "jwilsonp2a" <<A
href="">j1wilson@x...>> > > > To:
<<A
href="">amibroker@xxxxxxxxxxxxxxx>>
> > > Sent: Thursday, October 23, 2003 9:04 AM> > > >
Subject: [amibroker] trailing stop question from new user> > >
> > > > > > > > > > > > >
> > Hi,> > > > > > > > > > I am
trying to implement a two tiered stop loss, one part > being >
> > a > > > > > trailing stop, the other a fixed
stop. I want a 3% trailing > stop > > > if > >
> > > I am at least 10% profitable, else I want a fixed stop loss
> > > price.> > > > > > > > >
> I thought I had it, but can't quite figure out how to > utilize a
> > > > > variable in the ApplyStop(2,x,3,true,false)
command. It is > > > the "x" I > > > > > just
showed that needs to be a 1 to enable, or a 0 to > disable.>
> > > > > > > > > Here is a portion of my
code:> > > > > > > > > >
==================================================> > > > >
.> > > > > .> > > > > .> >
> > > BuyPrice = Max(BuySTOP,Low);> > > > >
SellPrice = Min(SellSTOP,High);> > > > > > > >
> > profit_ten_percent = (((High - BuyPrice)/BuyPrice) >=
0.10);> > > > > enable_stop =
IIf(profit_ten_percent,1,0);> > > > > > > >
> > ApplyStop(2,enable_stop,3,True,False);> > > > >
Sell = Cross(SellPrice,Low);> > > > >
==================================================> > > > >
> > > > > It's the "enable_stop" variable that fouls this
up. Is this > > > strategy > > > > > even
possible? I would greatly appreciate any help on this.> > > >
> > > > > > Thank you, Jim> > > > >
> > > > > > > > > > > > >
> > > > > > > Send BUG REPORTS to <A
href="">bugs@x...> > > > > Send
SUGGESTIONS to suggest@x...> > >
> > -----------------------------------------> > > >
> Post AmiQuote-related messages ONLY to: > <A
href="">amiquote@xxxxxxxxxxxxxxx >
> > > > (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)>
> > > > --------------------------------------------> >
> > > Check group FAQ at: > > > <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > > > > > > > > > Your use of Yahoo!
Groups is subject to > > > <A
href="">http://docs.yahoo.com/info/terms/
> > > > > > > > > > > > >
> >> > > > > > > > > >
> > Send BUG REPORTS to bugs@x...>
> > Send SUGGESTIONS to <A
href="">suggest@x...> > >
-----------------------------------------> > > Post
AmiQuote-related messages ONLY to: <A
href="">amiquote@xxxxxxxxxxxxxxx >
> > (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)>
> > --------------------------------------------> > > Check
group FAQ at: > <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > > > > > Your use of Yahoo! Groups is subject to
> <A
href="">http://docs.yahoo.com/info/terms/
> > > > > > > >
>------------------------ Yahoo! Groups Sponsor
---------------------~-->Buy Ink Cartridges or Refill Kits for your HP,
Epson, Canon or LexmarkPrinter at MyInks.com. Free s/h on orders $50 or
more to the US & Canada.<A
href="">http://www.c1tracking.com/l.asp?cid=5511<A
href="">http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM---------------------------------------------------------------------~->Send
BUG REPORTS to <A
href="">bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
<A
href="">suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: <A
href="">amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to <A
href="">http://docs.yahoo.com/info/terms/
---Outgoing mail is certified Virus Free.Checked by AVG
anti-virus system (<A
href="">http://www.grisoft.com).Version: 6.0.530
/ Virus Database: 325 - Release Date:
10/25/2003
Yahoo! Groups Sponsor
ADVERTISEMENT
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|