[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] How 2 stop new buy signal changing value of initial stop? (AFL guru )



PureBytes Links

Trading Reference Links

Slow learner looking for AFL guru guidance or tips.

I have a buysignal which generates an InitialStop
value.

I want this InitialStop value to stay fixed until it
is crossed by the close.

At present if there are more buy signals before a sell
signal occurs then the value of the InitialStop
changes.

What code/function do I need under item # 4. below to
keep the InitialStop fixed until it is crossed by the
closing price?

If this is a case for using Loops I am totally lost
and any help/guidance would be much appreciated.

***************
code follows
***************

// #1. sample buy condition

Buy = Cross(Close, EMA (C , 10 ));

// #2. define pivot point lows as Troughs
tr1 = ValueWhen(Buy,Trough(L,1,1));
tr2 = ValueWhen(Buy,Trough(L,1,2));
tr3 = ValueWhen(Buy,Trough(L,1,3));
tr4 = ValueWhen(Buy,Trough(L,1,4));
tr5 = ValueWhen(Buy,Trough(L,1,5));
tr6 = ValueWhen(Buy,Trough(L,1,6));

// #3. set initial stop as the 2nd lowest recent
trough.
InitialStop = IIf(tr2 < tr1, tr2, 
IIf(tr3 < tr1, tr3,
IIf(tr4 < tr1, tr4,
IIf(tr5 < tr1, tr5,
IIf(tr6 < tr1, tr6, tr1 )))));

// #4. How to stop each new buy signal changing the
value of InitialStop?

//InitialStop  = Flip(Buy,Sell); // ?? Cannot use this
because I cannot define sell until I define Initial
stop.

//InitialStop = Flip(Buy,Cross(InitialStop,Close)); //
?? Cannot use this because it returns value of 1 for
Initialstop.

// #5.sell conditions
Sell = Cross(InitialStop,Close);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

Plot(C,"close",colorBlack,64);
Plot(EMA(C,10),"",colorGreen,1);
Plot(Zig(L,1),"zig",colorBlue,1);
Plot(InitialStop,"",colorBlue,1);

PlotShapes(shapeUpArrow * Buy,colorBlue,0);
PlotShapes(shapeDownArrow * Sell,colorRed,0);

*********
code ends
*********

I will post truff 3.doc to the files section to
illustrate what I wish to achieve.

Any help would be much appreciated.

ChrisB

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/