MC BETA 2.1.909 indicator compiles but does not work

Questions about MultiCharts and user contributed studies.
valabhi
Posts: 45
Joined: 25 Jun 2007

MC BETA 2.1.909 indicator compiles but does not work

Postby valabhi » 03 Jul 2007

i have an indicator to show EMA angle value which suppose to print on right side of ema,but does not print angle value. it only draws ema line. this indicator works perfactly ok in TS. it does not give any error whilecompiling
guest

User avatar
Kate
Posts: 758
Joined: 08 Dec 2006

Postby Kate » 04 Jul 2007

Please post a source code of the indicator and screenshots of TS8 and MultiCharts.

valabhi
Posts: 45
Joined: 25 Jun 2007

indicator compile but will not print angle value

Postby valabhi » 06 Jul 2007

Kate;
attached is the source code file . i do not have TS to give u screenshot valabhi


current bar
// PreviousEMA = Average(EMA[1],Lookback); //Another possible choice here
// PreviousEMA = EMA[Lookback]; //No smoothing - just use the EMA of n bars ago


If EmaAngleFactor <> 0 then //This is only here to prevent a Divide by 0 error is case EmaAngleFactor hapThis indicator normalizes the EMA angle for all types of data compression and displays
the EMA Angle using DougM_TX's nifty DMCWriteText function. }


Inputs: Price(Close),
EmaLength(34),
UpColor(Cyan), // You can also use RGB(128,128,128) for colors
DownColor(Red), // Get the RGB values from Format Indicator, Color "Other"
Lookback(2), // How far back you want to go to calculate the angle
VerticalDisplay(70), // Adjust where you want the angle to display
HorizOffset(2); // The number of bars to right of last bar on chart

Variables: EMA(0),
PreviousEMA(0),
EmaSlope(0),
EmaAngle(0),
EmaAngleFactor(1),
SessionDuration(0),
TicNum(10),
IntervalSize(3),
IntervalSizeRaw(0),
NBarsVolTick(5),
PlotColor(green);


// *****************************************************************************************************
//This calculates the "EmaAngleFactor", an adjustment to normalize the angle across various time frames
// I got this piece of code from another indicator dealing with EMA angle, but I don't know who the original author is
IntervalSize = BarInterval;
TicNum = pricescale/minmove;

if DataCompression = 2 then
begin {day}
SessionDuration = AbsValue(TimeToMinutes(Sess1EndTime)-TimeToMinutes(Sess1StartTime));
IntervalSizeRaw = SessionDuration*60;
EmaAngleFactor = SquareRoot(IntervalSizeRaw/180);
end else if DataCompression = 3 then
begin {week}
SessionDuration = AbsValue(TimeToMinutes(Sess1EndTime)-TimeToMinutes(Sess1StartTime));
IntervalSizeRaw = SessionDuration*60*5;
EmaAngleFactor = SquareRoot(IntervalSizeRaw/180);
end else if DataCompression = 4 then
begin {month}
SessionDuration = AbsValue(TimeToMinutes(Sess1EndTime)-TimeToMinutes(Sess1StartTime));
IntervalSizeRaw = SessionDuration*60*22;
EmaAngleFactor = SquareRoot(IntervalSizeRaw/180);
end else if DataCompression = 0 then
begin {volume and tick}
if TimeToMinutes(T)-TimeToMinutes(T of NBarsVolTick bars ago) > 1 then
SessionDuration = TimeToMinutes(T)-TimeToMinutes(T of NBarsVolTick bars ago)
else SessionDuration = 1;
IntervalSizeRaw = 60*SessionDuration/NBarsVolTick;
EmaAngleFactor = SquareRoot(IntervalSizeRaw/180);
end else if DataCompression = 1 then
begin {minutes}
IntervalSizeRaw = IntervalSize*60;
EmaAngleFactor = SquareRoot(IntervalSizeRaw/180);
end;

// *******************************************************************************************************
// - Calculating the EMA, Slope and Angle -
// The Angle is calculated by taking the difference between the current EMA value
// and a previous EMA value, in this case the median EMA. We take the slope and use
// ArcTangent to find the Angle in degrees of that slope.

EMA = XAverage(Price,EmaLength);

// Using the median EMA smoothes out the calculation a bit, but other things could be used here
PreviousEMA = Median(EMA[1], Lookback); //Use EMA[1], so the lookback starts from the previous bar, not pens to equal 0
EmaSlope = ((EMA - PreviousEMA)*TicNum) / EmaAngleFactor
else EmaSlope = 1;

EmaAngle = ArcTangent(EmaSlope);


// ********************************************************************************************************
// Plot Statements

If EmaAngle >= 0 then PlotColor = UpColor
else if EmaAngle < 0 then PlotColor = DownColor ;

Plot1(Ema,"Ema", PlotColor );
//Plot2(EmaAngle);
//Plot3(0);

// Displaying the text - note that is only displays in subgraph 1
condition1 = DMCWriteText(-999999, 0,"EMA Angle ", _VDL(VerticalDisplay), PlotColor, 0, HorizOffset);
condition1 = DMCWriteText(-999999, 0, numtostr(EmaAngle, 0) + "°", _VDL(VerticalDisplay-4), PlotColor, 0, HorizOffset);


//***********************************************************************[/code]


Return to “MultiCharts”