Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Dot for Trade Indicator

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

    Draw Dot for Trade Indicator

    I have created an indicator that will draw a dot above or below a bar when a set of parameters are true. (Above or below depending on a buy or sell situation) I do this with an "If / Then" statement where the Then statement is the DrawDot() method.

    My issue is that when applied the chart only draws the dot for the last instance for each instead of all instances. Once the set of conditions becomes true again the previous dot is erased and a new dot is drawn. How do I leave all dots?

    Here's an example of what I have.
    Code:
    if (
    						SMA(5)[0] > SMA(5)[1]
    						&& SMA(5)[1] < SMA(5)[2]
    						
    						&& Rising(SMA(5))
    						&& Rising(SMA(20))
    						&& Rising(SMA(40))
    						
    						)
    						DrawDot("Trade Alert Buy", true, 0, High[0] + 5, Color.LawnGreen);
    					
    					if (
    						SMA(5)[0] < SMA(5)[1]
    						&& SMA(5)[1] > SMA(5)[2]
    						
    						&& Falling(SMA(5))
    						&& Falling(SMA(20))
    						&& Falling(SMA(40))
    						)
    						DrawDot("Trade Alert Sell", true, 0, Low[0] - 5, Color.Red);

    #2
    Hello BReal,

    Thanks for your post.

    The way to show all of the dots is to provide a unique tag name for each dot. Currently you are using the same name for each dot and the functionality of erasing previous and only showing current is expected.

    An easy way to create unique tag names is to add the CurrentBar to the tagname, for example:

    DrawDot("Trade Alert Buy"+CurrentBar, true, 0, High[0] + 5, Color.LawnGreen);

    When the dots are drawn, if you double click on one and look at the property you will see, for example, a name such as "Trade Alert Buy1189". meaning the dot is on bar # 1189.

    DrawDot: http://ninjatrader.com/support/helpG...7/?drawdot.htm
    CurrentBar: http://ninjatrader.com/support/helpG...currentbar.htm
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mohsemian, Today, 01:36 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_BrendanC  
    Started by Polufson, Today, 01:37 PM
    0 responses
    5 views
    0 likes
    Last Post Polufson  
    Started by Derjan, Today, 01:18 PM
    2 responses
    17 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by Cicero, Today, 09:41 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by johnnymustard, Today, 12:01 PM
    2 responses
    12 views
    0 likes
    Last Post johnnymustard  
    Working...
    X