PDA

View Full Version : drawing a horizontal line on the stop level


Thomas79
04-30-2009, 09:11 AM
Hi
i would like to draw an horizontal line on my stop level, i read the guide and write that script...but it doesn't work...

SetStopLoss(CalculationMode.Price,High[0] + 3*TickSize);
DrawHorizontalLine("SetStopLoss", DashStyle.DashDot,Color.Black);

NinjaTrader_Josh
04-30-2009, 09:19 AM
Please see the syntax portion of the Help Guide article on DrawHorizontalLine().

DrawHorizontalLine(string tag, double y, Color color)

You need to provide a "double y" value for the line to be drawn at for the second parameter and not some DashStyle.

DrawHorizontalLine("SetStopLoss", High[0] + 3 * TickSize, Color.Black);

Thomas79
04-30-2009, 09:27 AM
oki i have a line but on all the historical graph... i can not have it just during the trade ? after the trade is closed don't see the line anymore ?

NinjaTrader_Josh
04-30-2009, 09:34 AM
If you don't want the line anymore you need to remove the line.

RemoveDrawObject("SetStopLoss");
http://www.ninjatrader-support.com/HelpGuideV6/RemoveDrawObject.html

Thomas79
04-30-2009, 09:52 AM
sorry Josh... i wasn't clear, i want that the line remain on the chart as long as the trade is on the way... show an example below... i draw the line with a pen...

http://farm4.static.flickr.com/3344/3488328881_f487f28bcf_o.jpg

NinjaTrader_Josh
04-30-2009, 09:58 AM
Thomas79,

Just leave the line drawn and when you don't want it anymore type in RemoveDrawObject().

DrawHorizontalLine() will draw a line all the way across the chart regardless of which bar you are at. If you only want line segments then use DrawLine().

Thomas79
04-30-2009, 12:06 PM
thx Josh, that's work... the only thing is that works but just for the last trade on my graph, not the previous...

also i can see it XX bar ago but how can i see for the coming bar... what i have to write on the 5th where i put 0... can i put +10 ? that not works....

here my code :

//set a stop 3 ticks above my shooting
SetStopLoss(CalculationMode.Price,High[0]+ 3*TickSize);
DrawLine("SetStopLoss",false, 10, High[0] + 3 * TickSize, 0, High[0] + 3 * TickSize, Color.Red, DashStyle.Dot,2);

NinjaTrader_Josh
04-30-2009, 12:13 PM
You need to give it unique string names. You are constantly using the same ID name and as such it will only draw one line. For each trade you need a new ID name.

Thomas79
05-01-2009, 02:37 AM
but it's impossible to give a new ID name for each trade... i have a lot of trade !

or may be there is a solution to automatically generate a new ID for each trade ?

here my code

//set a stop 3 ticks above my shooting
SetStopLoss(CalculationMode.Price,High[0]+ 3*TickSize);

Stop = High[0]+ 3*TickSize;
DrawLine("Stop",false, 10, Stop, 0, Stop, Color.Red, DashStyle.Dot,2);

NinjaTrader_Bertrand
05-01-2009, 06:04 AM
Simply use something like this for creating unique tag ID's -
"Stop" + CurrentBar

Thomas79
05-03-2009, 07:05 AM
that's work, thx a lot !!