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

Notification

Icon
Error

Options
Go to last post Go to first unread
edwin4400  
#1 Posted : Tuesday, June 28, 2005 12:38:31 AM(UTC)
edwin4400

Rank: Member

Groups: Registered, Registered Users
Joined: 6/22/2005(UTC)
Posts: 29
Location: Singapore

Hi, I know the system tester allows daily, weekly, monthly bar testing. However, if I want to test a 3 day bar, how do I go about it? I have tried setting the chart periodicity using "OTHER" to 3, creating a 3day bar chart. And system test this chart using tester periodicity=current but it doesnt work. Anyone has any idea how to go about this? Regards, Edwin
wabbit  
#2 Posted : Tuesday, June 28, 2005 7:23:17 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)
hmmmm. tricky one here! There might a number of ways around this. The obvious method is to code up a system looking at groups of three bars, using something along the lines of: if (mod(cum(1),3)=0, then something, else something different) otherwise I guess you might have to use the downloader to "create" your own data file from an existing stock, programatically grouping the data together. I might not have the immedate solution, but I hope this gives you some ideas of how to tackle the problem? wabbit :D
edwin4400  
#3 Posted : Tuesday, June 28, 2005 9:30:03 AM(UTC)
edwin4400

Rank: Member

Groups: Registered, Registered Users
Joined: 6/22/2005(UTC)
Posts: 29
Location: Singapore

Hi Wabbit, Can you explain how to use the downloader to create specific periodicity such as 3 day in 1 bar? This is the first time I see the mod function. Will go and try it out and let u know. Thanks, Edwin
wabbit  
#4 Posted : Tuesday, June 28, 2005 9:49:24 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)
It would be a long process, and each stock woul dhave to be handled individually, but you could open a stock, export the data to Excel, then use the Excel functions to select the opening price on the first bar of a grouping, the close of the last bar of the grouping, the highest and lowest bars in the group, and sum the volume. Ave the data as text file and import back into the downloader and view in MS. This system is like one already used to modify stock data to create Heikin-Ashi candlesticks See : http://forum.equis.com/viewtopic.php?t=735 and/or https://www.metastock.co...tor/200404.html#RobertMc I personally think that programatically grouping the days might be simpler! Hope this helps. wabbit :D
wabbit  
#5 Posted : Tuesday, June 28, 2005 11:31:47 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)
Try: prd:=3; x:=Mod(Cum(1),prd); grpO:=ValueWhen(1,x=1,O); grpH:=If(x=0,HHV(H,prd),PREV); grpL:=If(x=0,LLV(L,prd),PREV); grpC:=ValueWhen(1,x=0,C); You should then be able to do 'normal' calculations using the 'grouped' data. Note the bars are jsut grouped in consecutive groups, with no regard for weekends, holidays etc. I will be interested to see if this works for you. Please post your completed code when you are done. wabbit :D
edwin4400  
#6 Posted : Tuesday, June 28, 2005 3:04:09 PM(UTC)
edwin4400

Rank: Member

Groups: Registered, Registered Users
Joined: 6/22/2005(UTC)
Posts: 29
Location: Singapore

Hi Wabbit, Need yr expertise on this one: I tried your formula, it only return 3day bar after a 3rd daily bar is computed. However, if the 4th daily bar is present, then the 2nd 3day bar should have the same OHLC as the 4th daily bar. Somehow I still cannot get it to work, can u kindly take a look: prd:=3; x:=Mod(Cum(1),prd); grpO:=ValueWhen(1,x=1,O); grpH:=If(x=0,HHV(H,prd),If(Mod(Cum(1),2)=1,H,HHV(H,2))); grpL:=If(x=0,LLV(L,prd),If(Mod(Cum(1),2)=1,L,LLV(L,2))); grpC:=If(x=0,ValueWhen(1,x=0,C),If(Mod(Cum(1),2)=1,C, ValueWhen(1,Mod(Cum(1),2)=0,C))); grpO;grpH;grpL;grpC; THanks, Edwin
wabbit  
#7 Posted : Wednesday, June 29, 2005 12:42:05 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)
Sorry Edwin, I cannot fully grasp what you are trying to achieve, so I will try to explain as I go along, my line of thinking. 1. You want to collect the bars into groups of three, hence we set the "periodicity" for want of a better word here: prd:=3; 2. Next we want to actually do the group testing. We use the code below, that will return a value of 1 on the first bar in the grouped data, 2 on the second, etc etc and 0 on the last bar. x:=Mod(Cum(1),prd); I think up to here we are in agreeance? 3. Now the opening price for the group is the opening price for the first bar in the group (that is when 'x' variable equals 1). We find this bar and return the Open price on this bar as the Open price for the grouped data: grpO:=ValueWhen(1,x=1,O); Now as the first bar on the chart also happens to be the first bar in the grouped data, this opening price is valid from the time when Cum(1)=1 i.e. the whole chart. This means the open price in the very first group is identified and displayed in the very first group on the chart. grpH:=If(x=0,HHV(H,prd),PREV); grpL:=If(x=0,LLV(L,prd),PREV); grpC:=ValueWhen(1,x=0,C); Now all of these values dont get calculated until the group used for there calculation has been "completed" This means, although the open price is displayed in the group for which it is 'valid', the remaining data is 'delayed' until the next group. To have all of the OHLC data displayed in the group for which it is actually valid, use the Ref() lookahead function to get the data from into the future and plot it in the group for which it pertains. I think might solve your problem???? prd:=3; x:=Mod(Cum(1),prd); grpO:=ValueWhen(1,x=1,O); grpH:=If(x=0,HHV(H,prd),PREV); grpL:=If(x=0,LLV(L,prd),PREV); grpC:=ValueWhen(1,x=0,C); grpO; Ref(GrpH,+prd-1); Ref(GrpL,+prd-1); Ref(GrpC,+prd-1); Notice there is now data for the first 'prd' bars on the chart, but not for the last group of chart data is the grouping is not complete i.e. the code will cannot predict the future, the group until it is complete. [I think there might be a better way to chieve this, but I cannot think of it righ now, but if I do, I will post again.] It has forward looking referencing, so use it with it caution! Hope this helps wabbit :D
edwin4400  
#8 Posted : Thursday, June 30, 2005 2:23:43 AM(UTC)
edwin4400

Rank: Member

Groups: Registered, Registered Users
Joined: 6/22/2005(UTC)
Posts: 29
Location: Singapore

Hi Wabbit, Thanks for your time and explanation. I was trying to access the forum last night but keep popping HTTP gateway error. Nonetheless, appreciate your analysis. Actually, what I am looking for is something similar to the weekly bars. Say today is monday, although there is no 5daily bars to compute a weekly bar, the weekly bar is actually represented by the monday bar. If it is tuesday, then the weekly bar is open from monday open high from highest high of monday or tuesday low from lowest low of monday or tuesday close from tuesday close However, in the first formula you posted, the 1st and 2nd daily bar does not give any OHLC until the 3rd daily bar is computed. Hope I have made it clear. Thanks, Edwin
wabbit  
#9 Posted : Thursday, June 30, 2005 3:09:36 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)
OK... I think I can do that - I will have a look for you tonight. wabbit :D
wabbit  
#10 Posted : Thursday, June 30, 2005 1:39:59 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)
Here we go again... Let's see if I have it right this time... prd:=3; x:=Mod(Cum(1),prd);
edwin4400 wrote:
open from monday open
To do this, I think we need to set grpO as the open on Monday. This value will remain the same on Tuesday and Wednesday and be reset on Thursday to Thursday's opening price. grpO:=ValueWhen(1,x,O);
edwin4400 wrote:
high from highest high of monday or tuesday
To do this,we set grpH as the high on Monday. If the high on Tuesday is higher than this value then use the higher value, if the high on Wednesday is higher again then use this value. Reset the value on Thursday to be the high on that day. grpH:=If(x,H,If(H>PREV,H,PREV));
edwin4400 wrote:
low from lowest low of monday or tuesday
We do the same thing for the lows as we did for the highs. grpL:=If(x,L,If(L<PREV,L,PREV));
edwin4400 wrote:
close from tuesday close
This had me stumped for a little while until I had a couple of glasses of red wine, then it came to me in a blinding flash of logic - - this is just the close of each bar! grpC:=C; So if I have this right, the whole formula should be: prd:=3; x:=Mod(Cum(1),prd); grpO:=ValueWhen(1,x,O); grpH:=If(x,H,If(H>PREV,H,PREV)); grpL:=If(x,L,If(L<PREV,L,PREV)); grpC:=C; grpO; grpH; grpL; grpC; Let me know how this goes... if need ve, we can work on it a little more tomorrow or over the weekend. wabbit :D P.S. Sorry about all the PREVs - I hope you have a fast machine!
edwin4400  
#11 Posted : Friday, July 1, 2005 6:14:14 AM(UTC)
edwin4400

Rank: Member

Groups: Registered, Registered Users
Joined: 6/22/2005(UTC)
Posts: 29
Location: Singapore

Hi Wabbit, I tried the latest codes for 3period BAR creation but the result are not right. prd:=3; x:=Mod(Cum(1),prd); grpO:=ValueWhen(1,x,O); {I think this is okay for getting the group open} grpH:=If(x,H,If(H>PREV,H,PREV)); grpL:=If(x,L,If(L<PREV,L,PREV)); {The return value for group High and group L is now the daily high and daily low which is incorrect, I think PREV is assumed to be 0 on the first daily bar. I tried to use ref(H,-1) but still unable to get what I need.} grpC:=C; {Your red wine is working fine!!:)} One thing I learned is that I can actually breakdown each syntax and debug individually to see if the arguments are correct. This is fun!! I will try to work on the grpH and grpL again tonight. Let me know if u have more inputs. Red wine all the way :smt030 Thanks, Edwin
wabbit  
#12 Posted : Sunday, July 3, 2005 12:46:22 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)
How did you go with the problem, Edwin? I must admit, I havent even looked at this over this weekend - SWMBO had me 'lifting and shifting' in the garden all weekend! wabbit :D
edwin4400  
#13 Posted : Sunday, July 3, 2005 3:40:24 PM(UTC)
edwin4400

Rank: Member

Groups: Registered, Registered Users
Joined: 6/22/2005(UTC)
Posts: 29
Location: Singapore

Hi Wabbit, I am no where near that working formula. Perhaps I am trying to watch a weekly indicator on a daily chart. Although this is a 3day bar that I am trying to generate. Regards, Edwin
wabbit  
#14 Posted : Wednesday, July 6, 2005 1:47:19 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)
grpH:=If(x=1,H,If(H>PREV,H,PREV)); If I am reading what I have written correctly then this should say: when x=1 (the first day in the group) assign the days HIGH to grpH then on the second day, if that days high is higher than the value stored in grpH then assign the larger value to the variable, otherwise just leave the stored value as it is then on the third day, if that days high is higher than the value stored in grpH then assign the larger value to the variable, otherwise just leave the stored value as it is and so on until the group is completed, then when x=1 (the first day in the group) assign the days HIGH to grpH then .... On my charts it appear to work as I think you intended. Try changing the prd value to something larger, like 10 to see a more dramatic effect. wabbit :D P.S. If this isnt right, please post an annotated chart with the actual code used, otherwise I am very quickly running out of ideas! [EDIT] [size=24:2351d3a759][color=red:2351d3a759]EUREKA[/color]![/size:2351d3a759] prd:=10; x:=Mod(Cum(1),prd); grpO:=ValueWhen(1,x,O); grpH:=If(x=1,H,If(H>PREV,H,PREV)); grpL:=If(x=1,L,If(L<PREV,L,PREV)); grpC:=C; grpO; grpH; grpL; grpC; The difference was where I was working with one script in MS and had posted another one here on the board! {NUMPTY!} YOU NEED TO SPECIFY x=1 IN THE CRITERIA \\:D/ \\:D/
edwin4400  
#15 Posted : Wednesday, July 6, 2005 3:26:31 PM(UTC)
edwin4400

Rank: Member

Groups: Registered, Registered Users
Joined: 6/22/2005(UTC)
Posts: 29
Location: Singapore

Hi Wabbit, I had make another revision. The Group open value must also include x=1 condition. Here the final piece for plotting a 3Day Group bar on a daily chart: prd:=3; x:=Mod(Cum(1),prd); grpO:=ValueWhen(1,[color=blue:51cc2664e6]x=1[/color],O); grpH:=If(x=1,H,If(H>PREV,H,PREV)); grpL:=If(x=1,L,If(L<PREV,L,PREV)); grpC:=C; grpO; grpH; grpL; grpC; Thanks, Edwin :lol: :lol: :lol: :lol: :lol: :lol:
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.