PureBytes Links
Trading Reference Links
|
Even closer .....
Using two different stops doesn't seem to change the result, but
I'll stick with that just in case. In fact with 2 stops I can just
leave the larger one fixed.
I found a solution for the problem with the trailing stop
not "sticking." I used an HHV value to fix it, and then had to add
another variable to make the first bar of each buy work correctly.
Here is the code that seems to work for a buy with SL of 0.005
switching to a trailing stop of 0.002 once a profit of 0.003 is
reached.
Buy = Cross(EMA(Close,12),EMA(Close,26));
Short = Cross(EMA(Close,26),EMA(Close,12));
Sell = Short;
Cover = Buy;
PositionSize=100000;
Currentbuy=Ref(Buy,0);
priceatbuy=ValueWhen(Buy,BuyPrice,1);
Var1=IIf(((HHV(High,BarsSince(Buy))>=priceatbuy+0.003) AND
Currentbuy<1),0.002,0);
ApplyStop(0,2,0.005,True,False);
ApplyStop(2,2,Var1,True,False);
Which solves half of my problem. :) Now I have to find a way to add
a corresponding SL for Shorts (easy) and have both of them work at
the same time (tricky). And I'm almost out of "play" time this
weekend. :(
Thanks again for all the help. I think I have enough to finish
working this thing out now.
James
--- In amibroker@xxxxxxxxxxxxxxx, "Gary A. Serkhoshian"
<serkhoshian777@xxxx> wrote:
> Dave is right on. Just use two different stops, and when you
don't want to use one of the two change the stop amount to something
that will never trigger. LastValue() also literally takes the
lastvalue of the array and populates that value back in time which,
to Dave's point, does not make it dynamic.
>
> Regards,
> Gary
>
> Dave Merrill <dmerrill@xxxx> wrote:
> Sorry, I'm not trying any of this, which probably means I'm
wrong... It seems to me that if Gary's right about needing to use
LastValue on the stopType ApplyStop parameter, that says it can't
change over time. Check out the help for LastValue. You'll see that
it returns the single last value in an array, so your stop is always
one type or the other; it doesn't change dynamically.
>
> If I'm right about that, you'd need two different stops, one a
stop loss and one a trailing stop, whose parameters you'd change to
make one effectively the active one.
>
> Dave
> I changed the volitility parameter to "True." But when I do an
> exploration I see the same thing ... when the price drops below 30
> pips of profit it reverts to the 50 pip stop loss (within a single
> trade).
>
> James
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Dave Merrill" <dmerrill@xxxx>
> wrote:
> > check your parameters for ApplyStop! look at Volatile (this is
> straight out
> > of the help; put your cursor somewhere within the word ApplyStop
> and press
> > F1 to see it):
> >
> > ApplyStop( type, mode, amount, exitatstop, volatile = False )
> > volatile -
> > decides if amount (or distance) (3rd parameter) is sampled at
the
> trade
> > entry and remains fixed during the trade (Volatile = FALSE - old
> behaviour)
> > or if can vary during the trade (Volatile = TRUE) (allows single
> line
> > Chandelier exit implementation)
> >
> > dave
> >
> > Getting closer and closer ...
> >
> > Gary: I used the lastvalue function as you suggested and it
> > eliminated the "bad argument" error. Thanks!
> >
> > Dave: You were right that I wasn't using "Buyprice" correctly.
I
> was
> > able to get what I wanted by making a new
variable "priceatbuy."
> > Thanks!
> >
> > And I tweaked a couple of other things. But now I have another
> > problem I'm trying to work through. To restate what I'm trying
to
> > do ... I want a 50 pip stoploss, but once I have 30 pips of
> > profit I want to switch to a 20 pip trailing stop. Here is the
> code
> > in it's current state:
> >
> > Buy = Cross(EMA(Close,12),EMA(Close,26));
> > Short = Cross(EMA(Close,26),EMA(Close,12));
> > Sell = Short;
> > Cover = Buy;
> > PositionSize=100000;
> > priceatbuy=ValueWhen(Buy,BuyPrice,1);
> > Var1=IIf(High>=(priceatbuy+0.003),2,0);
> > Var2=IIf(High>=(priceatbuy+0.003),0.002,0.005);
> > ApplyStop(LastValue(Var1),2,Var2,True,False);
> >
> > My problem is that the trailing stop doesn't stick. If the
profit
> > for a trade goes back below 30 pips it reverts to the 50 pip
stop
> > loss. What I want to backtest is that the trailing stop (once
> > triggered) remains throughout that particular trade. Then the
> next
> > trade starts with the 50 pip simple stop loss. Any ideas?
> >
> > All help is truly appreciated!
> >
> > James
> Yahoo! Groups Sponsor
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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.
>
>
> ---------------------------------
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
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 http://docs.yahoo.com/info/terms/
|