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

RE: tough coding problem



PureBytes Links

Trading Reference Links


<FONT face=Arial color=#008080 
size=4>HHV20:=HHV(HIGH,20);
<FONT face=Arial color=#008080 
size=4>HHV2:=IF(HIGH<HHV20 AND HIGH>PREV, HIGH, PREV);
<FONT face=Arial color=#008080 
size=4>HHV3D:=IF(HHV2=HIGH OR REF(HHV2,-1)=REF(HIGH,-1)
<FONT face=Arial color=#008080 
size=4> OR REF(HHV2,-2)=REF(HIGH,-2),1,0);
<FONT face=Arial color=#008080 
size=4>HHV3D;
<FONT face=Arial color=#008080 
size=4> 
Will 
this work?
<FONT face=Arial color=#008080 
size=4> 
<FONT face=Arial color=#008080 
size=4>neo
 

  <FONT face=Tahoma 
  size=2>-----Original Message-----From: 
  owner-metastock@xxxxxxxxxxxxx [mailto:owner-metastock@xxxxxxxxxxxxx]On 
  Behalf Of Tom SprungerSent: Saturday, December 29, 2001 9:03 
  AMTo: metastock@xxxxxxxxxxxxxSubject: tough coding 
  problem
  I am working on a tough coding problem.  Here is what I 
  am trying to do.
   
  Either the day before yesterday, today, or 
  today, the High must be the "second-highest high" of 
  the past 20 days. 
  
  I can not figure out how to find out if the the 
  "second-highest high of the last 20 days" has occured 
  within the last 3 days.  I can easily find the <FONT 
  size=2>highest high but not the second highest high. 
  Equis support gave a solution which allows me to do the above 
  only in an expert or exploration, but not in the system tester. Basically the 
  solution is
  "You can use the HHVBars() function to find out how many bars ago the 
  highest value was.  Buy putting that function inside the LastValue() 
  function, this number becomes a constant which you can then use inside other 
  functions.  From there, you can Ref() back to that point and find the 
  highest value before that one and the highest value since.  This will 
  give you the second highest value during the 20 bar period.  Then you can 
  compare it to the most recent three bars to see if it matches one of 
them."
  " this technique will not work with historical values on an 
  expert, though it could be used to give you alerts on new data.  The 
  reason it is limited this way is because of the LastValue() function.  
  This always refers looks at the last bar loaded and returns the value whatever 
  is being referenced has on that bar.  Therefore,  in the example I 
  used below, LastValue will return the number of bars since the 20 day high was 
  made, as calculated on the last bar of data loaded.  This value is the 
  only number ever used, regardless of the bar the formula is being calculated 
  on."
  Anyone have any other clever ideas on doing this?
  Thanks
  Tom