PDA

View Full Version : Two TradeStation indicators for translation, please


jtrade
09-29-2008, 07:24 AM
Here are two very simple, useful TS8 indicators that I cut and pasted together some years ago with a little help from the TS forums, ie. I'm not a programmer, so if anyone would be willing to code them in Ninjascript, I'd really appreciate it. FWIW, I emailed 3 NS Partners for a quote : two did not reply & the third quoted $400 which is above my "learn how to paste it together yourself" level !

The first is a Double Smoothed Stochastic which I use as confirmation of "trade direction & hold". The second is a double, smoothed momentum : fast (line) and slow (histogram) whch has multiple uses once you observe it awhile.

Via the two links below, I'm showing them in separate sub-windows for clarity, but in TradeStation I drag them into one window to save space (not sure if this is possible in Ninja charting, so if they could be coded as one indicator, so much the better). When combined into a single sub-window, I use the DSS scaling, not the momentum scaling.

Anyone, please ?

J.

http://www.mediafire.com/?dto2lnjj4kj
http://www.mediafire.com/?tntdtn4jnnz

NinjaTrader_Ray
09-29-2008, 07:47 AM
We have a new support rep who will provide NinjaScript support. As part of his training process, I will have him review these scripts and see if it would make sense for him to convert. Give us a week.

jtrade
09-29-2008, 07:57 AM
Thank-you, Ray !

J.

NinjaTrader_Bertrand
09-29-2008, 08:22 AM
Hi jtrade,
thanks for asking & posting those, i am reviewing them for conversion to NT.

Have a great day,
Bertrand

jtrade
09-29-2008, 08:52 AM
And thank-you, Bertrand !

J.

NinjaTrader_Bertrand
09-29-2008, 12:49 PM
Hi jtrade,
for the first part of your request I would recommend using our native Stochastics indicator, with the following inputs:
PeriodD 12, PeriodK 14, Smooth 8

I compared the values in TradeStation + NinjaTrader on a 1min ES chart and you should be fine.

Working currently on the second part of your request.

Take care,
Bertrand

jtrade
09-30-2008, 04:26 AM
Thanks Bertrand.... I just went through my notes from 2 years back and am very embarrassed to see that I ditched the double-smoothed sto for a standard one : so sorry. They are still very useful settings...

Looking forward to your fast slow momentum coding and if possible being able to display in the same window as the sto.

NinjaTrader_Bertrand
09-30-2008, 08:00 AM
Thanks Bertrand.... I just went through my notes from 2 years back and am very embarrassed to see that I ditched the double-smoothed sto for a standard one : so sorry. They are still very useful settings...

Looking forward to your fast slow momentum coding and if possible being able to display in the same window as the sto.

Hey jtrade,
no problem, we all have gone through that at times.

Please find attached the second part of your conversion request, shorter momentum will display as a line, the longer as a histogram, you can change the width as needed in the properties.

Good trading,
Bertrand

jtrade
10-01-2008, 01:03 AM
Fantastic, Bertrand : thank-you so much !

J.

qwfxny
12-27-2008, 09:02 PM
Hey jtrade,
no problem, we all have gone through that at times.

Please find attached the second part of your conversion request, shorter momentum will display as a line, the longer as a histogram, you can change the width as needed in the properties.

Good trading,
Bertrand


does anyone has this code for tradestation please

xtrender
12-29-2008, 04:51 PM
Hello, I realize this may not be the right place to ask this question, but I struggle to convert this TS code to ninja

Input:Coefdwn(2.1),Coefup(2.3);
Plot1((Average((RSI(Close,14)),6))+((Coefup*Averag e(TrueRangeCustom((RSI(Close,14)),(
RSI(Close,14)),(RSI(Close,14))),15))),"Plot1");
Plot2((Average((RSI(Close,14)),6))-(Coefdwn*(Average(TrueRangeCustom((RSI(Close,14)),
(RSI(Close,14)),(RSI(Close,14))),15))),"Plot2");

With TrueRangeCustom function code as follows:

Inputs: HPrice(NumericSeries), LPrice(NumericSeries), CPrice(NumericSeries);
Variables: THigh(0), TLow(0);
If CPrice[1] > HPrice Then
THigh = CPrice[1]
Else
THigh = HPrice;
If CPrice[1] < LPrice Then
TLow = CPrice[1]
Else
TLow = LPrice;
TrueRangeCustom = THigh - TLow;

I will appreciate Any sugestions!

Thank you and HAPPY NEW YEAR!

NinjaTrader_Josh
12-29-2008, 05:14 PM
xtrender,

We are not TS experts here. As a last resort you can also try contacting one of the 3rd party NinjaScript Consultants to get the conversion done for you: http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm

xtrender
12-30-2008, 07:11 AM
I can code a little in C# myself, however some features of ninja script is confusing to me like numericseries type in TS, what that would be in ninja script? Is it the same as dataseries?

Thank you.

NinjaTrader_Bertrand
12-30-2008, 08:44 AM
Hi xtrender, yes good spot, although this is limited to the use as input to functions in TradeStation. In NinjaScript you have the DataSeries class which generally holds a history fitting the bars present on a chart, please also see this link - http://www.ninjatrader-support.com/HelpGuideV6/DataSeriesObject.html

For our indicator building tutorials you can check here - http://www.ninjatrader-support.com/HelpGuideV6/Overview18.html

For the trueRange calculation, you can check the sharing section of this forum for the Twiggs Money Flow I posted sometime ago, parts of it are already coded in there - this may be a good starting point for you.

http://www.ninjatrader-support2.com/vb/local_links_search.php?action=show&literal=1&search=twiggs&desc=1

xtrender
12-31-2008, 08:40 AM
Thank you for your help.

Your code is precisely what I neeed, except for one unfortunate detail.
I need to pass RSI(Close,14,3)instead of price.
I have tried to wright TrueRangeCustom as a method:

publicdouble tRange(double HPrice, double LPrice, double CPrice)
{

//define the true high
if (CPrice > HPrice)
THigh = CPrice;
else
THigh = HPrice;

//define the true low
if (CPrice < LPrice)
TLow = CPrice;
else
TLow = LPrice;

//calculate the true range
double TR = THigh - TLow;
return TR;
}
double part2 =Coefup*SMA(tRange(RSI(Close,14,3),RSI(Close,14,3) ,RSI(Close,14,3)),15)[0];

I get this message: The best overloaded method match for tRange (double,double,double) has some invalid arguments... can not convert argument1,2,2 to double.
I understand this is beyond and above ...however if you can make a sugestion I will truly appreciate.

I am trying to recreate volatility bands formula...
Plot1((Average((RSI(Close,14)),6))+((Coefup*Averag e(TrueRangeCustom((RSI(Close,14)),(RSI(Close,14)), (RSI(Close,14))),15))),"Plot1");

It could be valuable to any NinjaTrader user.

Thank you and Happy New Year!

NinjaTrader_Bertrand
12-31-2008, 08:50 AM
Hi xtrender, you are welcome - Happy New Year to you as well from NinjaTrader!

You miss the correct referencing in the your RSI call so it returns a double value, please use this:


RSI(Close,14,3)[0]

serval
01-01-2009, 01:18 AM
I just discoverd this wonderfull tools, thanks for programing it !!!

I have a request if possible. Can someone help me to make change the color of the momentum if it is on up tick or downtick

Great thanks

Hey jtrade,
no problem, we all have gone through that at times.

Please find attached the second part of your conversion request, shorter momentum will display as a line, the longer as a histogram, you can change the width as needed in the properties.

Good trading,
Bertrand

NinjaTrader_Josh
01-01-2009, 01:47 PM
serval,

Unfortunately we cannot take custom programming requests. You can try one of the 3rd party NinjaScript Consultants here: http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm

Or hopefully a community member can help you out. Good luck and happy New Years!

xtrender
01-02-2009, 08:54 AM
Hello,

can not pass RSI as input to tRange method. I have tried method with Dataseries inputs , return as double and it compiles.
double r4 = tRange(RSI(Close,14,3),RSI(Close,14,3),RSI(Close,1 4,3))[0]; can not convert from NinjaTrader.Indicator.RSI to DataSeries

public double tRange(DataSeries HPrice, DataSeries LPrice, DataSeries CPrice)
{

if (CPrice[1] > HPrice[0])
THigh = CPrice[1];
else
THigh = HPrice[0];

if (CPrice[1] < LPrice[0])
TLow = CPrice[1];
else
TLow = LPrice[0];

double tr = (THigh - TLow);
return tr;
}
This TS function takes RSI(Close,14) as input
Inputs: HPrice(NumericSeries), LPrice(NumericSeries), CPrice(NumericSeries);
Var: THigh(0), TLow(0);
If CPrice[1] > HPrice Then
THigh = CPrice[1]
Else
THigh = HPrice;
If CPrice[1] < LPrice Then
TLow = CPrice[1]
Else
TLow = LPrice;
TrueRangeCustom = THigh - TLow;


Any suggestion ?

Thank you for help.

NinjaTrader_Bertrand
01-02-2009, 09:14 AM
Hi xtrender, please go back to your original posted code in post #15.

Then use this snippet below -


double part2 = Coefup * SMA(tRange(RSI(Close, 14, 3)[0], RSI(Close, 14, 3)[0], RSI(Close, 14, 3)[0]), 15)[0];

xtrender
01-02-2009, 03:33 PM
Hi Bertrand,

Thank you for help. I did make it work some how. But not with the code you have posted above. SMA does not take double as input. I still not fully understand if what I arive to is the proper translation from original code, but it looks OK.
I have changed the type of inputs for tRange to IDataSeries from DataSeries as well as this line:
r2.Set(tRange(RSI(Close,14,3),RSI(Close,14,3),RSI( Close,14,3)));
with r2 of DataSeries type.

I truly appreciate your feedback.

Thank you very much.

NinjaTrader_Bertrand
01-03-2009, 08:36 AM
Sorry for my mistake and creating confusion xtrender, great you have it gotten to working state - the real test is on live data while checking if the returned values makes sense - if you like post your code as exported zip and I take a look.

xtrender
01-08-2009, 02:14 PM
Hello Bertrand,

Sorry for delay. This is what I came up with.

I hope it make sense.

NinjaTrader_Josh
01-08-2009, 02:22 PM
xtrender,

Is there any part in particular you are seeking help on? It seems you have it working already?

xtrender
01-08-2009, 05:10 PM
Bertrand, If you have noticed, I have split the code in parts. The reason for that I was not able to write this as one calculation, in one line.
As I mention I still not sure if this is the correct translation of TS code.

Thank you.

:confused:

NinjaTrader_Bertrand
01-09-2009, 02:09 AM
Looks good xtrender - have compared the values to your TS version? That will be the ultimate test for it...maybe I hovered over it to quick, but I wasn't spotting where you feed the HLC values from the data into your tRange method....

xtrender
01-09-2009, 06:16 AM
Hi Bertrand,
I am not sure, but I think that by passing any indicator value without specific bar identifier( such as [0]) to the tRange, the method logic some how takes indicator high and substracts from indicator low. It compares CPrice, which can be any value ( price or indicator value).
But again I am not that good with programming.

On many occasions I am running into double and dataseries conversion clush. Do you know of a way to explicitely convert type double to type DataSeries? My understanding is that DataSeries type is not C# type?
Perhaps NinjaTrader could come up with a way to pass double types to Indicators where it takes DataSeries as input and vc.
That is the reason I am breaking my code in parts. For instance SMA takes Dataseries as input, but tRange method returns double.

Thank you.

NinjaTrader_Bertrand
01-09-2009, 06:30 AM
Hi xtrender, yes there is a 'conversion' from a dataseries to a double: access one dataseries element with the indexing [] you already used in your code.

Here's a good overview over the Basic Syntax - http://www.ninjatrader-support.com/HelpGuideV6/BasicSyntax.html

For more info about the DataSeries class - http://www.ninjatrader-support.com/HelpGuideV6/DataSeriesObject.html

Here's also a reference sample dealing with this topic - http://www.ninjatrader-support2.com/vb/showthread.php?t=7299

For your indicator, I would suggest comparing all your variable values with the TradeStation counterparts to ensure the calcuation was ported correctly into NinjaScript.

jtrade
01-31-2011, 02:52 AM
Hey jtrade,
no problem, we all have gone through that at times.

Please find attached the second part of your conversion request, shorter momentum will display as a line, the longer as a histogram, you can change the width as needed in the properties.

Good trading,
Bertrand

'Morning, Bertrand .. taking you back to your most excellent help in 2008, when you coded the DSM for me. I now use this in NT7, but it adds horizontal lines according to the vertical scaling. I like these lines, but would like to be able to set and fix the horizontal level from inputs within the indicator.

Would it be possible for you to do this for me, please ?

I attach a screenshot showing the lines at +10 & -5 : these levels change as I adjust the vertical axis.

NinjaTrader_Bertrand
01-31-2011, 07:35 AM
jtrade, you can simply add NT7's ConstantLine indicator to the DSM indicator panel, enter the horizontal line values needed and set AutoScale = true, so the lines are kept in view at all times since they are then part of the AutoScale range.

jtrade
01-31-2011, 07:45 AM
Thank-you very much, Bertrand, that works & is very useful to know about.

Is there any way to delete the DSM code that causes the existing variable horizontal lines to form (I don't see it when I open the indicator for editing) ?

NinjaTrader_Bertrand
01-31-2011, 07:52 AM
You're welcome, the indicator does not add them - NT would do it per default for the indicator panel, I believe you could set the horizontal gridlines in point mode at a very high value, so they effectively would not display at all - you can enter those properties with a right click in the indicator Y Axis.

jtrade
01-31-2011, 09:26 AM
Thank-you, Bertrand.