PureBytes Links
Trading Reference Links
|
thanks tomasz fo your
help!
How do I count number of bars since
sell/buy condition?
Thanks
juan
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Tomasz Janeczko
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Wednesday, July 09, 2003 11:58
AM
Subject: Re: [amibroker] Help with stop
loss condition - please !
Hello,
You can not use ApplyStop that way.
This is so because stops are applied not at the formula
execution stage but
later and apply stop is just a "SWITCH" that turns on/off
built-in stop handling.
Therefore you can not change mode of stop via
if-else.
The code that you have used:
if
(LastValue(BarIndex())<=3){ApplyStop(stopTypeTrailing,stopModePercent,4,True,False);
//4%}else{ApplyStop(stopTypeTrailing,stopModePoint,BuyPrice,True,False);}
is actually equivalent to just single line:
<FONT
size=3>ApplyStop(stopTypeTrailing,stopModePoint,BuyPrice,True,False);
As last value of barindex is almost ALWAYS greater than
3
LastValue(BarIndex() ) gives you the NUMBER OF BARS in
currently backtested symbol.
What you can do is to change the AMOUNT of stop on
bar-by-bar basis
but you can NOT change the mode (from stopModePoint to
stopModePercent)
on bar-by-bar basis.
ApplyStop( stopTypeTrailing, stopModePercent /* this must be
constant */, 4 /* this CAN BE VARIABLE */, True );
Best regards,Tomasz
Janeczkoamibroker.com
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
<A title=emarco@xxxxxxxxxxxxxxx
href="">emarco
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Wednesday, July 09, 2003 4:28
PM
Subject: [amibroker] Help with stop
loss condition - please !
<FONT face="Times New Roman"
color=#000000 size=3> <FONT
face=Batang color=#0000ff size=2>Hi!
I am coding a stop loss that
changes after 3 bars (when I go short or buy a
contract).
The stop loss is not executed
after 3 bars at buy price.<FONT face=Batang color=#0000ff
size=2>....any idea why?
If also want to include sellprice
in the code , how should i fit in?
<FONT face=Batang color=#0000ff
size=2>THANKS
<FONT face=Batang color=#0000ff
size=2>
<FONT face="Times New Roman"
color=#000000 size=3>Buy = Cross(EMA(C,13),EMA(C,150));Sell =
Cross(EMA(Close,50),Close);Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);Short
= Cross(EMA(C,150),EMA(C,13));Cover =
Cross(Close,EMA(Close,50));Short=ExRem(Short,Cover);Cover=ExRem(Cover,Short);if
(LastValue(BarIndex())<=3){ApplyStop(stopTypeTrailing,stopModePercent,4,True,False);
//4%}else{ApplyStop(stopTypeTrailing,stopModePoint,BuyPrice,True,False);}PositionValue
= MarginDeposit = 1;PositionSize = 1;PointValue =
50;Send BUG REPORTS to
bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: 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 the <A
href="">Yahoo! Terms of Service.
Send
BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: 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 the <A
href="">Yahoo! Terms of Service.
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.
|