PureBytes Links
Trading Reference Links
|
I am having a hard time with that.
( exit == 1 AND Close[i] < Ref (LLV(Close[i],10), -1) )
For some reason I just can't make that work. I tried this also
( exit == 1 AND Close[i] < Ref (LLV(Close[i],10), [i-1]) )
but it didn't work either... I wonder what is wrong with that code.
Louis
2008/2/26, Louis Préfontaine <rockprog80@xxxxxxxxx>:
Hi Tuzo,
Thanks again for your reply.
I tried to add a selling condition but just didn't know where to put it exactly. I tried after
if( exit == 0 AND
High[ i ] >= ( 1 + FirstProfitTarget * 0.01 ) * priceatbuy)
to add something like AND close>100 (just to try) and even tried close[i]>100 and it didn't work... What did I do wrong?
I think you are right when you say I need to catch up on programming. I hope Howard's book will help me for that but I am really better to learn by myself than by getting a huge 1000 pages C++ book. But if you think it might be worth it, I don't reject that idea...
I will try to do as Brian said to me and try to keep my eyes open and see where the gold is. So far you helped me a lot and that's also gold to me. Thanks!
Louis
2008/2/26, tuzo_wilson <j.tuzo.wilson@xxxxxxxxx>:
--- In amibroker@xxxxxxxxxxxxxxx, "Louis Pr�fontaine" <rockprog80@xxx> wrote:
If you are using the boolean value (IsInTrade) then you need to reset it when you exit the trade. See near the end of the formula. Although if you now understand the buyatprice == 0 then you could revert to the canned example.
> Moreover, I don't know how to add other selling rules to that
(where to put those rules in the code) and I don't understand
To add different sell logic, you can modify the "AND" portion of the if statements after if( exit == ...
> the
meaning of this part Sell[ i ] = exit + 1; // mark appropriate exit code
This sets the type of sell signal. It (exit + 1) will be either 3 or 4 which corresponds to hitting a profit target or hitting a trailing stop (IIRC).
I don't know how other people feel but IMO, you may want to take a look at some simple intro programming tutorials separate from AB. Between general programming, array processing, and the specifics of AFL there is a lot to take in. Of course your mileage may vary.
Tuzo
Buy = RSI (14)<30;
Sell = 0; // the system will exit // 50% of position if FIRST PROFIT TARGET stop is hit
// 50% of position is SECOND PROFIT TARGET stop is hit // 100% of position if TRAILING STOP is hit FirstProfitTarget = 10; // profit SecondProfitTarget = 25; // in percent TrailingStop = 15; // also in percent
isInTrade = False; priceatbuy=0; highsincebuy = 0; exit = 0; for( i = 0; i < BarCount; i++ ) {
if ( NOT isInTrade AND Buy[ i ] )
{
isInTrade = True;
priceatbuy = BuyPrice[ i ]; }
if( isInTrade ) { highsincebuy = Max( High[ i ], highsincebuy ); if( exit == 0 AND
High[ i ] >= ( 1 + FirstProfitTarget * 0.01 ) * priceatbuy)
{ // first profit target hit - scale-out exit = 1; Buy[ i ] = sigScaleOut; } if( exit == 1 AND
High[ i ] >= ( 1 + SecondProfitTarget * 0.01 ) * priceatbuy ) { // second profit target hit - exit exit = 2;
SellPrice[ i ] = Max( Open[ i ], ( 1 + SecondProfitTarget *
0.01 ) * priceatbuy ); } if( Low[ i ] <= ( 1 - TrailingStop * 0.01 ) * highsincebuy ) { // trailing stop hit - exit
exit = 3; SellPrice[ i ] = Min( Open[ i ], ( 1 - TrailingStop * 0.01) * highsincebuy ); }
if( exit >= 2 ) { Buy[ i ] = 0; Sell[ i ] = exit + 1; // mark appropriate exit code exit = 0;
priceatbuy = 0; // reset price highsincebuy = 0;
isInTrade = False; // not in a trade any more
} } } SetPositionSize( 50, spsPercentOfPosition * ( Buy == sigScaleOut )); // scale out 50% of position
Short=0; Cover=0; /// /// /// /// ///
__._,_.___
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
__,_._,___
|