Error

 Previous Topic Next Topic
 valentino #1 Posted : Friday, October 2, 2015 1:43:22 PM(UTC) Rank: NewbieGroups: Registered Users, Subscribers, Unverified UsersJoined: 10/2/2015(UTC)Posts: 2 Good morning to all, I would like to have the possibility to get the HHV value when a certain condition happens. For example when the close is > of the open. If I use the HHV function like this HHV(Close, C>O), the system returns this error: "This variable or expression must contain only constant data". Is there a trick to solve this problem, or to have the possibility to use a variable constant?   Thank you   Valentino
 Wanna join the discussion?! Login to your Discussions forum accountor Register a new forum account.
 MS Support #2 Posted : Friday, October 2, 2015 3:22:38 PM(UTC) Rank: Advanced MemberGroups: Moderators, Registered, Registered Users, SubscribersJoined: 10/8/2010(UTC)Posts: 1,953Thanks: 91 timesWas thanked: 155 time(s) in 150 post(s) Hello, When the close is greater than the open, you want to look for the highest high value of what exactly? How far back do you want to look for this highest high value?
 valentino #3 Posted : Friday, October 2, 2015 3:47:10 PM(UTC) Rank: NewbieGroups: Registered Users, Subscribers, Unverified UsersJoined: 10/2/2015(UTC)Posts: 2 Hello, in the case of the formula, the condition C>O is just an example, I would like to have the value of the highest close of the period where every day the condition of Close > Open has been verified. That is I want to have from the function the Highest close of the period where the condition has always been true. In this case the periods field couldn't be a constant, but it depends from the number of consecutive days where the condition (c>O), has been always true. In the case of the formula hhv( DATA ARRAY, PERIODS ), the periods must be a constant. But I need a variable condition...
 MS Support #4 Posted : Friday, October 2, 2015 5:29:00 PM(UTC) Rank: Advanced MemberGroups: Moderators, Registered, Registered Users, SubscribersJoined: 10/8/2010(UTC)Posts: 1,953Thanks: 91 timesWas thanked: 155 time(s) in 150 post(s) You might be able to use HighestSince instead, such as: HighestSince(1,C > O,C)
 Guest #5 Posted : Saturday, October 3, 2015 9:34:24 AM(UTC) Rank: MemberGroups: Guests Joined: 5/6/2007(UTC)Posts: 25 Thank you: it works.
 mstt #6 Posted : Monday, October 5, 2015 11:25:22 PM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, SubscribersJoined: 7/25/2005(UTC)Posts: 1,042Was thanked: 57 time(s) in 54 post(s) There is a solution for situations where a variable Periods parameter is required while still being recognized as a constant by MetaStock. Here's what the code for an Exponential Moving Average might look like. VarPds:= {your definition of variable periods} ; Mov(C,LastValue(VarPds+PREV-PREV),E); My understanding of this specific configuration is that some small errors can appear in the result with some functions (e.g. Exponential Moving Average in particular). The method is used by all of the MS11 Adaptive Indicator series. To test the two PREV-method variations plot the following indicator on several charts, or run an exploration using Cum(A) and Cum(B) in separate columns to identify charts returning occasional different values for some charts The variation below does not introduce small errors. VarPds:= {your definition of variable periods} ; Mov(C,LastValue(VarPds+PREV*0),E); {EMA Variable Periods Indicator Check} A:=Mov(C,LastValue(10+PREV-PREV),E); B:=Mov(C,LastValue(10+PREV*0),E); A; B; {EMA Variable Periods Exploration Check} {colA} A:=Mov(C,LastValue(10+PREV-PREV),E); Cum(A); {colB} B:=Mov(C,LastValue(10+PREV*0),E); Cum(B); A better solution is to use the 188KB Forum DLL as it accepts variable Periods parameters. The proprietary MSTT DLL has an EMA function that allows fractional Periods - quite useful at times.As always, DLL solutions run much faster than PREV-based solutions. Hope this helps. Roy 1 user thanked mstt for this useful post. MS Support on 10/6/2015(UTC)
 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.