View Full Version : Using a custom indicator
SuzyG
01-22-2007, 10:26 AM
How do Iaccess a custom indicator in my strategy when I do not have the source code? I added the .dll to the strategy script using "references". When I refer to it as I would any indicator, I get this error:
'NinjaTrader.Indicator.Name' is a 'type' but is used like a 'variable'
I don't know what this means.
Thanks.
NinjaTrader_Ray
01-22-2007, 10:55 AM
Hi SuzyG,
Please refer to the HelpGuide > NinjaScript > Distributing Custom NinjaScript Indicators > Distribution Step 5
You should have a DLL and a Vendor file (two files) from the source of the custom DLL provider. If you do not, please contact the vendor.
Ray
SuzyG
01-22-2007, 11:13 AM
I have a .cs file in bin\custom\indicator and a .dll in bin\custom. I still don't get how I can refer to the indicator.
NinjaTrader_Ray
01-22-2007, 11:57 AM
If you have the required files, within your strategy, you can type "this." and you will see all methods and properties of the strategy which should then include the custom indicator. You can then select the method and go from there. If you do not see this, please let me know.
SuzyG
01-22-2007, 01:35 PM
No, I see ones I have created, but notcustom indicatorsfroma vendor.
NinjaTrader_Dierk
01-23-2007, 12:31 AM
Let's start from scratch.
a) Do you want to reference a custom indicator you coded by yourself -> make sure you coded this indicator using NT6B5 or later, then you simply can reference liek Ray said by typing"this."
b) Do you want to reference a custom indicator which was coded by a vendor -> the vendor tehn should have build this indicator with NT6B5 or later and should have provided you 2 files as per documentation Ray referenced below
If none of above is correct, then likely indicator was not build using NT6B5 or later, in this case you can not reference the custom indicator.
SuzyG
01-26-2007, 02:45 AM
a) I can see the indicators I have coded. "This." shows them.
b) Yes, this is my trouble. In this case, I do have the source code and one compiled .dll. I have opened the source code and re-compiled in the 6.0.0.6 version. I still do not see it with "this." nor can I reference it in my scripts.
Since I have the source code, I should be able to do something with it. It seems like recompiling it should have worked. ??
Thank you.
NinjaTrader_Ray
01-26-2007, 02:58 AM
When you say you have source file, do you mean the actual indicator file itself? If yes, make sure you remove any DLL that was provided to you. Restart NT. Save the indicator file in C:\Program Files\NinjaTrader 6\bin\Custom\Indicator, open it, compile it, then it will be available.
Ray
SuzyG
02-24-2007, 12:02 PM
Hi Ray,
I did what you suggested and do not have the vendor's .dll in bin\custom. I have the source .cs or maybe part of it. I am not sure. It contains calculations, etc. There is no NinjaScript generated code. Since the generated code is missing, what does this mean? I can use the indicator on my chart, but not see it when I type this. or access it from within a strategy or indicator.
Thank you,
SuzyG
NinjaTrader_Ray
02-25-2007, 03:13 AM
If you have the source, then just compile it and you will be able to use within other indicators or a strategy. If you don't have the source and only the DLL then you must request the Vendor file from the vendor.
Ray
SuzyG
02-25-2007, 05:01 AM
Yes, I should have clarified that. I did compile it.
Irebuilt it so I could get the generated code and now it works. Thank you for your help.
DarrylT
03-13-2007, 09:50 AM
Hi,
I think my question is related to this topic. I have a custom indicatorwhose valueI want to use in a strategy. In the strategy Initialize method I've got:
Add(MyIndicator(1, 4, false, 80));
Then in the OnBarUpdate I tried:
tradingPrice = this.MyIndicator.Value;
to obtain the indicator value, so I didn't have to duplicate the indicator code in the strategy. But this gives a compile error saying:
"'NinjaTrader.Strategy.Strategy.MyIndicator(int, double, bool, int)' is a method, which is not valid in the given context."
Is there a better way to obtain the included indicator value?
Thanks,
Darryl
NinjaTrader_Ray
03-13-2007, 09:55 AM
Try
tradingPrice = this.MyIndicator.Values[0];
NinjaTrader_Ray
03-13-2007, 09:56 AM
My mistake:
tradingPrice = this.MyIndicator.Value[0];
DarrylT
03-13-2007, 09:59 AM
Yes, I tried that also, gives the same compile error.
Thanks,
Darryl
NinjaTrader_Ray
03-13-2007, 10:07 AM
I assume you did this -
tradingPrice = MyIndicator(1, 4, false, 80).Value[0];
DarrylT
03-13-2007, 10:22 AM
Well, no, I didn't, since that looks like another invocation. I thought after doing
Add(MyIndicator(1, BidAskRatio, false, 80));
that the values could be retrieved using
tradingPrice = MyIndicator.Value[0];
The good news is that trying this latest suggestion, doing
tradingPrice = MyIndicator(1, 4, false, 80).Value[0];
in the strategy works. Now my strategy code has both the Add of the indicator and the reference with inputs.
The catch now is that the indicator isn't dispaying on the chart (though I am able to see the indicator values in the strategy). When I add the indicator by itself it does show on the chart, but when used from the strategy it does not.
Thanks,
Darryl
NinjaTrader_Ray
03-13-2007, 10:59 AM
Are there any error messages in the log? If not, could you email me the indicator?
Ray