Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 02-15-2017, 07:27 AM   #1
JerryWar
Senior Member
 
Join Date: Mar 2009
Posts: 616
Thanks: 105
Thanked 73 times in 60 posts
Default What is wrong with this ?

This worked in NT7. When I switched to NT8 I had to hard code the MasterName. I have now tried switching it back and It generates All sorts of errors wiping out All indicators from the chart . Indicators that do not use this. The code swap is as follows.

MasterName="CL";

to

MasterName=Instrument.MasterInstrument.Name.ToStri ng();

Note their is no sample in the Help guide. So is their something still not working with this.

Thanks
JerryWar is offline  
Reply With Quote
Old 02-15-2017, 07:57 AM   #2
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 10,002
Thanks: 735
Thanked 1,676 times in 1,615 posts
Default

Hello JerryWar,

Thank you for your post.

In what context is the string called after being set? Can you provide all lines of code where the string is called and in what functions?
Example:
Code:
Print(MasterName); // in OnBarUpdate
I look forward to your response.
NinjaTrader_PatrickH is offline  
Reply With Quote
Old 02-15-2017, 08:07 AM   #3
JerryWar
Senior Member
 
Join Date: Mar 2009
Posts: 616
Thanks: 105
Thanked 73 times in 60 posts
Default

dirLong=MasterName+" dirLong.wav"; // Sound wave file name would be "CL dirLong.wav"

It is then referenced in an Alert() to supply the Sound file.
MasterName, Hard coded to "CL" works, using Instrument.MasterInstrument.Name.ToString() does not.
In NT7 it works fine.
JerryWar is offline  
Reply With Quote
Old 02-15-2017, 12:38 PM   #4
JerryWar
Senior Member
 
Join Date: Mar 2009
Posts: 616
Thanks: 105
Thanked 73 times in 60 posts
Default

So it appears it only works in State==State.Dataloaded or State==State.Confirgure
All my sound file names have been set in State == State.SetDefaults because that is what is called
after you open and close the UI.

So how do I get around this ?
JerryWar is offline  
Reply With Quote
Old 02-15-2017, 03:29 PM   #5
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 10,002
Thanks: 735
Thanked 1,676 times in 1,615 posts
Default

Hello JerryWar,

Thank you for your response.

Configure would not have the instrument, you would need to use DataLoaded preferably to ensure the data is loaded and thus the instrument.

Please let me know if you have any questions.
NinjaTrader_PatrickH is offline  
Reply With Quote
Old 02-15-2017, 03:39 PM   #6
JerryWar
Senior Member
 
Join Date: Mar 2009
Posts: 616
Thanks: 105
Thanked 73 times in 60 posts
Default

As I understand it SetDefaults is the only one that is triggered by the UI so if I change the Sound file via the UI how can the Instrument Name get cancatenated if it is only available on DataLoaded which isn't triggered by the UI. How do I get around this issue ?
JerryWar is offline  
Reply With Quote
Old 02-16-2017, 09:05 AM   #7
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 10,002
Thanks: 735
Thanked 1,676 times in 1,615 posts
Default

Hello JerryWar,

Thank you for your response.

If you set the sound file by the UI then I would use a place holder string that reference a specific file, the user can then change that value in the UI. If you want the sound file based on the instrument name then you need to do so in DataLoaded.

Please let me know if you have any questions.
NinjaTrader_PatrickH is offline  
Reply With Quote
Old 02-16-2017, 10:00 AM   #8
JerryWar
Senior Member
 
Join Date: Mar 2009
Posts: 616
Thanks: 105
Thanked 73 times in 60 posts
Default

Despite the issues that causes i.e No easy way to have Sound files or any files indexed by the Root Symbol installed. It appears illogical to me. The fact you can open a UI for an indicator which has to already be installed on a chart which already has a Root Symbol an that same UI cannot know that Root symbol just doesn't make sense.
JerryWar is offline  
Reply With Quote
Old 02-16-2017, 12:30 PM   #9
koganam
Vendor
 
Join Date: Feb 2008
Posts: 6,988
Thanks: 50
Thanked 2,864 times in 2,322 posts
Default

Quote:
Originally Posted by JerryWar View Post
Despite the issues that causes i.e No easy way to have Sound files or any files indexed by the Root Symbol installed. It appears illogical to me. The fact you can open a UI for an indicator which has to already be installed on a chart which already has a Root Symbol an that same UI cannot know that Root symbol just doesn't make sense.
You may be conflating different concepts.

I am going to assume that you have multiple different files, that are named by using an instrument name prefix. eg., CLdirlong.wav, ESdirlong.wav, NQdirlong.wav et.c.

and you want the user to be able to specify the constant string partial filename that would be appended to an instrument name on the chart or calling medium.

In that case, the only part that must be specified in the PropertyGrid would be "dirlong.wav". The concatenation would have to take place when the instrument prefix is available. If you concatenate before the data is available, you will get an undesired result.

The first place that the instrument name is available to code is when the data is being loaded: State.DataLoaded. Is there any particular reason why you insist that the chart instrument, which is not yet related to the object whose PropertyGrid is now being configured should show up in the PropertyGrid that, because the object has not yet been applied to the chart, has no relation to the chart yet? The instrument on the chart is not a property of the indicator that you are applying. Why would one expect it to be in the indicator's PropertyGrid.

The indicator can only know to what chart it is applied, after it, the indicator is applied to the chart, and the chart data is being loaded. That would be the first time that the indicator can do anything with the chart-instrument's properties.
koganam
NinjaTrader Ecosystem Vendor - OmegaSigma Indicators
Last edited by koganam; 02-16-2017 at 12:33 PM.
koganam is offline  
Reply With Quote
Old 02-16-2017, 01:33 PM   #10
JerryWar
Senior Member
 
Join Date: Mar 2009
Posts: 616
Thanks: 105
Thanked 73 times in 60 posts
Default

koganam,
Thank you for your reply. you grasp exactly what I did that worked well in NT7 and does not now work in NT8. However, I am insisting on Nothing about the properties grid. I was only looking for a work around and pointing out what I believe to be a logical hole in the process. I also agree the indicator cannot do anything with chart until it reloads the data. So obviously a feature got lost in the process with NT8. If the file name is changed in the properties grid which is State.Setdefaults and Root symbol is not available until after State.dataloaded then the new file name is not known.

Unless I am mistaken there should be a new state which is something like,

If (State.Setdefaults detected && State.Dataloaded detected && Instrument.MasterInstrument.Name!=null )

{
process file names
Clear states detected
}

but I think this may have a flaw if the indicator is on the chart and the dataSeries is changed on the chart.
Last edited by JerryWar; 02-16-2017 at 01:43 PM.
JerryWar is offline  
Reply With Quote
Old 02-17-2017, 12:46 PM   #11
koganam
Vendor
 
Join Date: Feb 2008
Posts: 6,988
Thanks: 50
Thanked 2,864 times in 2,322 posts
Default

Quote:
Originally Posted by JerryWar View Post
koganam,
Thank you for your reply. you grasp exactly what I did that worked well in NT7 and does not now work in NT8. However, I am insisting on Nothing about the properties grid. I was only looking for a work around and pointing out what I believe to be a logical hole in the process. I also agree the indicator cannot do anything with chart until it reloads the data. So obviously a feature got lost in the process with NT8. If the file name is changed in the properties grid which is State.Setdefaults and Root symbol is not available until after State.dataloaded then the new file name is not known.

Unless I am mistaken there should be a new state which is something like,

If (State.Setdefaults detected && State.Dataloaded detected && Instrument.MasterInstrument.Name!=null )

{
process file names
Clear states detected
}

but I think this may have a flaw if the indicator is on the chart and the dataSeries is changed on the chart.
I am not sure that I understand why you think there is a problem, because I am doing the same thing that I did in NT7, and have no problem getting my read strings to include that chart name and period when the indicator announces what I want it to announce. I guess we must be seeing different things.

Then again, my ChartId is prepended by the code, and I do not need to see the ChartId reflected in the PropertyGrid, so we are probably talking about different things.
koganam
NinjaTrader Ecosystem Vendor - OmegaSigma Indicators
koganam is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NT8.0.0.7 Optimization Graph 3D Axis Values on wrong axis and wrong values rayko Version 8 Beta 5 01-15-2016 09:38 AM
Unrealized profit display wrong in market analyzer, entry wrong in chart trader adamus Platform Technical Support 3 06-17-2011 10:56 AM
What is wrong here? cicondo Strategy Development 1 07-21-2009 04:10 PM
What am I doing wrong? wiredfoxterror Platform Technical Support 1 07-29-2008 11:06 PM
Forex trading - wrong reporting, wrong Close action, connecting jcervinka Platform Technical Support 2 08-30-2007 09:42 AM


All times are GMT -6. The time now is 05:05 AM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content. Visit the CFTC resources for education regarding the industry and signs of fraud.