PDA

View Full Version : Dot color problem


tortexal
06-20-2009, 11:01 PM
Plots perfectly but all the dots are green :D

protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.SpringGreen), PlotStyle.Dot, "Plot0"));
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Dot, "Plot1"));
}

protected override void OnBarUpdate()
{
if (CurrentBar < 1)
return;

if(a > 0 && b > 0)
{
Plot0.Set(High[0]);
}

if (a < 0 && b < 0)
{
Plot1.Set(High[0]);
}

}

it's probably something silly

NinjaTrader_Bertrand
06-22-2009, 06:15 AM
tortexal, are your conditions properly triggering the Plot1 part? Perhaps you also need to add a neutral Plot as in this sample - http://www.ninjatrader-support2.com/vb/showthread.php?t=3227

tortexal
06-22-2009, 07:09 AM
you may be right on the neutral/inbetween dot. I output window'd all the math again to confirm and it's correct. For the time being I made another indicator to plot the 2nd part separately, both now work as they should. I will try the neutral dot AH and report back

bert1
06-22-2009, 11:19 AM
Im trying to create a predictive average with dots, ensign has such an indicator but I have no idea how to write. Been trying all morning and downloaded your 3 color MA which is very close I just cant open to see how to write it...could you help please? thanks.
Bert

NinjaTrader_Bertrand
06-22-2009, 11:23 AM
Welcome to our support forums bert1 - you can open the downloaded indicator by going to Tools > Edit NinjaScript > Indicator. This will open the NinjaScript editor and you can review and amend the code you have. For some great tutorials regarding indicator coding in NinjaScript, please check this link - http://www.ninjatrader-support.com/HelpGuideV6/Overview18.html

bert1
06-22-2009, 12:00 PM
thank you, unfortunately the code I have is drop down boxes, some Ive spent last 6 hours trying to create this. I'll look again at this turtorial but so far it hasnt sunk in. :-(

Thanks
Al

NinjaTrader_Bertrand
06-22-2009, 12:03 PM
You can also take a look at the sharing section to see if it has already been created - http://www.ninjatrader-support2.com/vb/forumdisplay.php?f=37

If you need this professionally coded for you, I suggest you contact one of those consultants - http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm

bert1
06-22-2009, 12:17 PM
thank you for your help, much appreciated
Bert

bert1
06-22-2009, 04:26 PM
One last question, I have an indicator that came from Metatrader based on RSI...Is a code from Meta very difficult to translate for ninja? Also it may be possible that I can get the code for tradestation on same indicator, would that be closer to the ninja language?
Thanks again
Bert

NinjaTrader_Bertrand
06-23-2009, 05:32 AM
Hard to say per se, depends on how familiar you are with MQL4 or Easy Language...most of the needed functions and methods are available per default with NinjaTrader, so I guess the TradeStation code might be easier to follow for a conversion / recreation of the indicator using NinjaScript.

bert1
06-24-2009, 04:56 PM
Thanks, I got a copy of the tradestation code, its a simple idea. Ive been through the tutorials but still dont see how to create plots over an indicator. What I trying is this, Id like to use the RSI as the base indicator without showing the RSI line...but rather use several EMA's based on RSI to create a cross similar to MACD. Could you perhaps give me a starting point by posting a code similar to this idea?

Thanks Again
Bert

NinjaTrader_Bertrand
06-25-2009, 05:29 AM
Hi Bert, here's a quick idea to get you started - open the MACD indicator, right click in it and save it under a new name. Then replace instances of the code Input with RSI(C, 10, 1) and leave the [0] part intact, as you need this as a double value. Then hit F5 to compile your new code....this should give you a MACD running on RSI...feel free to play around with other combinations and parameters as you need it.

bert1
06-25-2009, 11:39 AM
thanks, tried it but maybe not changing "Input" correctly as it looks excactly like regular MACD. Its this that I trying to acomplish...use RSI as base indicator but only show 3 EMA's that are offset of each other and derived from the RSI values. Ive played around with this to the point of giving up. I used the tutorial of SMA on VOL but it's not even close to working as I get errors when I use // Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(RSI(14, 1)[0]);
Plot1.Set(Plot0[0]);
Plot2.Set(Plot1[0]);
I have tradestation code is there a way to translate it to ninja trader?

NinjaTrader_Bertrand
06-25-2009, 12:02 PM
bert1, you can delete Plot1 and Plot2 and just try this as a start in the OnBarUpdate() -


Plot0.Set(MACD(RSI(Close, 10, 1), 10, 20, 5)[0]);


An EMA of this would look like this -

Plot0.Set(EMA(MACD(RSI(Close, 10, 1), 10, 20, 5), 10)[0]);

bert1
06-25-2009, 02:01 PM
Thanks Again, I think its working!!! :-)
Bert

bert1
06-25-2009, 06:43 PM
ok, thought of one last question, sorry :-), how would I set this indicator to show a max 100 and min 0 just like RSI?

Thanks again for the help, the last code you sent is what made the engine click

Bert

NinjaTrader_Bertrand
06-26-2009, 05:19 AM
Changing the scale is unfortunately not supported with NinjaTrader 6.5 - in NinjaTrader 7 you'll get access to more options in this regard - http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html

For now you could use a range bound indicator like the RSI on your custom MACD or work with this posted addon script - http://www.ninjatrader-support2.com/vb/showpost.php?p=76927&postcount=1

bert1
08-12-2009, 08:45 PM
bert1, you can delete Plot1 and Plot2 and just try this as a start in the OnBarUpdate() -


Plot0.Set(MACD(RSI(Close, 10, 1), 10, 20, 5)[0]);


An EMA of this would look like this -

Plot0.Set(EMA(MACD(RSI(Close, 10, 1), 10, 20, 5), 10)[0]);

This worked but I need to displace one of the lines, when I add
Displacement = 3; it displaces all 3 lines...How do I displace just one of my lines?

bert1
08-12-2009, 08:45 PM
Changing the scale is unfortunately not supported with NinjaTrader 6.5 - in NinjaTrader 7 you'll get access to more options in this regard - http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html

For now you could use a range bound indicator like the RSI on your custom MACD or work with this posted addon script - http://www.ninjatrader-support2.com/vb/showpost.php?p=76927&postcount=1

This worked but I need to displace one of the lines, when I add
Displacement = 3; it displaces all 3 lines...How do I displace just one of my lines?

NinjaTrader_Bertrand
08-13-2009, 04:55 AM
You can of course also manually displace a plot, for example a displacement of 1 bar -


Plot0.Set(MACD(RSI(Close, 10, 1), 10, 20, 5)[1]);

bert1
08-13-2009, 05:49 AM
You can of course also manually displace a plot, for example a displacement of 1 bar -


Plot0.Set(MACD(RSI(Close, 10, 1), 10, 20, 5)[1]);


I wanted to displace 3 bars to right, so I did this;
Plot1.Set(EMA(EMA(Plot0, 3),3)[0]);
Plot2.Set(SMA(EMA(EMA(EMA(Plot1,3),3),3),5)[3]); But then indicator doesnt show up??? And I loose the RSI scale
Thanks

NinjaTrader_Bertrand
08-13-2009, 06:15 AM
For a displacement of 3 bars you would need to add this check to the start of your OnBarUpdate() then -


if (CurrentBar < 3) return;



http://www.ninjatrader-support2.com/vb/showthread.php?t=3170

bert1
08-13-2009, 06:34 AM
For a displacement of 3 bars you would need to add this check to the start of your OnBarUpdate() then -


if (CurrentBar < 3) return;



http://www.ninjatrader-support2.com/vb/showthread.php?t=3170


like this?
Plot1.Set(EMA(EMA(Plot0, 3),3)[0]);
if (CurrentBar < 3) return;
Plot2.Set(SMA(EMA(EMA(EMA(Plot1,3),3),3),5)[0]);

bert1
08-13-2009, 06:41 AM
like this?
Plot1.Set(EMA(EMA(Plot0, 3),3)[0]);
if (CurrentBar < 3) return;
Plot2.Set(SMA(EMA(EMA(EMA(Plot1,3),3),3),5)[0]);


got it , it worked thanks! was missing the [3]

NinjaTrader_Bertrand
08-13-2009, 06:48 AM
Great you got it working.

bert1
08-13-2009, 06:50 AM
Great you got it working.


YES! MUCH THANKS!:)