Made an indicator to plot the range, barsize and distance from the XMA in text on the chart.
It works just every now and then (seems when the XMA in part 3 of the code is crossed) the indicator give me an error: "TextID does not exist."
Code:
Code: Select all
Inputs: BarSizeColour (Darkgray),FloatH (0),FloatV (10), Decimals(0),TxtSzr(8);
// 1 BarSize ////////////////////////////////////////////////////////////////////////////////////////////////////
If BarNumber = 1 then begin
Value1 = Text_New(0, 0, 0, " ");
end;
If LastBarOnChart then begin
Value2 = Text_SetString(Value1, "BarSize " + NumToStr((High[1]-Low[1]),Decimals) + " / " + NumToStr((High-Low),Decimals));
Value2 = Text_SetColor(Value1, BarSizeColour);
Value2 = Text_Setsize(Value1, TxtSzr);
Value2 = Text_Float(Value1, FloatH, FloatV);
End;
// 2 Range /////////////////////////////////////////////////////////////////////////////////////////////////////
If BarNumber = 1 then begin
Value3 = Text_New(0, 0, 0, " ");
end;
If LastBarOnChart then begin
value4 = Text_SetString(Value3 , "Range " + NumToStr(DailyRange(1),Decimals) + " / " + NumToStr(DailyRange(0),Decimals));
value4 = Text_SetColor(Value3 , BarSizeColour);
value4 = text_setsize(Value3 , TxtSzr);
value4 = Text_Float(Value3, FloatH, FloatV+5);
End;
// 3 EMA Distance///////////////////////////////////////////////////////////////////////////////////////////////
If BarNumber = 1 then begin
value5 = Text_New(0, 0, 0, " ");
end;
vars: XMAdist(0);
XMAdist = c-(XAverage(c,20));
If LastBarOnChart then begin
value6 = Text_SetString(value5 , "XMADist " + NumToStr(XMAdist,Decimals) );
value6 = Text_SetColor(value5 , BarSizeColour);
value6 = text_setsize(value5 , TxtSzr);
value6 = Text_Float(value5 , FloatH, FloatV-5);
End;
Thanks.