NexusFi: Find Your Edge


Home Menu

 





I'm a Ninjascript Newbie and need some help


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one suprsnipes with 2 posts (0 thanks)
    2. looks_two Big Mike with 1 posts (2 thanks)
    3. looks_3 cory with 1 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 4,302 views
    2. thumb_up 4 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 1 attachments




 
Search this Thread

I'm a Ninjascript Newbie and need some help

  #1 (permalink)
suprsnipes
Melbourne, Australia
 
Posts: 6 since Nov 2009
Thanks Given: 4
Thanks Received: 0

Hi Guys,

I have coded a very basic NinjaTrader indicator but I am having some trouble trying to work out how I could move forward with it.

At the moment the indicator draws lines from the open (using the NinjaTrader CurrentDayOHL indicator). It draws horizontal lines 50 and 100 ticks above and below the open price.

What I would like to do is ONLY display the horizontal line that is nearest to the current price as I have found that by displaying the 4 lines mentioned above or any more for that matter it squashes the chart considerably.

So in effect if if the price was still close to the open then I would only want to display two of the horizontal lines the 50 ticks above the open and 50 ticks below the open ... or ... if the price was above the open by say 60 ticks then I would only like to display the horizontal line 100 ticks above the open and 50 ticks below the open.

Also if the price has already been to one of the aforementioned prices then I don't want to display that level again during the session.

I would really, really appreciate the help.

Thanks in advance,
suprsnipes

P.S. I have attached the .zip file

Attached Files
Elite Membership required to download: MyCustomIndicator1.zip
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
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 …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
The Program
18 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #3 (permalink)
 
wh's Avatar
 wh 
Neubrandenburg, Germany
 
Experience: Advanced
Platform: R
Trading: Stocks
Posts: 538 since Jun 2009
Thanks Given: 298
Thanks Received: 512


perhaps you add in onbarupdate()

if(CurrentBar < 2) return;

if intraday calc the bar to daily mean 1 min are 1440 bars for a day ...

Causality is the relationship between an event (the cause) and a second event (the effect), where the second event is a consequence of the first.
Reply With Quote
Thanked by:
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,537

To avoid "squashing" the chart, change AutoScale to false in the indicator menu, or add AutoScale = false in #initialize.

If you want to test for what line is closest, use a Math.Min/Math.Max statement compared with Close.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
suprsnipes
Melbourne, Australia
 
Posts: 6 since Nov 2009
Thanks Given: 4
Thanks Received: 0


wh View Post
perhaps you add in onbarupdate()

if(CurrentBar < 2) return;

if intraday calc the bar to daily mean 1 min are 1440 bars for a day ...

Thanks for the reply wh.

As suggested I should place this in onbarupdate() but does it go underneath the existing code? I'm not quite sure what to do here.


Big Mike View Post

Big Mike To avoid "squashing" the chart, change AutoScale to false in the indicator menu, or add AutoScale = false in #initialize.

If you want to test for what line is closest, use a Math.Min/Math.Max statement compared with Close.

Mike

No problem with the suggestion to add AutoScale to false option within the script Big Mike but as per above I am stuck with achieving what I was originally after. If any of you NinjaScript Wizards have some spare time I would really appreciate it if you could perhaps point me in the right direction here.

Regards,
suprsnipes

Reply With Quote
  #6 (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

the trick is looking at some scripts you think that is close to what you are looking for.

randomly open the first script I see
 
Code
protected override void OnBarUpdate()
        {
			if (CurrentBar == 0) { // first bar initialization
				lasthi = hi[0] = useHiLo ? High[0] : Input[0];
				lastlo = lo[0] = useHiLo ? Low[0] : Input[0];
				lasthibar = lastlobar = 0;
				return;
...
so looks like you just need to add the code right under onbarupdate()


another script;
 
Code
	protected override void Initialize()
		{
			Add(new Plot(new Pen(Color.Lime, 4), PlotStyle.Bar, "MacdUp"));
			Add(new Plot(new Pen(Color.Red, 4), PlotStyle.Bar, "MacdDown"));
			Add(new Plot(new Pen(Color.Yellow, 4), PlotStyle.Bar, "MacdDown"));
			Add(new Plot(new Pen(Color.DarkGray, 1), PlotStyle.Line, "Avg"));

			Add(new Line(Color.DarkGray, 0, "Zero line"));

			macd	= new DataSeries(this);
			fastEma	= new DataSeries(this);
			slowEma	= new DataSeries(this);
			
			DisplayInDataBox = false; 
            CalculateOnBarClose = false;
			PaintPriceMarkers = false; 
		}
...
there is no scale = false but looks like you should put it there in the Initialize()

Reply With Quote
Thanked by:




Last Updated on February 17, 2010


© 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