Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawHorizontalLine at StopLoss

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    DrawHorizontalLine at StopLoss

    trying to add this
    Code:
    [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]

    #2
    You can only do Draw() methods in OnBarUpdate(). Please ensure you are in OnBarUpdate().
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      would this draw a line based on the following?
      private int = stop_ticks

      EnterLong(DefaultQuantity,
      "");
      BarColor = Color.Magenta;
      DrawHorizontalLine(
      "MyHorizontalLine", stop_ticks,Color.DimGray,DashStyle.Dot,1);

      Comment


        #4
        You can't do private int = stop_ticks. You need to do something like this:

        private int stop_ticks = 0;
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          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


            #6
            Nope. To erase draw objects you have to explicitly remove them.

            Josh P.NinjaTrader Customer Service

            Comment


              #7
              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


                #8
                duck_CA,

                That works fine, but you can't tell it to draw that quickly. You need to wait till you have a short position before you can do it.

                Code:
                if (Position.MarketPosition == MarketPosition.Short)
                     // draw your line
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  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


                    #10
                    What is the problem with the code currently?
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      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 different
                      Originally posted by NinjaTrader_Josh View Post
                      What is the problem with the code currently?

                      Comment


                        #12
                        Please post complete code. Thank you.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          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


                            #14
                            duck_CA,

                            It is because you are wrapping your RemoveDrawObject() if-statements with the overarching High[1] > High[0] criteria. Please move them outside of that if-statement.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              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 close
                              Code:
                              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 Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              335 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              102 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              554 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              552 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X