Here is the code I have written to date, it just doesn't work when I go to a different chart - I am using TickSize as the factor to space it out... bad idea.
Please help.
public static void MFDrawItem (this NinjaScript ns, NinjaScriptBase nsb, ref int dcounter, int drawtype, int panel, bool direction, string IDPrefix, int currbar, int barsback, double drawony, double drawoffset, Brush brush, string txtstrval1, string txtstrval2)
{
double lbloffset = 0;
// double defaultoffset; // ticks below the Y value to draw the arrow
// double drawTicksOffset;
double prevarrowoffset;
double ts;
// bool nextarrow = false; // used to increment the arrow if we get 2 in 1 bar in same direction
ts = (double) Instrument.Instruments[0].MasterInstrument.TickSize;
// drawTicksOffset = drawoffset * ts; // ticks below the Y value to draw the arrow
// defaultoffset = 40.0 * ts;
// lbloffset = defaultoffset;
if (direction) // long direction
{
if (LastUpArrowBar == currbar)
{
ns.Print ("another up arrow on bar <" + currbar + ">");
prevarrowoffset = LastUpArrowOffset;
} else {
prevarrowoffset = 0.0;
}
switch(drawtype)
{
case 0: // draw a dot
lbloffset = drawony - ((drawoffset * ts) + (ts * .03)) + prevarrowoffset;
DrawingTools.Draw.Dot (nsb, (IDPrefix+currbar.ToString()+dcounter.ToString()), true, barsback, lbloffset, brush);
if (txtstrval1 != "" || txtstrval2 != "")
lbloffset -= (ts * .07);
dcounter++;
break;
case 1: // draw an diamond
lbloffset = drawony - ((drawoffset * ts) + (ts * .03)) + prevarrowoffset;
DrawingTools.Draw.Diamond(nsb, (IDPrefix+currbar.ToString()+dcounter.ToString()), true, barsback, lbloffset, brush);
if (txtstrval1 != "" || txtstrval2 != "")
lbloffset -= (ts * .1);
dcounter++;
break;
case 2: // draw an arrow
lbloffset = drawony - ((drawoffset * ts) - (ts * .07)) + prevarrowoffset;
DrawingTools.Draw.ArrowUp(nsb, (IDPrefix+currbar.ToString()+dcounter.ToString()), true, barsback, lbloffset, brush);
if (txtstrval1 != "" || txtstrval2 != "")
lbloffset -= (ts * .23);
dcounter++;
break;
}
if (txtstrval1 != "")
{
DrawingTools.Draw.Text(nsb, "Txt1"+(IDPrefix+currbar.ToString()+dcounter.ToStr ing()), txtstrval1, barsback, lbloffset, brush);
lbloffset -= (ts * .13);
dcounter++;
}
if (txtstrval2 != "")
{
DrawingTools.Draw.Text(nsb, "Txt2"+(IDPrefix+currbar.ToString()+dcounter.ToStr ing()), txtstrval2, barsback, lbloffset, brush);
lbloffset -= (ts * .13);
dcounter++;
}
lbloffset -= (ts * .08); // spacer for the next one
LastUpArrowOffset = lbloffset - drawony; // save this we may need to print another arrow below it
LastUpArrowBar = currbar;
}
else
{
if (LastDownArrowBar == currbar)
{
ns.Print ("another down arrow on bar <" + currbar + ">");
prevarrowoffset = LastDownArrowOffset;
} else {
prevarrowoffset = 0.0;
}
switch(drawtype)
{
case 0: // draw a dot
lbloffset = drawony + ((drawoffset * ts) + (ts * .03)) + prevarrowoffset;;
DrawingTools.Draw.Dot(nsb, (IDPrefix+currbar.ToString()+dcounter.ToString()), true, barsback, lbloffset, brush);
if (txtstrval1 != "" || txtstrval2 != "")
lbloffset += (ts * .31);
dcounter++;
break;
case 1: // draw an diamond
lbloffset = drawony + ((drawoffset * ts) + (ts * .03)) + prevarrowoffset;;
DrawingTools.Draw.Diamond(nsb, (IDPrefix+currbar.ToString()+dcounter.ToString()), true, barsback, lbloffset, brush);
if (txtstrval1 != "" || txtstrval2 != "")
lbloffset += (ts * .32);
dcounter++;
break;
case 2: // draw an arrow
lbloffset = drawony + ((drawoffset * ts) + (ts * .00)) + prevarrowoffset;
DrawingTools.Draw.ArrowDown(nsb, (IDPrefix+currbar.ToString()+dcounter.ToString()), true, barsback, lbloffset, brush);
if (txtstrval1 != "" || txtstrval2 != "")
lbloffset += (ts * .45);
dcounter++;
break;
}
if (txtstrval2 != "")
{
DrawingTools.Draw.Text(nsb, "Txt2"+(IDPrefix+currbar.ToString()+dcounter.ToStr ing()), txtstrval2, barsback, lbloffset, brush);
lbloffset += (ts * .13);
dcounter++;
}
if (txtstrval1 != "")
{
DrawingTools.Draw.Text(nsb, "Txt1"+(IDPrefix+currbar.ToString()+dcounter.ToStr ing()), txtstrval1, barsback, lbloffset, brush);
lbloffset += (ts * .13);
dcounter++;
}
lbloffset += (ts * .07); // spacer for the next one
LastDownArrowOffset = lbloffset - drawony; // save this we may need to print another arrow above it
LastDownArrowBar = currbar;
}
}
}
Comment