View Full Version : Drawline
wcmaria
06-23-2009, 01:33 PM
I have the following code which I would like to draw a circle below the bar the crosses and also draw a line.
if (CrossAbove(EMA(14), EMA(145), 1))
DrawDot(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Red);
DrawLine("tag1", false, 10, 1000, 0, 1001, Color.LimeGreen, DashStyle.Solid, 1);
When I run the indicator it works when just the drawDot line is in, when I add the drawline it does not draw the dot or the line.
Is there a reason for this?
Thanks
NinjaTrader_Josh
06-23-2009, 01:37 PM
wcmaria,
You need to place them within { } brackets for the if-statement.
if (CrossAbove.....)
{
DrawDot(...);
DrawLine(...);
}
wcmaria
06-23-2009, 02:01 PM
Thanks for the input.
When I include the following code
if (CrossAbove (EMA(14), EMA(145), 1) )
{
DrawDot(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Red);
Print((MAEnvelope(0.5,25).LowerBand[0]));
DrawLine(CurrentBar.ToString(), false, 10, 1000, 0, 1001, Color.LimeGreen, DashStyle.Solid, 1);
}
it does not work (shows nothing on the screen), but when I hash out the print and drawline lines it prints the dot in the correct place.
wcmaria
06-23-2009, 02:13 PM
It seems in my case I cannot use both the Drawdot and DrawTriangle within the same if statement. It will only work if I use one or the other.
if (CrossAbove (EMA(14), EMA(145), 1) )
{
DrawDot(CurrentBar.ToString(), true, 0, High[0] + TickSize, Color.Red);
//Print((MAEnvelope(0.5,25).LowerBand[0]));
DrawTriangleDown(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Red);
}
Is there a way to draw both a circle below and a several triangles at different prices above the same bar?
NinjaTrader_Josh
06-23-2009, 02:15 PM
The reason is because you are using the exact same object name. You need to use separate names if you want two separate objects.
eDanny
06-23-2009, 03:30 PM
Try something like this:
if (CrossAbove (EMA(14), EMA(145), 1) )
{
DrawDot("MyDot" + CurrentBar.ToString(), true, 0, High[0] + TickSize, Color.Red);
//Print((MAEnvelope(0.5,25).LowerBand[0]));
DrawTriangleDown("MyTriangle" + CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Red);
}
wcmaria
06-24-2009, 05:28 AM
Thanks for the responses everyone. It worked.
Will