Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 9/24/2011(UTC) Posts: 1
|
Hello All, I am new to MetaStock and have been trying to use some of the publicly available Matestock strategies.
One of them has the following code:
haOpen:=(Ref((O+H+L+C)/4,-1) + PREV)/2;
What I do not understand is what -1 and PREV stands for. Can someone help to understand what this code will result in?
Very much appreciate your help in advance. Thanks.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Pandyav
I assume you know that the line of code you're asking about sets the OPEN price for Heikin-Ashi bar charts. Below I also list the code for the other three prices - HaCLOSE, HaHIGH and HaLOW.
HaCLOSE:=(O+H+L+C)/4; HaOPEN:=(Ref((O+H+L+C)/4,-1) + PREV)/2; HaHIGH:=Max(H,HaOPEN); HaLOW:=Min(L,HaOPEN);
The HaOPEN variable uses the Ref() function to sum the previous bar's O, H, L and C and divide that total value by 4. The "-1" means the the Ref() function looks back one bar to access the required OHLC prices. There's a very clear description of the Ref() function's syntax in the Metastock User Manual - see the MetaStock Formula Language section - a good place to look for specific information on any MS function.
PREV specifies the previous bar's value of the variable currently being defined - in this case the PREVious value of HaOPEN. So the current value of HaOPEN is set by the combined sum of the PREVious value of HaOPEN and the previous bar's value of (O+H+L+C)/4 divided by 2.
Another way of writing the formula for HaOPEN is shown below
HaOPEN:=Wilders( Ref( (O+H+L+C)/4, -1) ,2);
This expression can also be written as
HaOPEN:=Wilders( Ref( HaCLOSE, -1) ,2);
When using this last definition of HaOPEN you must first define HaCLOSE or Metastock will report an error. Why Wilders() or an exponential Mov() function can be used to eliminate PREV from the basic HaOPEN definition is another question for another time.
Roy
|
|
|
|
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.