Names default to Here(1); dt = Current data table(); cnames = dt << get column names( "string"); If( !(contains(cnames,"Date") & contains(cnames, "Close")), Throw() ); dt << New Column( "EMA12", Numeric, "Continuous", Format( "Fixed Dec", 12, 3 ), Formula( If( Row() > 12, Lag( :EMA12, 1 ) + (:Close - Lag( :EMA12, 1 )) * (2 / (12 + 1)), Row() == 12, Summation( i = Row() - 11, Row(), :Close[i] ) / 12 ) ) ); dt << New Column( "EMA26", Numeric, "Continuous", Format( "Fixed Dec", 12, 3 ), Formula( If( Row() > 26, Lag( :EMA26, 1 ) + (:Close - Lag( :EMA26, 1 )) * (2 / (26 + 1)), Row() == 26, Summation( i = Row() - 25, Row(), :Close[i] ) / 26 ) ) ); dt< :Signal, :MACD - :Signal ) ) ); dt << New Column( "Bear", Numeric, "Continuous", Format( "Fixed Dec", 12, 4 ), Formula( If( :MACD <= :Signal, :MACD - :Signal ) ) ); If( contains(cnames, "High") & Contains(cnames, "Low"), gb = dt << Graph Builder( Size( 695, 520 ), Show Control Panel( 0 ), Graph Spacing( 6 ), Variables( X( :Date ), Y( :Close ), Y( :High, Position( 1 ) ), Y( :Low, Position( 1 ) ), Y( :EMA12, Position( 1 ) ), Y( :EMA26, Position( 1 ) ), Y( :MACD ), Y( :Signal, Position( 2 ) ), Y( :Bull, Position( 2 ) ), Y( :Bear, Position( 2 ) ) ), Relative Sizes( "Y", [225 150] ), Elements( Position( 1, 1 ), Line( X, Y( 1 ), Y( 4 ), Y( 5 ), Legend( 4 ) ), Area( X, Y( 2 ), Y( 3 ), Legend( 8 ), Area Style( "Range" ) ) ), Elements( Position( 1, 2 ), Line( X, Y( 1 ), Y( 2 ), Legend( 13 ) ), Bar( X, Y( 3 ), Y( 4 ), Legend( 11 ) ) ), SendToReport( Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "Moving Average Convergence Divergence MACD - on limited data" )} ), Dispatch( {}, "Date", ScaleBox, {Interval( "Day" ), Inc( 7 ), Minor Ticks( 0 ), Label Row( Show Major Grid( 1 ) )} ), Dispatch( {}, "Close", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ), Dispatch( {}, "MACD", ScaleBox, {Add Ref Line( 0, "Dashed", "Medium Dark Red", "", 4 ), Label Row( Show Major Grid( 1 ) )} ), Dispatch( {}, "400", ScaleBox, {Legend Model( 4, Properties( 0, {Line Color( 0 )}, Item ID( "Close", 1 ) ), Properties( 1, {Line Color( 35 )}, Item ID( "EMA12", 1 ) ), Properties( 2, {Line Color( 37 )}, Item ID( "EMA26", 1 ) ) ), Legend Model( 8, Properties( 0, {Line Color( 1 ), Fill Color( 32 ), Transparency( 0.3 )}, Item ID( "High..Low", 1 ) ) ), Legend Model( 13, Properties( 0, {Line Color( 37 )}, Item ID( "MACD", 1 ) ) ), Legend Model( 11, Properties( 0, {Fill Color( -248181 )}, Item ID( "Bull", 1 ) ), Properties( 1, {Fill Color( 35 )}, Item ID( "Bear", 1 ) ), Properties( -1, {Transparency( 0.6 )}, Item ID( "Dif", 1 ) ) )} ), Dispatch( {}, "graph title", TextEditBox, {Set Text( "Hi Lo Range, Close and Market Indicators" )} ), Dispatch( {}, "Y title", TextEditBox, {Set Text( "Hi Lo Range, Close" )} ), Dispatch( {}, "Y 1 title", TextEditBox, {Set Text( "MACD, Signal & Histogram" )} ), Dispatch( {}, "400", LegendBox, {Legend Position( {4, [0, 1, 2], 8, [-1], 13, [3, 4], 11, [-1, -1]} ), Position( {0, 1, 2, -1, 3, 4, -1, -1} )} ) ) ), //else gb = dt << Graph Builder( Size( 695, 520 ), Show Control Panel( 0 ), Graph Spacing( 6 ), Variables( X( :Date ), Y( :Close ), Y( :EMA12, Position( 1 ) ), Y( :EMA26, Position( 1 ) ), Y( :MACD ), Y( :Signal, Position( 2 ) ), Y( :Bull, Position( 2 ) ), Y( :Bear, Position( 2 ) ) ), Relative Sizes( "Y", [225 150] ), Elements( Position( 1, 1 ), Line( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 4 ) ) ), Elements( Position( 1, 2 ), Line( X, Y( 1 ), Y( 2 ), Legend( 13 ) ), Bar( X, Y( 3 ), Y( 4 ), Legend( 11 ) ) ), SendToReport( Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "Moving Average Convergence Divergence MACD - on limited data" )} ), Dispatch( {}, "Date", ScaleBox, {Interval( "Day" ), Inc( 7 ), Minor Ticks( 0 ), Label Row( Show Major Grid( 1 ) )} ), Dispatch( {}, "Close", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ), Dispatch( {}, "MACD", ScaleBox, {Add Ref Line( 0, "Dashed", "Medium Dark Red", "", 4 ), Label Row( Show Major Grid( 1 ) )} ), Dispatch( {}, "400", ScaleBox, {Legend Model( 4, Properties( 0, {Line Color( 0 )}, Item ID( "Close", 1 ) ), Properties( 1, {Line Color( 35 )}, Item ID( "EMA12", 1 ) ), Properties( 2, {Line Color( 37 )}, Item ID( "EMA26", 1 ) ) ), Legend Model( 13, Properties( 0, {Line Color( 37 )}, Item ID( "MACD", 1 ) ) ), Legend Model( 11, Properties( 0, {Fill Color( -248181 )}, Item ID( "Bull", 1 ) ), Properties( 1, {Fill Color( 35 )}, Item ID( "Bear", 1 ) ), Properties( -1, {Transparency( 0.6 )}, Item ID( "Dif", 1 ) ) )} ), Dispatch( {}, "graph title", TextEditBox, {Set Text( "Hi Lo Range, Close and Market Indicators" )} ), Dispatch( {}, "Y title", TextEditBox, {Set Text( "Hi Lo Range, Close" )} ), Dispatch( {}, "Y 1 title", TextEditBox, {Set Text( "MACD, Signal & Histogram" )} ), Dispatch( {}, "400", LegendBox, {Legend Position( {4, [0, 1, 2], 13, [3, 4], 11, [-1, -1]} ), Position( {0, 1, 2, -1, 3, 4, -1, -1} )} ) ) ) //end no hi lo close gb ); //end if