на основе вашего индикатора из темы viewtopic.php?f=27&t=341&start=50#p2026
не подскажете , почему фрактал не суммирует показания?
Код: Выделить всё
function Initialize()
{
IndicatorName = "1";
PriceStudy = true;
AddInput("Input", Inputs.Candle);
AddSeries("W", DrawAs.Custom, Color.Blue);
AddSeries("H", DrawAs.Custom, Color.MediumTurquoise );
AddSeries("L", DrawAs.Custom, Color.Lime);
AddParameter("Delta", 1.5);
AddGlobalVariable("peakbar", Types.Int, 0);
AddGlobalVariable("troughbar", Types.Int, 0);
AddGlobalVariable("Direction", Types.Int, 0);
AddGlobalVariable("hi", Types.Double, 0);
AddGlobalVariable("lo", Types.Double, 0);
AddGlobalVariable("hibar", Types.Int, 0);
AddGlobalVariable("lobar", Types.Int, 0);
}
function Evaluate()
{
if (CurrentIndex < 2)
{
lo = Input.Low[0]; //First min candle for Low
hi = Input.High[0]; //First max candle for High
}
else
{
double delta = 0.0005*Delta;
//Detected Local max and Local min
if(Input.High[0] >= hi)
{
hi = Input.High[0];
hibar = CurrentIndex;
}
if(Input.Low[0] <= lo)
{
lo = Input.Low[0];
lobar = CurrentIndex;
}
if(Direction >= 0)
{
if(Input.High[0] > (1 + delta)*lo)
{
Direction = -1;
hi = Input.High[0];
hibar = CurrentIndex;
troughbar = lobar;
W[lobar-CurrentIndex] = lo;
L[lobar-CurrentIndex] = lo;
}
}
if(Direction <= 0)
{
if(Input.Low[0] < (1 - delta)*hi)
{
Direction = 1;
lo = Input.Low[0];
lobar = CurrentIndex;
peakbar = hibar;
W[hibar-CurrentIndex] = hi;
H[hibar-CurrentIndex] = hi;
}
}
H.DrawArrowDown(Color.Magenta, LineStyles.Solid, 7, Color.Magenta,1);
L.DrawArrowUp(Color.SpringGreen, LineStyles.Solid, 7, Color.SpringGreen, 1);
W.DrawLine(Color.Blue,Line.Solid,1);
if (CurrentIndex == MaxIndex)
{
if (troughbar > peakbar)
W[hibar-CurrentIndex] = hi;
if (troughbar < peakbar)
W[lobar-CurrentIndex] = lo;
}
}
}
Ваш индикатор суммирующий показания
Код: Выделить всё
function Initialize()
{
IndicatorName = "1_SUMMA";
AddInput("Input", Inputs.Candle);
AddSeries("D", DrawAs.Custom, Color.Green, false);
AddSeries("U", DrawAs.Custom, Color.Red, false);
AddShadowSeries("Sum", DrawAs.Custom, Color.SpringGreen);
AddSeries("SUp", DrawAs.Custom, Color.Lime, false);
AddSeries("SDown", DrawAs.Custom, Color.HotPink, false);
AddGlobalVariable("SumUp", Types.Double, 0);
AddGlobalVariable("SumDown", Types.Double, 0);
AddGlobalVariable("LX", Types.Long, 0);
AddGlobalVariable("HX", Types.Long, 0);
PriceStudy = false;
}
function Evaluate()
{
var I = MY.1(Input, 1.5);
var Lx = 0;
var Hx = 0;
var Ly = 0.0;
var Hy = 0.0;
for (var x = 0; x < 999; x++)
{
if (I["L"][x] > 0) { Lx = CurrentIndex - x; Ly = I["L"][x]; }
if (I["H"][x] > 0) { Hx = CurrentIndex - x; Hy = I["H"][x]; }
if (Lx != 0 && Hx != 0) break;
}
if (Lx == 0 && Hx == 0 ) return;
if (BarDate(0) != BarDate(1))
{
SumUp = 0; SumDown = 0;
}
if ( Lx > Hx )
D[1] = Hy - Ly;
else
U[1] = Hy - Ly;
if (HX != Hx || LX != Lx)
{
HX = Hx;
LX = Lx;
if (Hx > Lx) SumUp += Hy - Ly;
if (Hx < Lx) SumDown += Hy - Ly;
}
SUp[0] = SumUp;
SDown[0] = SumDown;
Sum[0] = SumDown + SumUp;
}