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

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 andrewtrades, Today, 04:57 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    6 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    436 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    9 views
    0 likes
    Last Post FAQtrader  
    Started by rocketman7, Today, 09:41 AM
    5 responses
    20 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X