Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Indicator Plots only Once

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

    Indicator Plots only Once

    Hello!
    Need some help with developing an Indicator.
    Having trouble that indicator plots only last conditions and once, and doesn't plot any lines (i'm using vertical lines with two colors) on history (except two last lines).
    I want to see all lines that I have. In Output window I see that values are calulating good and returns the right value, but on chart I see only two vertical lines.

    Here is the code I'm using for plot lines:
    Code:
    if(mcSum > 2)
    			{
    				Print("Can take long trades");
    				DrawVerticalLine("Long Enable", 0, upColor);
    			}
    			if(mcSum < -2)
    			{
    				Print("Can take short trades");
    				DrawVerticalLine("Short Enable", 0, downColor);
    			}
    upColor setted to green and downColor for red in Variables.

    What I need to do to get all this Lines?
    In Output window I see all Prints "Can take long/short trades".
    Thanks!

    update: i found that lines are refreshing and plots me only last values. I'm using this code in OnBarUpdate method.
    But I want next thing: as my condition applies - plot vertical line and don't remove it or refresh. Want to stay that line on chart.
    Last edited by YevhenShynkarenko; 11-15-2015, 07:24 AM.

    #2
    Originally posted by YevhenShynkarenko View Post
    Hello!
    Need some help with developing an Indicator.
    Having trouble that indicator plots only last conditions and once, and doesn't plot any lines (i'm using vertical lines with two colors) on history (except two last lines).
    I want to see all lines that I have. In Output window I see that values are calulating good and returns the right value, but on chart I see only two vertical lines.

    Here is the code I'm using for plot lines:
    Code:
    if(mcSum > 2)
    			{
    				Print("Can take long trades");
    				DrawVerticalLine("Long Enable", 0, upColor);
    			}
    			if(mcSum < -2)
    			{
    				Print("Can take short trades");
    				DrawVerticalLine("Short Enable", 0, downColor);
    			}
    upColor setted to green and downColor for red in Variables.

    What I need to do to get all this Lines?
    In Output window I see all Prints "Can take long/short trades".
    Thanks!

    update: i found that lines are refreshing and plots me only last values. I'm using this code in OnBarUpdate method.
    But I want next thing: as my condition applies - plot vertical line and don't remove it or refresh. Want to stay that line on chart.



    Code:
    [B]Parameters[/B]
    [COLOR="Blue"]tag[/COLOR]
    A user defined unique id used to reference the draw object. 
    For example, if you pass in a value of "myTag", each time 
    this tag is used, the same draw object is modified.
     [COLOR="blue"][I]If unique tags are used each time, 
    a new draw object will be created each time.[/I][/COLOR]

    Comment


      #3
      Originally posted by YevhenShynkarenko View Post
      Hello!
      Need some help with developing an Indicator.
      Having trouble that indicator plots only last conditions and once, and doesn't plot any lines (i'm using vertical lines with two colors) on history (except two last lines).
      I want to see all lines that I have. In Output window I see that values are calulating good and returns the right value, but on chart I see only two vertical lines.

      Here is the code I'm using for plot lines:
      Code:
      if(mcSum > 2)
      			{
      				Print("Can take long trades");
      				DrawVerticalLine("Long Enable", 0, upColor);
      			}
      			if(mcSum < -2)
      			{
      				Print("Can take short trades");
      				DrawVerticalLine("Short Enable", 0, downColor);
      			}
      upColor setted to green and downColor for red in Variables.

      What I need to do to get all this Lines?
      In Output window I see all Prints "Can take long/short trades".
      Thanks!

      update: i found that lines are refreshing and plots me only last values. I'm using this code in OnBarUpdate method.
      But I want next thing: as my condition applies - plot vertical line and don't remove it or refresh. Want to stay that line on chart.
      Your Lines have the same tag, so the last one will overwrite any others. Make your tags unique.

      The syntax in the NTHelp states this rather clearly.

      Last edited by koganam; 11-15-2015, 05:22 PM.

      Comment


        #4
        Hello YevhenShynkarenko,

        I believe koganam and sledge have provided the necessary information to resolve your inquiry. If you continue to experience difficulties, please let us know so we can assist.

        Basically you would want your code to look like this for all the lines to appear:
        Code:
        if(mcSum > 2)
        			{
        				Print("Can take long trades");
        				DrawVerticalLine("Long Enable" + CurrentBar.ToString(), 0, upColor);
        			}
        			if(mcSum < -2)
        			{
        				Print("Can take short trades");
        				DrawVerticalLine("Short Enable" + CurrentBar.ToString(), 0, downColor);
        			}
        Thank you in advance!
        Michael M.NinjaTrader Quality Assurance

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by arvidvanstaey, Today, 02:19 PM
        2 responses
        7 views
        0 likes
        Last Post arvidvanstaey  
        Started by jordanq2, Today, 03:10 PM
        0 responses
        4 views
        0 likes
        Last Post jordanq2  
        Started by traderqz, Today, 12:06 AM
        10 responses
        18 views
        0 likes
        Last Post traderqz  
        Started by algospoke, 04-17-2024, 06:40 PM
        5 responses
        46 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by mmckinnm, Today, 01:34 PM
        3 responses
        6 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X