Welcome Features News Download Registration Support FAQ Wish list Links
Advanced stock charting and analysis program

AFL Library

This is read-only version of AFL library entry. Ability to add user formulas and comment is only available from members-only area.

Details:

Formula name: Murrey Math Price Lines
Author/Uploader: Jozsef Toth - (email hidden)
Date/Time added: 2008-03-29 18:05:18
Origin:
Keywords: Murrey Gann octave
Level: basic
Flags: indicator

DISCLAIMER: Most formulas present in AFL on-line library are submitted by the users and are provided here on an "as is" and "as available" basis. AmiBroker.com makes no representations or warranties of any kind to the contents or the operation of material presented here. We do not maintain nor provide technical support for 3rd party formulas.
Description:

http://www.murreymath.com/
http://mysite.verizon.net/bonniehill/pages/murrey.html
http://mysite.verizon.net/bonniehill/pages/w.d.gann.html

LastVisibleIndex error fixed.

Formula:

/*
//       $Archive: /AFL.root/AFL/YofaTrader/Custom/Murrey Math Price
Lines.afl.cs $           
//          $Date: 08.03.29 22:57 $         
//       $Modtime: 08.03.29 22:52 $       
//      $Revision: 15 $      
//      $Workfile: Murrey Math Price Lines.afl.cs $        
*/

ParamShowLevel=ParamList("Show harmonic levels", "1/8|1/4|1/2", 1 ); 
ParamShowLabel=ParamStyle("Show harmonic labels", styleNoLabel, styleNoLabel);

if(Status("action") ==1)  //indicator
{
    LastVisibleIndex = LastValue(Status("lastvisiblebarindex"));
    if (LastVisibleIndex > BarCount -1) //to avoid errors is case of cursor is
behind the last bar
	    LastVisibleIndex = BarCount-1;
    TotalVisibleBars = LastVisibleIndex -
LastValue(Status("firstvisiblebarindex")) + 1;
}
else
{
    LastVisibleIndex = BarCount -1;
    TotalVisibleBars = BarCount;
}

HHScreen = HHV(High, TotalVisibleBars);
LLScreen = LLV(Low,  TotalVisibleBars);
PRScreen = HHScreen[LastVisibleIndex] - LLScreen[LastVisibleIndex]; //Price
range

PriceRangeVisible = PRScreen * 1.1;
MiddleVisible = (HHScreen[LastVisibleIndex] + LLScreen[LastVisibleIndex]) /2;
HighestVisible= MiddleVisible + PriceRangeVisible / 2;
LowestVisible = MiddleVisible - PriceRangeVisible / 2;

SquareBase = 0.1953125;

if (HighestVisible > 0.390625)
    { SquareBase = 1.5625; }

if (HighestVisible > 1.5625)
    { SquareBase = 3.125; }
	
if (HighestVisible > 3.125)
    { SquareBase = 6.25; }
	
if (HighestVisible > 6.25)
    { SquareBase = 12.5; }
    
if (HighestVisible > 25)
    { SquareBase = 100; }
        	
if (HighestVisible > 250)
    { SquareBase = 1000; }
	
if (HighestVisible > 2500)
    { SquareBase = 10000; }
	
if (HighestVisible > 25000)
    { SquareBase = 100000; }

ShowLevel = 1;

PriceStep = SquareBase / 8;
while ( PriceRangeVisible / 4 <= PriceStep AND ShowLevel < 4)
{
    PriceStep = PriceStep / 8;
    ShowLevel++;
}

//Lowest,highest harmonic value to show on the panel
LowerValue  = Floor(LowestVisible  / PriceStep) * PriceStep;
HigherValue = Ceil(HighestVisible / PriceStep) * PriceStep;

Octave1PriceStep = SquareBase / 8; 
Octave2PriceStep = SquareBase / 64 ;
Octave3PriceStep = SquareBase / 512;

Harmonic = LowerValue;

//iterate from low to high values 
while( Harmonic <= HigherValue )
{
    style = styleDashed; // 1/8, 3/8, 5/8, 7/8 lines of any level
    color = colorGreen;  //1/8, 7/8
    if ((Harmonic / PriceStep) % 8 == 1 OR (Harmonic / PriceStep) % 8 == 7)
        color = colorYellow; // 3/8, 5/8
    if (ParamShowLevel != "1/8")
        style = styleNoLine;
        
    if ((Harmonic / PriceStep) % 2 == 0) // 1/4, 3/4 lines of any level
    {
        style = styleDashed;
        color = colorPink;
        if (ParamShowLevel == "1/2")
            style = styleNoLine;
    }
     
    if ((Harmonic / PriceStep) % 4 == 0) // 1/2 line of any level
    {
        style = styleDashed;
        color = colorBlue;
    }
    
    if ((Harmonic / PriceStep) % 8 == 0) // 1/1 line of Baby level
    {
        color = colorBlue;
        style = styleLine;
        if ((Harmonic / Octave3PriceStep) % 64 == 0) // 1/1 line of Minor level

        {
             style = styleThick; // 1/1 /Level Minor
        }
    }
    
    if (style != styleNoLine)  //if there is a line to plot... (avoid printing
unused labels)
    {
	    style = style + ParamShowLabel;
        Plot( Harmonic, "", color, style);
    }
    
    Harmonic = Harmonic + PriceStep;
}

Comments:

Steve
steveg1919 [at] yahoo.com
2008-04-12 17:16:14
Thanks.

I wasn't quite sure how to fix it myself.


About | Privacy | Terms of Use | Contact information
Copyright © 2001 AMIBROKER.COM