Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Magenta Bar

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

    Magenta Bar

    is there a way i can keep or save the "Magenta Bar" for other strategies instead of retyping the code?

    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] 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]EnterLong(DefaultQuantity, [FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT][/FONT][/SIZE]
    [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]"Mypinkline"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] ,Position.AvgPrice + stop_ticks,Color.Pink);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"Mypalegreenline"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] ,Position.AvgPrice - 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]
    [SIZE=2][FONT=Courier New]} [/FONT][/SIZE]
    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] OnBarUpdate()[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [FONT=Courier New][SIZE=2][COLOR=#008000]// Condition set 1[/COLOR][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (Close[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] == MagentaBar)[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]EnterLong(DefaultQuantity, [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]

    #2
    Best would be to code the 'magenta bar' conditions into an indicator and to reference this then from your strategies - please see also this tip - http://www.ninjatrader-support2.com/...ead.php?t=3228

    Comment


      #3
      reference indicator to strategy

      i have built the indicator which compiles fine...
      how do i reference this new indicator?
      i have already used the "Add()" in Initialize

      is there any material i can read on this?

      thanks

      Comment


        #4
        myIndicatorName(whatever parameters you have)[0]

        You access your indicator like any other indicator.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          private int vs private double

          Code:
          [FONT=Courier New][SIZE=2][COLOR=#0000ff]
          private[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] stop_ticks = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]20[/COLOR][/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][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] abc = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]2.618[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]//standard deviation setting
          [/COLOR][/SIZE][/FONT]
          not sure if i'm using these correctly... is the "private double" used when decimals are used and "private int" used when whole numbers are used?

          or am i smokin crack lol... can't seem to find any reading material on this

          thanks

          Comment


            #6
            That is correct. doubles are floating point values. ints are integer values.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            630 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            565 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X