logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Patrick  
#1 Posted : Friday, April 1, 2005 6:20:08 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Is there a way to make the Expert Advisor to only show the first long/short signal, not all of them? Yes, there is, but it is fairly complex. It requires that your Expert formulas be reworked into what we tend to call a "flip-flop" construction. Here are two samples of this sort of construction: 2 state: bc:=Cross(C,Mov(C,20,S)){buy signal condition}; sc:=Cross(Mov(C,20,S),C){sell signal condition}; trade:=If( bc=1, 1, If(sc=1, 0, PREV)); cross( trade= x, 0.5) 3 state: bc:=C > Mov(C,20,S)+1{enter long condition}; be:=Cross(Mov(C,20,S),C){close long condition}; sc:=C < Mov(C,20,S)-1{enter short condition}; se:=Cross(C,Mov(C,20,S)){close short condition}; trade:=If( bc=1, 1, If(sc=1, -1, If((be AND PREV=1) OR (se AND PREV=-1),0,PREV))); Cross( trade= x, 0.5) You will need to change the Trade=X, in the above formulas to Trade= 1, Trade= -1, or Trade= 0, depending on the condition you are defining. As you can see these are rather involved ... Note: The PREV function used in these formulas is required, and it has the drawback of causing the calculation to be relatively slow.
henry1224  
#2 Posted : Saturday, April 2, 2005 2:41:14 PM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
If you have the Power Pivots Plus Add-on here is a way to get the first signal without having to use the Prev Function and slowing down your explorations Symbols Long Entry LE:=H>Ref(HHV(H,20),-1); LX:=Ref(H>Ref(HHV(H,20),-1),-1); SE:=L<Ref(LLV(L,20),-1); SX:=Ref(L<Ref(LLV(L,20),-1),-1); B:=ExtFml("PowerPivots.SysEval",LE,LX,SE,SX,"!@#$#@!"); B>0 AND Ref(B,-1)<=0 Short Entry LE:=H>Ref(HHV(H,20),-1); LX:=Ref(H>Ref(HHV(H,20),-1),-1); SE:=L<Ref(LLV(L,20),-1); SX:=Ref(L<Ref(LLV(L,20),-1),-1); B:=ExtFml("PowerPivots.SysEval",LE,LX,SE,SX,"!@#$#@!"); B<0 AND Ref(B,-1)>=0 Long Exit LE:=H>Ref(HHV(H,20),-1); LX:=Ref(H>Ref(HHV(H,20),-1),-1); SE:=L<Ref(LLV(L,20),-1); SX:=Ref(L<Ref(LLV(L,20),-1),-1); B:=ExtFml("PowerPivots.SysEval",LE,LX,SE,SX,"!@#$#@!"); B=0 AND Ref(B,-1)>0 Short Exit LE:=H>Ref(HHV(H,20),-1); LX:=Ref(H>Ref(HHV(H,20),-1),-1); SE:=L<Ref(LLV(L,20),-1); SX:=Ref(L<Ref(LLV(L,20),-1),-1); B:=ExtFml("PowerPivots.SysEval",LE,LX,SE,SX,"!@#$#@!"); B=0 AND Ref(B,-1)<0
Jose  
#3 Posted : Friday, April 8, 2005 1:20:13 AM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Another way to get rid of redundant Buy & Sell signals, without resorting to the PREV function: MetaStock -> Tools -> Indicator Builder -> New -> Copy and paste complete formula between "---8<---" lines. [code:1:3325922c2b] ==================== System trade signals ==================== ---8<-------------------------- { System trade signals } { ©Copyright 2005 Jose Silva } { For personal use only } { http://www.metastocktools.com } { Note on simultaneous entry/exit on same bar: #1 Ignore: entry/exit signals cancel each other; #2 Preference given to: new entry if currently Short, new exit if currently Long.} { Signals reference example } entry:=C>Mov(C,21,E); exit:=C<Mov(C,10,E); { User inputs } plot:=Input("Signals: [1]Clean, [2]All, [3]Trade binary",1,3,1); choose:=Input("Simultaneous entry/exit: [1]Ignore, [2]Preference",1,2,1); delay:=Input("Entry and Exit delay",-1,5,0); { Initialize plot } Init:=Cum(IsDefined(entry+exit))=1; { #1 - Ignore entry/exit on same bar } x:=ValueWhen(1,entry-exit<>0,entry-exit); long:=x=1 AND (Alert(x<>1,2) OR Init); short:=x=-1 AND (Alert(x<>-1,2) OR Init); signals1:=long-short; binary1:=ValueWhen(1,signals1<>0,signals1); { #2 - Preference to first entry/exit } long:=entry AND (Alert(entry=0,2) OR Init); short:=exit AND (Alert(exit=0,2) OR Init); binary2:=ValueWhen(1,long-short<>0,long-short); long:=binary2=1 AND (Alert(binary2<1,2) OR Init); short:=binary2=-1 AND (Alert(binary2>-1,2) OR Init); signals2:=long-short; { Select #1 or #2 } binary:=If(choose=1,binary1,binary2); signals:=If(choose=1,signals1,signals2); { Plot in own window } Ref(If(plot=2,entry,0),-delay); Ref(If(plot=1,signals, If(plot=2,-exit,binary)),-delay) ---8<-------------------------- [/code:1:3325922c2b] jose '-) http://www.metastocktools.com
Users browsing this topic
Guest (Hidden)
Similar Topics
Re: How to stop redundant buy & sell signals (Formula Assistance)
by newbie 10/19/2005 6:25:35 PM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.