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.
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.
Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.
Need help? 1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first. 2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses. 3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make. 4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance. 5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers. 6) Help using the forum? Watch this video to learn general tips on using the site.
If you want to support our community, become an Elite Member.
The following 2 users say Thank You to Big Mike for this post:
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.
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.