NexusFi: Find Your Edge


Home Menu

 





Need help with coding please...trying to add plotted shapes to a script


Discussion in NinjaTrader

Updated
    1. trending_up 817 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 1 attachments




 
Search this Thread

Need help with coding please...trying to add plotted shapes to a script

  #1 (permalink)
 Titan007 
las vegas
 
Experience: Intermediate
Platform: NT
Trading: Futures
Posts: 4 since Dec 2017
Thanks Given: 1
Thanks Received: 1

I'm new to Ninja and know how to write Pine and some EasyL but can't seem to figure out how to plot shapes on the price chart with Ninja. Would someone be able to help add a diamond shape to a script when MA's cross?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Build trailing stop for micro index(s)
Psychology and Money Management
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Exit Strategy
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
51 thanks
Funded Trader platforms
44 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #2 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401


Titan007 View Post
I'm new to Ninja and know how to write Pine and some EasyL but can't seem to figure out how to plot shapes on the price chart with Ninja. Would someone be able to help add a diamond shape to a script when MA's cross?

You can find all of the methods and their signatures in the help guide. Here is a link to the Ninjascript side of the helpguide: https://ninjatrader.com/support/helpGuides/nt8//NT%20HelpGuide%20English.html?language_reference_wip.htm

Here is a link to the Draw.Diamond() page: https://ninjatrader.com/support/helpGuides/nt8//NT%20HelpGuide%20English.html?draw_diamond.htm

At the bottom of the helpguide is an example:

// Paints a red diamond on the current bar 1 tick below the low
Draw.Diamond(this, "tag1", true, 0, Low[0] - TickSize, Brushes.Red);


Drawing objects must have a unique name so with the above example you will only see the latest diamond. When the name is not unique any previously drawn diamond with that name would be removed so that only the latest version would be seen. To create unique names you can add +CurrentBar, for example: Draw.Diamond(this, "tag1"+CurrentBar, true, 0, Low[0] - TickSize, Brushes.Red); This would allow you to see every occurrence of a diamond because the bar number is added to the name tag1 to create a unique (per bar) tag name.

So generically:

if (CrossAbove (EMA(13), SMA(20), 1))
{
Draw.Diamond(this, "tag1"+CurrentBar, true, 0, Low[0] - TickSize, Brushes.Red); // Draw red diamond when crossabove is true at 1 tick below the low of the bar
}

Be yourself; everyone else is already taken. Oscar Wilde
Reply With Quote
Thanked by:
  #3 (permalink)
 Titan007 
las vegas
 
Experience: Intermediate
Platform: NT
Trading: Futures
Posts: 4 since Dec 2017
Thanks Given: 1
Thanks Received: 1


Thank you so much for your detailed reply. I will be working on this today!

Started this thread Reply With Quote
  #4 (permalink)
 Titan007 
las vegas
 
Experience: Intermediate
Platform: NT
Trading: Futures
Posts: 4 since Dec 2017
Thanks Given: 1
Thanks Received: 1


Tasker_182 View Post
You can find all of the methods and their signatures in the help guide. Here is a link to the Ninjascript side of the helpguide: https://ninjatrader.com/support/helpGuides/nt8//NT%20HelpGuide%20English.html?language_reference_wip.htm

Here is a link to the Draw.Diamond() page: https://ninjatrader.com/support/helpGuides/nt8//NT%20HelpGuide%20English.html?draw_diamond.htm

At the bottom of the helpguide is an example:

// Paints a red diamond on the current bar 1 tick below the low
Draw.Diamond(this, "tag1", true, 0, Low[0] - TickSize, Brushes.Red);


Drawing objects must have a unique name so with the above example you will only see the latest diamond. When the name is not unique any previously drawn diamond with that name would be removed so that only the latest version would be seen. To create unique names you can add +CurrentBar, for example: Draw.Diamond(this, "tag1"+CurrentBar, true, 0, Low[0] - TickSize, Brushes.Red); This would allow you to see every occurrence of a diamond because the bar number is added to the name tag1 to create a unique (per bar) tag name.

So generically:

if (CrossAbove (EMA(13), SMA(20), 1))
{
Draw.Diamond(this, "tag1"+CurrentBar, true, 0, Low[0] - TickSize, Brushes.Red); // Draw red diamond when crossabove is true at 1 tick below the low of the bar
}

Just an update I can't get it to work right. I downloaded a script from here to practice on, it's a moving average that changes color based on rising/falling bar values. I was able to get the red and green diamonds to plot on the chart but they plot on every bar instead of a single time when the moving average color changes. I have been scouring the internet trying to find examples of something similar but can't find anything.
Alternatively I tried to modify a 2nd indicator that has 2 moving averages in it using crossover/crossunder. The problem there is I tried every parameter and plot value I could find in the script but kept getting 'does not exist in context' errors.
I'm not giving up, but I have never used C# before. Seems the Python based languages are easier to pickup and modify for me.

Started this thread Reply With Quote
  #5 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401

If you try my example, and add and ema 13 and and sma 20 to the chart, does it show at the cross above then?

Be yourself; everyone else is already taken. Oscar Wilde
Reply With Quote
  #6 (permalink)
 Titan007 
las vegas
 
Experience: Intermediate
Platform: NT
Trading: Futures
Posts: 4 since Dec 2017
Thanks Given: 1
Thanks Received: 1


Tasker_182 View Post
If you try my example, and add and ema 13 and and sma 20 to the chart, does it show at the cross above then?

Ok I got that to work. To be honest the 'else if' eluded me until a few minutes ago.

Screenshot 2022-10-20 124322

Attached Thumbnails
Click image for larger version

Name:	Screenshot 2022-10-20 124322.png
Views:	43
Size:	56.6 KB
ID:	327583  
Started this thread Reply With Quote
Thanked by:




Last Updated on October 20, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts