NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 01-14-2008, 02:03 PM   #1
vitor1982
Junior Member
 
Join Date: Dec 2007
Location: Poland
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default Don't plot on chart - Need help

Hi, my name is Wiktor and I come from Poland ) my grammar english is not really impressive. i'm begginer trader and i try write my first indicator.

When i write :

protected override void Initialize()
{

Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
CalculateOnBarClose = false;
Overlay = true;
PriceTypeSupported = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{

// Condition set 1 kupuj
if ( Close[0] > MAX(High, 2)[0] )

{
DrawArrowUp("My up arrow" + CurrentBar, 0, Low[0] +- 5 * TickSize, Color.Blue);
DrawLine("My line" + CurrentBar, 0, Low[0],35, Low[0], Color.Blue);
}



I would like trade Long when price breakout MAX from 2 bars, but that indicator don't plot on chart, where is bug ?? What I write wrong ?? Help me
vitor1982 is offline  
Reply With Quote
Old 01-14-2008, 02:21 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Yek shamash! (my spelling is probably bad as well but hopefully you know what I mean)

The problem is with your logic. Your condition will !never be true since the close will !never be greater than the highest highest high of the last two bars. At best, it may equal. What you likely want to check for is if the current bar close is greater than the highest high of the past two bars excluding the current bar.

if (Close[0] > MAX(High, 2)[1])
// Do something

is what you want. You will also want to add a check like this before hand.

if (CurrentBar < 1)
return;

See this link for more info - http://www.ninjatrader-support.com/v...ead.php?t=3170
NinjaTrader_Ray is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Start/End of day plot Mexie Indicator Development 20 08-04-2011 09:24 PM
Variable plot within chart? Burga1 Charting 9 12-02-2007 08:20 PM
Limiting a Plot rt-trader General Programming 2 08-25-2007 06:21 PM
Hiding a plot grd974 Indicator Development 5 05-28-2007 01:47 PM
Chart Trader vs Plot Executions LG Charting 1 04-27-2007 02:24 AM


All times are GMT -6. The time now is 03:27 PM.