NexusFi: Find Your Edge


Home Menu

 





Drawing a text on a chart report


Discussion in NinjaTrader

Updated
    1. trending_up 4,141 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

Drawing a text on a chart report

  #1 (permalink)
Astrogirl
Milan/Italy
 
Posts: 51 since Oct 2013
Thanks Given: 25
Thanks Received: 12

Hello everybody!

I'm a newbie of NT scripting and I cannot undestand why my script doesn't work as I wish:

 
Code
                    BackColor = Color.YellowGreen;
	            DrawText("My text" + CurrentBar, "Stop loss level", 0, stop_loss_level, Color.Red);

It makes a backcolor on a chart but not a text; does anyone know why?!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Deepmoney LLM
Elite Quantitative GenAI/LLM
ZombieSqueeze
Platforms and Indicators
Exit Strategy
NinjaTrader
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #2 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


Astrogirl View Post
Hello everybody!

I'm a newbie of NT scripting and I cannot undestand why my script doesn't work as I wish:

 
Code
                    BackColor = Color.YellowGreen;
	            DrawText("My text" + CurrentBar, "Stop loss level", 0, stop_loss_level, Color.Red);

It makes a backcolor on a chart but not a text; does anyone know why?!

Cases like this first step is always to put a 'Print ("CB " + CurrentBar + " SLL " + stop_loss_level);' type of statement in and check the output window - what does that show?

Travel Well
Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
Astrogirl
Milan/Italy
 
Posts: 51 since Oct 2013
Thanks Given: 25
Thanks Received: 12



ratfink View Post
Cases like this first step is always to put a 'Print ("CB " + CurrentBar + " SLL " + stop_loss_level);' type of statement in and check the output window - what does that show?

Sorry Ratfink, what should it happen? I putted your code row in my script but nothing change on the chart

Reply With Quote
  #4 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090

try;

stop_loss_level = Low[0]; // add this line
BackColor = Color.YellowGreen;
DrawText("My text" + CurrentBar, "Stop loss level", 0, stop_loss_level, Color.Red);

Reply With Quote
  #5 (permalink)
Astrogirl
Milan/Italy
 
Posts: 51 since Oct 2013
Thanks Given: 25
Thanks Received: 12


cory View Post
try;

stop_loss_level = Low[0]; // add this line
BackColor = Color.YellowGreen;
DrawText("My text" + CurrentBar, "Stop loss level", 0, stop_loss_level, Color.Red);

No changes

The output monitor gives me always "0";

What looks more strange is that the output windows gives me also the Position.AvgPrice as "0".

Reply With Quote
  #6 (permalink)
Astrogirl
Milan/Italy
 
Posts: 51 since Oct 2013
Thanks Given: 25
Thanks Received: 12

I declared stop_loss_level in the #region Variables as: double stop_loss_level = 0

 
Code
    public class ComplexYMpeak2 : Strategy
    {
        #region Variables
		

		double stop_loss_level = 0	
		

        #endregion
Could it be the matter?

Reply With Quote
  #7 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


Astrogirl View Post
I declared stop_loss_level in the #region Variables as: double stop_loss_level = 0

 
Code
    public class ComplexYMpeak2 : Strategy
    {
        #region Variables
		

		double stop_loss_level = 0	
		

        #endregion
Could it be the matter?

We assumed you were calculating the stop_loss_level from somewhere else it is a persistent variable, if not that will definitely be your problem which is why Prints to the output window are always first port of call to check for valid/invalid assumptions, etc.

Travel Well
Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
Astrogirl
Milan/Italy
 
Posts: 51 since Oct 2013
Thanks Given: 25
Thanks Received: 12


ratfink View Post
We assumed you were calculating the stop_loss_level from somewhere else it is a persistent variable, if not that will definitely be your problem which is why Prints to the output window are always first port of call to check for valid/invalid assumptions, etc.

I really don't have any preparation about variables anyway my stop_loss_level is:

 
Code
stop_loss_level = Convert.ToInt32 (Position.AvgPrice * (1 - stop_loss));
But, as it gives me an error in the compilator, I had to declare the stop_loss_level as:

 
Code
double stop_loss_level = 0
Probably I reached the goal in a wrong way.

Reply With Quote
  #9 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


Astrogirl View Post

Probably I reached the goal in a wrong way.

Looks like you just need to work back with Prints at every stage to prove that average price and stop loss are themselves containing some useful numbers, then you can think more about the drawtext call.

Travel Well
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #10 (permalink)
Astrogirl
Milan/Italy
 
Posts: 51 since Oct 2013
Thanks Given: 25
Thanks Received: 12



ratfink View Post
Looks like you just need to work back with Prints at every stage to prove that average price and stop loss are themselves containing some useful numbers, then you can think more about the drawtext call.

Just done it!

The output windows gives me all the values correctly in some current bars (the ones related to the opened position, of course). Infact the strategy works as it due but the row

- DrawText("My text" + CurrentBar, "Stop_loss_price", 0, stop_loss_price, Color.Red);

It doesn't work as no data is drawn on the chart report.

Reply With Quote




Last Updated on March 27, 2014


© 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