Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
rising/falling source code?
Collapse
X
-
me again, im having a couple compiling errors that say
"The operator "<" cant be applied to operators type "double" and "Ninjatrader.Data.DataSeries"
what did i broke? lol
instead of making a whole new indi i just wanna plot some text on the price panel:
if( Close[0] >=MiddleTop);
{DrawTextFixed("Trend", " Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Red, Color.Red, 7);}
Comment
-
kabott,
For one, you don't want to close an if statement like this :
if( Close[0] >=MiddleTop);
You will need to remove the ;
Secondly, I am not sure if anything is wrong with that condition unless MiddleTop is a dataseries. Even then you are reporting an error with a different logical operator "<".
Perhaps that particular error is coming from elsewhere?Adam P.NinjaTrader Customer Service
Comment
-
It looks then like MiddleTop is a Plot or DataSeries. In that case, you need to write that as:Originally posted by kabott View Postme again, im having a couple compiling errors that say
"The operator "<" cant be applied to operators type "double" and "Ninjatrader.Data.DataSeries"
what did i broke? lol
instead of making a whole new indi i just wanna plot some text on the price panel:
if( Close[0] >=MiddleTop);
{DrawTextFixed("Trend", " Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Red, Color.Red, 7);}
if( Close[0] >=MiddleTop[0])
Comment
-
dang , this is so frustrating , the script file that's gaving the error is the same im working on, so it has to be here, how do i solve the Data series issue?
namespace NinjaTrader.Indicator
{
/// <summary>
/// Moving Average Envelopes
/// </summary>
[Description("Plots % envelopes around a moving average")]
public class MAEnvelopesColorFill : Indicator
{
#region Variables
private int matype = 3;
private int period = 14;
private double envelopePercentage = 1.5;
private Color fillColorUpper= Color.Gray;
private Color fillColorLower= Color.Red;
private Color maUp = Color.Green;
private Color maDown = Color.Red;
private int opacity = 2;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
// Adds a plot for the MA values to be stored in
Add(new Plot(Color.Blue, "Upper"));
Add(new Plot(new Pen(Color.Black, 2), PlotStyle.Line, "Middle"));
Add(new Plot(Color.Black, "Lower"));
Add(new Plot(Color.Black, "MiddleTop"));
Add(new Plot(Color.Black, "MiddleBottom"));
Plots[1].Pen.DashStyle = DashStyle.Dash;
Overlay = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
double maValue = 0;
switch (matype)
{
case 1:
{
Middle.Set(maValue = EMA(Inputs[0], Period)[0]);
break;
}
case 2:
{
Middle.Set(maValue = HMA(Inputs[0], Period)[0]);
break;
}
case 3:
{
Middle.Set(maValue = SMA(Inputs[0], Period)[0]);
break;
}
case 4:
{
Middle.Set(maValue = TMA(Inputs[0], Period)[0]);
break;
}
case 5:
{
Middle.Set(maValue = TEMA(Inputs[0], Period)[0]);
break;
}
case 6:
{
Middle.Set(maValue = WMA(Inputs[0], Period)[0]);
break;
}
}
Upper.Set(maValue + (maValue * EnvelopePercentage / 100));
Lower.Set(maValue - (maValue * EnvelopePercentage / 100));
MiddleTop.Set( maValue - (maValue * EnvelopePercentage / 200));
MiddleBottom.Set(maValue + (maValue * EnvelopePercentage / 200));
IRegion region = DrawRegion("tag1", CurrentBar, 0, Upper, Middle, Color.Empty, fillColorUpper, Opacity);
IRegion region2 = DrawRegion("tag2", CurrentBar, 0, Middle, Lower, Color.Empty, fillColorLower, Opacity);
{
if (Rising(Middle))
{ PlotColors[1][0]= maUp; }
else
{ PlotColors[1][0]= maDown; }
}
{
DrawOnPricePanel= true;
if( Close[0] >=MiddleTop)
{DrawTextFixed("Trend", " Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Red, Color.Red, 7);}
if(Close[0] >= Middle && Close[0] <MiddleTop)
{DrawTextFixed("Trend", " A - Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Maroon, Color.Maroon, 7);}
if( Close[0] <= Middle && Close[0] >MiddleBottom)
{DrawTextFixed("Trend", " A - Oversold", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.DarkGreen, Color.DarkGreen, 7);}
if( Close[0] < Middle && Close[0] >MiddleBottom)
{DrawTextFixed("Trend", " Oversold", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Green, Color.Green, 7);}
Comment
-
As Koganam and VTtrader pointed out,
You are comparing against dataseries.
You need to change things like : MiddleTop to MiddleTop[0]
If ( Close[0] > MiddleTop )
Is comparing a double against a dataseries, without telling it which element of the dataseries you want to compare against. DataSeries' are collections of values, not a single value itself.
Here is some more information : http://www.ninjatrader.com/support/h...ries_class.htm
-Adam ProfittLast edited by NinjaTrader_AdamP; 11-28-2011, 04:22 PM.Adam P.NinjaTrader Customer Service
Comment
-
ok, now it gets stuck in "Overbought" right from the beginning and doesn't change no more, it also makes an other channel with the same modification that works get stuck too
{
if( Close[0] >=MiddleTop[0])
{DrawTextFixed("TOverbought", " Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Red, Color.Red, 7);}
else
{RemoveDrawObject("TOverbought");}
if(Close[0] >= Middle[0] && Close[0] <MiddleTop[0])
{DrawTextFixed("TAOverbought", " A - Overbought", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Maroon, Color.Maroon, 7);}
else
{RemoveDrawObject("TAOverbought");}
if( Close[0] <= Middle[0] && Close[0] >MiddleBottom[0])
{DrawTextFixed("TAOversold", " A - Oversold", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.DarkGreen, Color.DarkGreen, 7);}
else
{RemoveDrawObject("TAOversold");}
if( Close[0] < Middle[0] && Close[0] >MiddleBottom[0])
{DrawTextFixed("TOversold", " Oversold", TextPosition.TopRight, Color.White, new Font("Arial Rounded MT Bold", 16), Color.Green, Color.Green, 7);}
else
{RemoveDrawObject("TOversold");}
}
Comment
-
kabott, we unfortunately could not debug this custom code for you here - best approach is simplying the script as much as possible and then printing variable / value info to the output window to better understand the sequence of events leading to the unexpected outcome you see.
Here's a tip on how to effectively use Print statements :
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment