![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Apr 2009
Posts: 294
Thanks: 21
Thanked 1 time in 1 post
|
Wondering is it's possible to use the AutoTrendLine on, say, the RSI, instead of price. Is there a setting about which I don't know or can this be done by swapping out price for RSI highs and lows in the code?
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hello dsraider,
Yes, this should be possible, but you would essentially have to rewrite a swing indicator for RSI values rather market highs and lows. You set the property DrawOnPricePanel = false, and then could set the Y values they're drawn on according to RSI values to have these drawn in an indicator panel.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Apr 2009
Posts: 294
Thanks: 21
Thanked 1 time in 1 post
|
Thanks for your reply, Ryan. Is there anything I would need to change other than Highs and Lows? Meaning, would going from (High[0]) to (RSI(High[0])) and the same for "Low" take care of the Swing Indicator end?
Thanks, Dave |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Unfortunately, I'm not sure the exact changes needed to move the swing indicator from price as its basis to RSI. The autotrendline indicator works closely with swing, so you would have to look at both and determine the changes needed.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Apr 2009
Posts: 294
Thanks: 21
Thanked 1 time in 1 post
|
Okay, I'm not sure if this is exactly what you meant but I THINK I made the Swing Indicator correctly (RaiderSwing in Panel 2).
However, as you can see, when I changed "Swing" to "RaiderSwing" in the Trendline indicator code, I did something wrong. It looks as if it's using price instead of RSI readings. Do I need to change something other than the Swing indicator to which the Trendline refers? |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Great progress on the swing indicator modified for RSI. I'd look at the places in the AutoTrendLine code where it draws at highs and lows and see if you can adjust to draw instead at RSI values.
DrawRay("UpTrendLine", upTrendStartBarsAgo, startBarPrice, upTrendEndBarsAgo, endBarPrice, UpTrendColor, DashStyle.Solid, LineWidth); DrawArrowDown("UpTrendBreak", barsAgo, High[barsAgo] + TickSize, Color.Blue); DrawRay("DownTrendLine", downTrendStartBarsAgo, startBarPrice, downTrendEndBarsAgo, endBarPrice, DownTrendColor, DashStyle.Solid, LineWidth); DrawArrowUp("DownTrendBreak", barsAgo, Low[barsAgo] - TickSize, Color.Blue);
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Apr 2009
Posts: 294
Thanks: 21
Thanked 1 time in 1 post
|
Ryan,
First, apologies for my last message. I posted it before I saw yours. I did notice one thing, though. My swing dots don't really line up (as indicators don't show highs and lows, only close). Maybe I'd be better using Close instead of High and Low or would that mess everything up? I did get the trendline to draw on the RSI but I obviously need to keep working on it... Thanks. |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Apr 2009
Posts: 294
Thanks: 21
Thanked 1 time in 1 post
|
It LOOKS like that did it (changing High and Low to Close).
I'll watch for awhile and make sure it works. If so, I'll post. Well, maybe I'll try and give the option for other indicators first, if I can figure out how. Thanks for the pointers, Ryan. Dave |
|
|
|
|
|
#9 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Thanks for the update and glad to hear you've been able to adapt auto trend line for this. It will be a nice addition to the filesharing section if everything ends up checking out on your side.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Apr 2009
Posts: 294
Thanks: 21
Thanked 1 time in 1 post
|
Hi Ryan,
In trying to enumerate the indicators, I'm getting the following error message: The namespace '<global namespace>' already contains a definition for 'IndicatorMethod' Here's what I have so far: PHP Code:
|
|
|
|
|
|
#11 | |
|
Senior Member
Join Date: May 2008
Location: Hartford, CT. USA
Posts: 618
Thanks: 13
Thanked 24 times in 18 posts
|
dsraider,
I'm pretty sure that every enum needs have an unique name associated with it. RJay Quote:
|
|
|
|
|
|
|
#12 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi Dsraider,
This reference sample offers an example implementation of this. As RJay says the enums must be unique, meaning only declared one time throughout the program. The message you're getting suggests that you're using that name elsewhere.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Apr 2009
Posts: 294
Thanks: 21
Thanked 1 time in 1 post
|
Thanks, guys, though I'm starting to think there's a better way, using "If" statements. In the meantime, while I'm taking baby steps, is there a way to call an indicator to plot?
Right now I'm adding the RSI and then adding my TrendLine indicator on top of it in the same panel. In the end, I'd like to have it add both once the indicator is selected from a drop down list. Any chance there's an example of that? Thanks, Dave |
|
|
|
|
|
#14 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Indicator plots are Set and you can use any of your existing indicators or other data series to set the plots of another.
You can conditionally set your plots based on a case with enums or with an if statement. Enums will work the best because you can populate a list of available items that will appear in a drop down list and then base your plot on this selection. You can set multiple plots within the switch statement of your enums. PseudoCode below: switch (indicatorType) { // If the matype is defined as an EMA then... case indicatorType.RSI: { Plot0.Set(RSI)[0]; Plot1.Set(RSITrendLine)[0]; break; } case indicatorType.MACD: { Plot0.Set(MACD)[0]; Plot1.Set(MACDTrendLine)[0]; break; } }
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Apr 2009
Posts: 294
Thanks: 21
Thanked 1 time in 1 post
|
Thanks, Ryan, but I'm still kind of a novice at this and usually need an example in front of me as I'm guessing I'm missing a bunch of basic steps here.
If one comes to mind, please let me know. Thanks. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|