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

Notification

Icon
Error

Options
Go to last post Go to first unread
weird  
#1 Posted : Saturday, February 4, 2006 9:17:15 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

I am trying to tackle another coding issue by breaking the issues into chunks. How to do certain things is more likely to be due to lack of coding knowledge on my part. As you may know from my previous post I trying to develop code without using lastvalue function, and am hitting some roadblocks, without even getting out of the driveway :eek: Basically here I am trying to determine the number of bars (no restrictions on the number of bars) of the second last occurrence of price equaling the value of the highest high value in the last 20 periods. The chart is AIX, weekly. UserPostedImage Any thoughts on how to do this. I am thinking I am probably missing something simple here. regards Dave
weird  
#2 Posted : Sunday, February 5, 2006 1:09:19 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

This is my current attempt, yet I am unable to eliminate the lastvalue function, pk:=LastValue(HHV(H,20)); pk1:=BarsSince(H=pk); constpk1:=LastValue(pk1); pk2:=Ref(BarsSince(H=pk),-constpk1-1)+1; {Total Bars to Peak 2} pk1+1+pk2; On line 4, I thought I could possibly use the forum dll, to avoid using the Lastvalue function in line 3, however the results were not what I expected. Of interest though is that's Brad's ASI dll produces the wanted result, pk:=LastValue(HHV(H,20)); pk1:=BarsSince(H=pk); pk2:=ExtFml("ASI.REF",pk1,-pk1-1)+1; {Total Bars to Peak 2} pk1+1+pk2; Instead of limiting the LastValue command to the last bar on the chart, would it be possible to have a similar function which allowed a constant to be created on the current bar of calculation not just the last bar? I guess some of my questions may be due to my lack of understanding of MFL , and of the potential problems that this could cause. Comments most welcome.
weird  
#3 Posted : Sunday, February 5, 2006 2:52:21 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

UserPostedImage The problem I am having with removing the lastvalue from the first couple of lines is that it seems not want to use the value defined intially as a constant value. Instead of getting 30 bars, I get 34 which is the HHV after this, and not using the values I am trying to tell it to use. :? While I don't expect to see pretty straight lines across the length of the chart due to the dynamic nature of the indicator recalculating itself at every bar , I would expect the last value to equal 30 at this point of time on this chart. regards Dave
Jose  
#4 Posted : Sunday, February 5, 2006 12:52:19 PM(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)
Take a look at the BarsSince Nth event indicator from MetaStockTools.com. "BarsSince Nth event - counts bars since Nth event (last event, 2nd last, etc), with multiple output choice." jose '-)
kanellop  
#5 Posted : Sunday, February 5, 2006 4:00:42 PM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

Dear Jose, Yesterday, Night with my Local Time, in 03:35 Local Time i see that interesting Message of Weird. I had a feeling that you will answer in that Message!!! Well, i am in a little trouble with that Message. First to understand it! Second, i want to ask you Dear Jose, if you believe in the Charts, of Weird, when exist the Highest High Value for example of the Last 20 Days, can someone create a Formula with Time Expressions, for to find (If finally happen), changes in Prices 10%, above or below from the HHV(H, 20). Let's tell you an Example. Suppose for now in a Stock, the HHV(H, 20) is at 50$ , which happen that, in the Date of 05-02-2006. I want to found a Formula to show me change a 10% (If finally happen), above or below of the HHV(H, 20) in the Field of the coming 3 Months, i mean from the 05-02-2006 until exactly 05-5-2006. Suppose now, that the coming Days, we have a New High of the Formula HHV(H, 20), for example in the Date of 10-02-2006. Then it is possible to exist the First Expression, and to create and a New Expression to occur in the same Formula for to, show me change a 10% (If finally happen) above or below of the HHV(H, 20) in the Field of the coming 3 Months, i mean from the 10-02-2006 until exactly 10-5-2006. What to believe for a thing like that? Can exist into Metastock? Kind Regards, George Kanellopoulos.
Jose  
#6 Posted : Sunday, February 5, 2006 10:31:37 PM(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)
Sorry George, but if I can't understand your request in the first 30 seconds, then unfortunately I have to get back to a busy work schedule. jose '-)
kanellop  
#7 Posted : Sunday, February 5, 2006 11:16:12 PM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

Dear Jose, Hello! I received your Message. I will try to fix it, again! Suppose that we have a Stock or Stocks (doesn't matter) in which we had put the Following Formula to exist in our Chart. HHV(H, 20) which is exactly the Highest High Value, High, of the Last 20 Periods(Not Days). Suppose for now, that in a Stock, the HHV(H, 20) is at 50$ , which happen that, in the Date of 05-02-2006. Now, we want to happen the following thing. I want to found a Formula for when, exist a change of 10% (If finally happen), above or below of the HHV(H, 20) in the Field of the coming 3 Months, i mean from the 05-02-2006 until exactly 05-5-2006, then suppose, when happen the HHV(H, 20) (Suppose in the Date of 05-02-2006) and does not exist Higher Price from the Highest High Value of (H, 20) that happen in the Date of the 05-02-2006, until exactly the Date (After 3 Months) 05-05-2006, then, if finally occur that, then the Formula to receive the Price (1), if does not happen the change, to receive Price(0). Dear Jose until now, do you believe that understand my Thought? If Yes, i will continue with another Message, when receive your Answer. Kind Regards, George Kanellopoulos.
Jose  
#8 Posted : Monday, February 6, 2006 12:09:29 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)
George, unfortunately MetaStock cannot predict the future. But if you find a way, please let us know! :) jose '-)
kanellop  
#9 Posted : Monday, February 6, 2006 12:18:30 AM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

Dear Jose, I received your Message. I agree that can not guess the Future...! I will fix my Message again with the Prices of the Past. I want to note that my Request is close with the Competition, of the High Low of a Month in which win an Amazing Person, Named, Mr Rodney Platt! So, Suppose that we have a Stock or Stocks (doesn't matter) in which we had put the Following Formula to exist in our Chart. HHV(H, 20) which is exactly the Highest High Value, High, of the Last 20 Periods(Not Days). Suppose for now, that in a Stock, the HHV(H, 20) is at 50$ , which happen that, in the Date of 05-02-2006. Now, we want to happen the following thing. I want to found a Formula for when, exist a change of 10% (If finally happen), above or below of the HHV(H, 20) in the Field of the coming 3 Months, i mean from the 05-02-2005 until exactly 05-5-2005, then suppose, when happen the HHV(H, 20) (Suppose in the Date of 05-02-2005) and does not exist Higher Price from the Highest High Value of (H, 20) that happen in the Date of the 05-02-2005, until exactly the Date (After 3 Months) 05-05-2005, then, if finally occur that, then the Formula to receive the Price (1), if does not happen the change, to receive Price(0). Dear Jose until now, do you believe that understand my Thought? If Yes, i will continue with another Message, when receive your Answer. Kind Regards, George Kanellopoulos.
Jose  
#10 Posted : Monday, February 6, 2006 1:11:54 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)
Sorry George, but multiple requests in one message (never mind in one sentence), just confuse the issue. Perhaps you can adapt this indicator to your needs: [code:1:7f682c[censored]9] { Date filter Plots +1 signal within user-input date period. For personal use only. http://www.metastocktools.com } { Date inputs } StDay:=Input("start Day",1,31,5); StMnth:=Input("start Month",1,12,2); StYear:=Input("start Year",1800,2200,2006); EnDay:=Input("end Day",1,31,5); EnMnth:=Input("end Month",1,12,5); EnYear:=Input("end Year",1800,2200,2006); { Selected date period } start:=Year()>StYear OR (Year()=StYear AND (Month()>StMnth OR Month()=StMnth AND DayOfMonth()>=StDay)); end:=Year()<EnYear OR (Year()=EnYear AND (Month()<EnMnth OR Month()=EnMnth AND DayOfMonth()<=EnDay)); period:=start AND (end OR (start AND Alert(start=0,2))); { Plot in own window } period [/code:1:7f682c[censored]9] That's all I can help with. jose '-)
kanellop  
#11 Posted : Monday, February 6, 2006 1:20:09 AM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

Dear Jose, I received your Message. I want to note that until now i have not try the Formula that you kindly, sent me, into my Metastock. I want to ask you if you understand my Last Message. I mean if you have understand what i asking for... I am a little curious if you understand it, because of the use of the English Language of my Side! Kind Regards, George Kanellopoulos.
weird  
#12 Posted : Monday, February 6, 2006 8:24:27 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

Thanks Jose, very nice bit of coding. Still hitting some of the same problem areas though :( Any ideas how I would do something like this ? UserPostedImage A continuous indicator which shows the number of bars, since prices were higher than any selected high on a chart. The following example formula does not provide what I after, as it produces the number of bars higher since the last value on the chart. value1:=lastvalue(High); barssince(H>value1); What I wish to know is the number of bars since a previous value was higher, for any and every price bar ??
weird  
#13 Posted : Monday, February 6, 2006 11:52:19 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

<Sorry for the heavy edits of the above post, just trying to get my thoughts straight ... they were abit all over the place>
Jose  
#14 Posted : Monday, February 6, 2006 10:11:21 PM(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)
W, the first thing you need to do is define the event clearly, in this case it being "price equaling the value of the highest high value in the last 20 periods". Once the event signals are clearly defined, we can then measure BarsSince Nth event - BarsSince 2nd event in the indicator example below. [code:1:7d2a332203] =================== BarsSince Nth event =================== ---8<-------------------------- { ©Copyright 2005 Jose Silva } { For personal use only } { http://www.metastocktools.com } { User inputs } NthEvent:=Input("BarsSince Nth event (1=last, 2=2nd last, etc)",1,1000,2); plot:=Input("plot: [1]BarsSince Nth event, [2]Event signals",1,2,1); { Event - price=HHV(price,20) example } prce:=H; signal:=prce=HHV(prce,20); { Count events backwards } count:=LastValue(Cum(signal))-Cum(signal)+1; { BarsSince Nth event } BarsSinceNth:= HighestSinceBars(NthEvent+1,signal,count)-1; { Plot in own window } If(plot=1,BarsSinceNth,signal) ---8<-------------------------- [/code:1:7d2a332203] jose '-)
kanellop  
#15 Posted : Monday, February 6, 2006 10:18:24 PM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

Dear Jose, Did you see my Last Message? Also i want to note something about the Code that you sent me. I put it, in a Chart into my Metastock, but i can not understand it, so well. Can you give me a New Simple Example with Formula, inside your Code (see below), for to understand it? { Date filter Plots +1 signal within user-input date period. For personal use only. http://www.metastocktools.com } { Date inputs } StDay:=Input("start Day",1,31,5); StMnth:=Input("start Month",1,12,2); StYear:=Input("start Year",1800,2200,2006); EnDay:=Input("end Day",1,31,5); EnMnth:=Input("end Month",1,12,5); EnYear:=Input("end Year",1800,2200,2006); { Selected date period } start:=Year()>StYear OR (Year()=StYear AND (Month()>StMnth OR Month()=StMnth AND DayOfMonth()>=StDay)); end:=Year()<EnYear OR (Year()=EnYear AND (Month()<EnMnth OR Month()=EnMnth AND DayOfMonth()<=EnDay)); period:=start AND (end OR (start AND Alert(start=0,2))); { Plot in own window } period Kind Regards, George Kanellopoulos.
Jose  
#16 Posted : Monday, February 6, 2006 10:35:22 PM(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)
George, you are welcome to contact me for any custom work, but I just can't take the time out of a busy work schedule to explain basic MetaStock coding in detail. My coding fee for both custom MetaStock programming and personal tuition is US$60/hr, same as Equis'. jose '-)
kanellop  
#17 Posted : Monday, February 6, 2006 10:48:04 PM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

Dear Jose, I received your Message and Thank You. Please if you like write down your E-Mail Address or send me a Private E-Mail, with your E-Mail, for to have it. George Kanellopoulos.
Capablanca  
#18 Posted : Monday, February 20, 2006 7:23:38 PM(UTC)
Capablanca

Rank:: Newbie

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

kanellop, you seem to be looking for a HHV that is 10% higher than a previous HHV correct? If so maybe something like HHV(H, 60) > 1.1*Ref(HHV(H, 20), -20) is what you're looking for. Not exactly what you requested but maybe you can modify it to suit your purposes. Weird I think I may have had a problem similar to yours but I'm not sure. It may help you to realize the formula BarsSince(HHV(H, 20=H) does not necessarily give you a value under 20. I was looking for what I thought was BarsSince(HHV(H, 10)=H) but was getting values over 10. The way around that I found was to code this: [code:1:7837b019a2]{If HHV(H, 10) = H of bar in last 10 days returns number of days back statement is most recently true else 999} a:= If(HHV(H, 10)=H, 0, If(HHV(H, 10)=Ref(H, -1), 1, If(HHV(H, 10)=Ref(H, -2), 2, If(HHV(H, 10)=Ref(H, -3), 3, If(HHV(H, 10)=Ref(H, -4), 4, If(HHV(H, 10)=Ref(H, -5), 5, If(HHV(H, 10)=Ref(H, -6), 6, If(HHV(H, 10)=Ref(H, -7), 7, If(HHV(H, 10)=Ref(H, -8), 8, If(HHV(H, 10)=Ref(H, -9), 9, 999) ) ) ) ) ) ) ) ) ); a[/code:1:7837b019a2] Extremely tedious and I'm wondering myself if there is a better way to code it. Again not what you are looking for but it may help you understand your problem. Can anyone else help?
kanellop  
#19 Posted : Monday, February 20, 2006 7:31:34 PM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

I receive your Message.I take a Look on it. I do not study it until now. Be sure that one of the Best Programmers in the Forum, named Jose Silva, check that difficult Issues and i believe that will write his Opinion to you. Kind Regards, George Kanellopoulos.
Capablanca  
#20 Posted : Monday, February 20, 2006 7:50:12 PM(UTC)
Capablanca

Rank:: Newbie

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

kanellop, if my earlier interpretation was correct another way of writing it might be ROC(HHV(H, 20), 60, %) >= 10
Users browsing this topic
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.