Дополнительный функционал:
- Фиолетовым цветом рисуются бары повышающиеся (open < close) внутри медвежьей тенденции;
- Светло-зеленым цветом рисуются бары понижающиеся (open > close) внутри бычьей тенденции;
- В дополнительной области под графиком рисуется общая тенденция зеленым - bull, красным - bear в виде гистограммы с значением 1 или -1.
Пример:
Код: Выделить всё
function Initialize()
{
IndicatorName = "EvgeBars";
AddInput("Input", Inputs.Candle);
PriceStudy = false;
AddSeries("BuySell", DrawAs.Custom, Color.Green, AxisType.ZeroBased);
AddSeries("Bear", DrawAs.Custom, Color.Red, AxisType.Default, true, Axes.Parent);
AddSeries("Bull", DrawAs.Custom, Color.Green, AxisType.Default, true, Axes.Parent);
AddSeries("BearPoor", DrawAs.Custom, Color.Magenta, AxisType.Default, true, Axes.Parent);
AddSeries("BullPoor", DrawAs.Custom, Color.LawnGreen, AxisType.Default, true, Axes.Parent);
AddGlobalVariable("Last", Types.Boolean, false);
}
function Evaluate()
{
//evge 04.03.2016 http://alfadirect4.ru
Bear = Input.Low[0];
Bull = Input.High[0];
BearPoor = Input.Low[0];
BullPoor = Input.High[0];
var H = Input.High[1];
var L = Input.Low[1];
if (Input.Close[0] > H)
{
Bull.DrawHistogram(Bear);
Last = true;
}
else if (Input.Close[0] < L)
{
Bear.DrawHistogram(Bull);
Last = false;
}
else
{
if (Last)
{
if (Input.Open[0] < Input.Close[0])
Bull.DrawHistogram(Bear);
else
BullPoor.DrawHistogram(Bear);
} else
{
if (Input.Open[0] > Input.Close[0])
Bear.DrawHistogram(Bull);
else
BearPoor.DrawHistogram(Bull);
}
}
if (Last)
BuySell = 1;
else
BuySell = -1;
if (BuySell > 0)
BuySell.DrawHistogram(Color.Green);
else
BuySell.DrawHistogram(Color.Red);
}