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

Notification

Icon
Error

Options
Go to last post Go to first unread
rk1235  
#1 Posted : Tuesday, August 2, 2005 2:32:33 AM(UTC)
rk1235

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/31/2005(UTC)
Posts: 7

Hi, I am new to the forum.Can someone help me to resolve the following? Normally an expert advisor plots all the buy and sell symbols, on whole of the chart ( using latches). Is it possible to plot only the last occurrence of the signals, e.g. last buy and only the last selll symbol? Thanx in advance.
wabbit  
#2 Posted : Tuesday, August 2, 2005 10:41:27 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Before spending time coding this one (it can be done reasonably easily), may I ask why would you want to only display the last indicators? If it is to speed up the computing process, then I suggest that it will actually take longer to compute all of the triggers and then find the last ones to display, than just computing and displaying all of the trigger points in the first place. If it is to clean up the chart because there are too many symbols, there are better ways to see the chart more clearly. If you really would like to see this being done, just reply here with your reasons and we can help. wabbit :D
rk1235  
#3 Posted : Tuesday, August 2, 2005 3:06:55 PM(UTC)
rk1235

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/31/2005(UTC)
Posts: 7

First of all , thanx Wabbit for coming forward for help........... The idea is to clean up the chart and see only the symbols of last two signals( one buy and one sell) ........... I tried doing it this way...........for long signal........ LE:=entry cond; LX:= exit condition; a1:=Cum(1); A2:=LastValue(A1-BarsSince(le)); B:= ExtFml("ForumDll.Latch",LE,LX,0,0); ln:=B=1 AND Ref(B,-1)=0; ss:=b=0 AND Ref(b,-1)=1; If(A1<A2,BarsSince(A1>=A2),ln) similarly for short signal.............. But somehow, sometimes only one signal appears and sometimes both signals are seen........... I am really stuck up...........
Jose  
#4 Posted : Wednesday, August 3, 2005 7:38:02 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)
Using Patrick' Latch, try something like this: [code:1:e35e18baaf] LastEntry:=entry and Cum(entry)=LastValue(Cum(entry)); LastExit:=exit and Cum(exit)=LastValue(Cum(exit)); LastEntry-LastExit [/code:1:e35e18baaf] Alternatively, use this MS indicator code: [code:1:e35e18baaf] ==================== System trade signals ==================== ---8<-------------------------- { System trade signals v2.5 } { ©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.} { Entry/Exit conditions - crossover 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,2); delay:=Input("Entry and Exit delay",-1,5,0); { Initialize } Init:=Cum(IsDefined(entry+exit))=1; { #1 - Ignore entry/exit on same bar } bin1:=ValueWhen(1,entry-exit<>0 OR Init, entry-exit); long:=bin1=1 AND (Alert(bin1<>1,2) OR Init); short:=bin1=-1 AND (Alert(bin1<>-1,2) OR Init); { Remove all signals except last two } long:=long and Cum(long)=LastValue(Cum(long)); short:=short and Cum(short)=LastValue(Cum(short)); signals1:=long-short; { #2 - Preference to first entry/exit } long:=entry AND (Alert(entry=0,2) OR Init); short:=exit AND (Alert(exit=0,2) OR Init); bin2:=ValueWhen(1,long-short<>0 OR Init, long-short); long:=bin2=1 AND (Alert(bin2<1,2) OR Init); short:=bin2=-1 AND (Alert(bin2>-1,2) OR Init); { Remove all signals except last two } long:=long and Cum(long)=LastValue(Cum(long)); short:=short and Cum(short)=LastValue(Cum(short)); signals2:=long-short; { Select #1 or #2 } binary:=If(choose=1,bin1,bin2); 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:e35e18baaf] jose '-) http://www.metastocktools.com .
rk1235  
#5 Posted : Wednesday, August 3, 2005 8:32:34 AM(UTC)
rk1235

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/31/2005(UTC)
Posts: 7

oh, thank you very much Jose !! After applying your logic, it's working fine now.......... finally the code which worked OR the way I could apply is: LE:={Entry Condition}; LX:={Entry Condition}; B:= ExtFml("ForumDll.Latch",LE,LX,0,0); ln:=B=1 AND Ref(B,-1)=0; ss:=b=0 AND Ref(b,-1)=1; long:=ln AND Cum(ln)=LastValue(Cum(ln)); short:=ss AND Cum(ss)=LastValue(Cum(ss)); If(long-short>0,1,0) ---->>{for plotting last buy} If(long-short<0,1,0) ---->>{for plotting last sell} Did I do it correctly Or is there any simpler way of doing it.........? I am yet to appreciate / understand the power of the cum function........it is still unclear to me...............
Jose  
#6 Posted : Wednesday, August 3, 2005 9:35:19 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)
rk1235 wrote:
Did I do it correctly Or is there any simpler way of doing it.........?
If it works for you, then you've done it correctly. 8:-) jose '-) http://metastocktools.com/#metastock
wabbit  
#7 Posted : Wednesday, August 3, 2005 11:20:56 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
rk1235 wrote:
LE:={Entry Condition}; LX:={Entry Condition}; B:= ExtFml("ForumDll.Latch",LE,LX,0,0); ln:=B=1 AND Ref(B,-1)=0; ss:=b=0 AND Ref(b,-1)=1; long:=ln AND Cum(ln)=LastValue(Cum(ln)); short:=ss AND Cum(ss)=LastValue(Cum(ss)); If(long-short>0,1,0); If(long-short<0,1,0);
Unless you really want a 1 plotted for the last buy and 1 plotted for the last sell, might I suggest you use a slightly more simple finish: LE:={Entry Condition}; LX:={Entry Condition}; B:= ExtFml("ForumDll.Latch",LE,LX,0,0); ln:=B=1 AND Ref(B,-1)=0; ss:=b=0 AND Ref(b,-1)=1; long:=ln AND Cum(ln)=LastValue(Cum(ln)); short:=ss AND Cum(ss)=LastValue(Cum(ss)); long-short; which will plot 1 for the last entry and -1 for the last sell. or, you could recall the latch to show the trade: LE:={Entry Condition}; LX:={Entry Condition}; B:= ExtFml("ForumDll.Latch",LE,LX,0,0); ln:=B=1 AND Ref(B,-1)=0; ss:=b=0 AND Ref(b,-1)=1; long:=ln AND Cum(ln)=LastValue(Cum(ln)); short:=ss AND Cum(ss)=LastValue(Cum(ss)); ExtFml("ForumDll.Latch",long,short,0,0); These are just suggestions... Use your imagination and the Users Manual to come up with something spectacular! wabbit :D
rk1235  
#8 Posted : Wednesday, August 3, 2005 2:41:06 PM(UTC)
rk1235

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/31/2005(UTC)
Posts: 7

Thanx Wabbit for your response. However, the method suggested by you : LE:={Entry Condition}; LX:={Entry Condition}; B:= ExtFml("ForumDll.Latch",LE,LX,0,0); ln:=B=1 AND Ref(B,-1)=0; ss:=b=0 AND Ref(b,-1)=1; long:=ln AND Cum(ln)=LastValue(Cum(ln)); short:=ss AND Cum(ss)=LastValue(Cum(ss)); long-short; will plot, of course, two symbols, but both of the same colour, same direction and on the same side of the plot. So to have both the symbols of diferent color and diff direction, those are to be plotted separately. However, improvement on my earlier code is : LE:={Entry Condition}; LX:={Entry Condition}; B:= ExtFml("ForumDll.Latch",LE,LX,0,0); ln:=B=1 AND Ref(B,-1)=0; ss:=b=0 AND Ref(b,-1)=1; long:=ln AND Cum(ln)=LastValue(Cum(ln)); short:=ss AND Cum(ss)=LastValue(Cum(ss)); long--------------------->>>>>>>>> for buy signal short ------------------>>>>>>>>>>>for sell sig
wabbit  
#9 Posted : Wednesday, August 3, 2005 2:47:26 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Quote:
will plot, of course, two symbols, but both of the same colour, same direction and on the same side of the plot
try it out! its only one indicator... Yes, it will be in one colour, but on different sides of the zero line! plus 1 = buy minus 1 = sell Rationale or Truth Table:
Buy Sell buy-sell
0 0 0
1 0 1
0 1 -1
1 1 0 {bad code/logic if both trigger on same day!??}
wabbit :D
rk1235  
#10 Posted : Wednesday, August 3, 2005 2:49:12 PM(UTC)
rk1235

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/31/2005(UTC)
Posts: 7

by the way, Wabbit, what are the other methods(mentioned by you above in your first reply) to make the chart more clear..........
wabbit  
#11 Posted : Wednesday, August 3, 2005 2:56:29 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
if you are using the code in an expert advisor: [list:a362634aba][*:a362634aba]you can utilise the ribbon instead of symbols on the chart itself [*:a362634aba]use small symbols without text notes, just have yourself a "symbols code language" e.g. small red arrow below the bar pointing up means this.... a small blue circle above the price bar means that ..... etc[/list:u:a362634aba] if you are using the code in an indicator on the chart: [list:a362634aba][*:a362634aba]you can scale indicators using lastvalue(highest(h)) and lastvalue(lowest(l)) etc. [*:a362634aba]some neat effects can be made using histogram values multiplied by low values, colouring in lines along the price bars when in a trade etc [*:a362634aba]overlaying an indicator without a scale can be useful at times[/list:u:a362634aba] There are a multitude of ways.... just have a read of the manual and experiment post a chart that you think is too busy and we might be able to suggest better ways to display the information and/or clean up the view wabbit :D
rk1235  
#12 Posted : Wednesday, August 3, 2005 3:56:24 PM(UTC)
rk1235

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 7/31/2005(UTC)
Posts: 7

THANX WABBIT........!!! YOUR TIPS ARE REALLY USEFULL.........
Users browsing this topic
Guest (Hidden)
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.