[SIZE=2][FONT=Courier New]SetProfitTarget([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], CalculationMode.Ticks, Tp_ticks);[/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#008000]//DrawHorizontalLine("Long Line" + CurrentBar, 0, Color.Chartreuse);[/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#008000]//DrawHorizontalLine("MyHorizontalLine", Close[0],Color.DimGray,DashStyle.Dot,1);[/COLOR][/SIZE][/FONT]
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
DrawHorizontalLine at StopLoss
Collapse
X
-
DrawHorizontalLine at StopLoss
trying to add this
Code:Tags: None
-
DrawHorizontalLine("MyHorizontalLine", + stop_ticks,Color.Lime,DashStyle.Solid,1);
trying to draw a line and would if so...would this line be erased after position is flat?
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] stop_ticks = 10[/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
Code:[SIZE=2][FONT=Courier New][COLOR=#0000ff]protected[/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]EnterShort(DefaultQuantity, [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"short"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]BarColor = Color.Magenta;[/FONT][/SIZE] [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"MyHorizontalLine"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], + stop_ticks,Color.Lime,DashStyle.Solid,[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
Comment
-
DrawHorizontalLine("short",Position.Mark etPosition + stop_ticks,Color.Blue);
trying to draw horizontal line + stop_ticks...basically looking for a line that shows where the stoploss is located on the chart
Code:[FONT=Courier New][SIZE=2] EnterShort(DefaultQuantity, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"short"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); BarColor = Color.Magenta; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]//DrawHorizontalLine("MyHorizontalLine",Open[0] + stop_ticks,Color.Blue); [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]DrawHorizontalLine([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"short"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Position.MarketPosition + stop_ticks,Color.Blue); [/SIZE][/FONT]
Comment
-
RemoveDrawObject
trying to erase DrawHorizontalLine when position wants to "reverse"Code:[SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]EnterShort(DefaultQuantity, [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"short"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]BarColor = Color.Magenta;[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New](Position.MarketPosition == MarketPosition.Short)[/FONT][/SIZE] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"stop loss line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + stop_ticks,Color.Pink);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"target profit line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] - tp_ticks,Color.PaleGreen);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New](Position.MarketPosition == MarketPosition.Flat)[/FONT][/SIZE] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]RemoveDrawObject([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"stop loss line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]RemoveDrawObject([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"target profit line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [FONT=Courier New][SIZE=2]}[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New](Position.MarketPosition == MarketPosition.Long)//*****[/FONT][/SIZE] [SIZE=2][FONT=Courier New]this is saying:[/FONT][/SIZE] [SIZE=2][FONT=Courier New]if the current [/FONT][/SIZE] [SIZE=2][FONT=Courier New]short position closed [/FONT][/SIZE] [SIZE=2][FONT=Courier New]to open a long position...remove those "old"[/FONT][/SIZE] [SIZE=2][FONT=Courier New]stop loss and target profit lines[/FONT][/SIZE] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]RemoveDrawObject([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"stop loss line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]RemoveDrawObject([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"target profit line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [FONT=Courier New][SIZE=2]}[/SIZE][/FONT]
Comment
-
seems like it's not removing the lines
when position reverses, the old lines remain and new ones get drawn showing a total of 4 lines...this was noticed in "replay" mode and not sure if "live" would be differentOriginally posted by NinjaTrader_Josh View PostWhat is the problem with the code currently?
Comment
-
Code
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Variables[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] tp_ticks = 10[/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for Tp_ticks[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] stop_ticks = 10[/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for Stop_ticks[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] SHORT CONDITIONS [/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New]([/FONT][/SIZE] [SIZE=2][FONT=Courier New]( High[[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] > High[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]])[/SIZE][/FONT] [SIZE=2][FONT=Courier New])[/FONT][/SIZE] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]EnterShort(DefaultQuantity, [FONT=Courier New][SIZE=2][COLOR=#800000]"short"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]BarColor = Color.Magenta;[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New](Position.MarketPosition == MarketPosition.Short)[/FONT][/SIZE] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"stop loss line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + stop_ticks,Color.Pink);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"target profit line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] - tp_ticks,Color.PaleGreen);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New](Position.MarketPosition == MarketPosition.Flat)[/FONT][/SIZE] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]RemoveDrawObject([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"stop loss line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]RemoveDrawObject([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"target profit line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [FONT=Courier New][SIZE=2]}[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New](Position.MarketPosition == MarketPosition.Long)//*****[/FONT][/SIZE] [SIZE=2][FONT=Courier New]this is saying:[/FONT][/SIZE] [SIZE=2][FONT=Courier New]if the current [/FONT][/SIZE] [SIZE=2][FONT=Courier New]short position closed [/FONT][/SIZE] [SIZE=2][FONT=Courier New]to open a long position...remove those "old"[/FONT][/SIZE] [SIZE=2][FONT=Courier New]stop loss and target profit lines[/FONT][/SIZE] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]RemoveDrawObject([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"stop loss line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]RemoveDrawObject([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"target profit line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [FONT=Courier New][SIZE=2]}[/SIZE][/FONT][/FONT][/SIZE]
Comment
-
RemoveDrawObjects seem to work now...thanks
how can i reference the DrawHorizontalLine to the entry price to keep it from moving? I think the Open[0] part is making the lines move on every new bar closeCode:DrawHorizontalLine([FONT=Courier New][SIZE=2][COLOR=#800000]"short stop loss line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + stop_ticks,Color.Pink);[/SIZE][/FONT]
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Initialize()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]Add(BarTimer());[/FONT][/SIZE] [SIZE=2][FONT=Courier New]Add(SMA([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800080]14[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]));[/SIZE][/FONT] [SIZE=2][FONT=Courier New]Add(SMA([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800080]45[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]));[/SIZE][/FONT] [SIZE=2][FONT=Courier New]SetProfitTarget([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], CalculationMode.Ticks, Tp_ticks);[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//DrawHorizontalLine("Long Line" + CurrentBar, 0, Color.Chartreuse);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//DrawHorizontalLine("MyHorizontalLine", Close[0],Color.DimGray,DashStyle.Dot,1);[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New]SetStopLoss([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], CalculationMode.Ticks, Stop_ticks, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]CalculateOnBarClose = [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]<summary>[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]</summary>[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] SHORT CONDITIONS [/SIZE][/FONT] [SIZE=2][FONT=Courier New]{ [/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New]([/FONT][/SIZE] [SIZE=2][FONT=Courier New]SMA([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800080]14[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] > SMA([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]45[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] [/SIZE][/FONT] [SIZE=2][FONT=Courier New])[/FONT][/SIZE] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]EnterShort(DefaultQuantity, [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"short"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]BarColor = Color.Magenta;[/FONT][/SIZE] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2](Position.MarketPosition == MarketPosition.Short)[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"short stop loss line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + stop_ticks,Color.Pink);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"short target profit line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] - tp_ticks,Color.PaleGreen);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]#endregion[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] LONG CONDITIONS [/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New]( [/FONT][/SIZE] [SIZE=2][FONT=Courier New]SMA([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800080]14[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] < SMA([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]45[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] [/SIZE][/FONT] [SIZE=2][FONT=Courier New])[/FONT][/SIZE] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]EnterLong(DefaultQuantity, [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"long"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]BarColor = Color.Green;[/FONT][/SIZE] [SIZE=2][FONT=Courier New]} [/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2](Position.MarketPosition == MarketPosition.Long)[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"long stop loss line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] - (stop_ticks),Color.Pink);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"long target profit line"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + (tp_ticks),Color.PaleGreen);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New](Position.MarketPosition == MarketPosition.Flat)[/FONT][/SIZE] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]RemoveDrawObjects();[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#008000]//RemoveDrawObject("long stop loss linetp_ticks");[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//RemoveDrawObject("long target profit linestop_ticks");[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//DrawHorizontalLine("stop loss line",Open[0] + stop_ticks,Color.Pink);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//DrawHorizontalLine("target profit line",Open[0] - tp_ticks,Color.PaleGreen);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]}[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]#endregion[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] REMOVE TP AND STOPLOSS LINES WHEN FLAT [/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT] [SIZE=2][FONT=Courier New](Position.MarketPosition == MarketPosition.Flat)[/FONT][/SIZE] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]RemoveDrawObjects();[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#008000]//RemoveDrawObject("stop loss line");[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//RemoveDrawObject("target profit line");[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//DrawHorizontalLine("stop loss line",Open[0] + stop_ticks,Color.Pink);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#008000]//DrawHorizontalLine("target profit line",Open[0] - tp_ticks,Color.PaleGreen);[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]}[/SIZE][/FONT] [SIZE=2][FONT=Courier New]} [/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]#endregion[/COLOR][/SIZE][/FONT]
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
580 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
335 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
102 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
552 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment