![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Member
Join Date: Jan 2009
Posts: 96
Thanks: 0
Thanked 0 times in 0 posts
|
Hello
I'm at a very early stage of learning NT script. I was able to find an indicator that I could modify and everything works except for one issue. The price will only show up to two decimals places and I need four. I'm referring to the price label and the scale (only showing 1.7 now, it needs to be 1.700, please see the "2 decimal" attachment). I only had to change the mathematical equation, no variables were added or changed. Also I have attached the modified indicator "Marketsentiment" which was taken from the "Spread" indicator. This is the line that I modified: Code:
Value.Set((Instrument2Close[0] / (Closes[Instrument1][0] * mul1 + Instrument2Close[0] * mul2)) / (Closes[Instrument1][0] / (Closes[Instrument1][0] * mul1 + Instrument2Close[0] * mul2))); Code:
//Value.Set(Closes[Instrument1][0] * mul1 + Instrument2Close[0] * mul2); // set output using synchronized data series Thanks |
|
|
|
|
|
#2 |
|
Member
Join Date: Jan 2009
Posts: 96
Thanks: 0
Thanked 0 times in 0 posts
|
I found this:
Code:
public override string FormatPriceMarker(double price)
{
// Formats price values to 4 decimal places
return price.ToString("N4");
}
|
|
|
|
|
|
#3 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 977 times in 960 posts
|
Yes, this should do the job for you, for example this SMA below would show 4 digits as well -
Code:
protectedoverridevoid OnBarUpdate()
{
Value.Set(SMA(20)[0]);
}
publicoverridestring FormatPriceMarker(double price)
{
// Formats price values to 4 decimal places
return price.ToString("N4");
}
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Member
Join Date: Jan 2009
Posts: 96
Thanks: 0
Thanked 0 times in 0 posts
|
That worked!
TY! |
|
|
|
|
|
#5 |
|
Member
Join Date: Aug 2011
Posts: 45
Thanks: 11
Thanked 0 times in 0 posts
|
Hello,
I am trying to format ATR to 2 decimal places. I tried to use the code supplied by NT_Bertrand below, obviously will amend from 4 decimal to 2 decimals. I copied the code as it is into and NT Script, and got error CS0246, "The type or namespace name publicoverridestring could not be found (are you missing a using directive or an assembly reference?)" . Referring to the help menu suggested I re-imported a 3rd party dll. I see this code was in reply to a question back in 2010, is this code still applicable to the current version of NT? If it is, then where do I import this 3rd party DLL from, or any other suggestion on a way to go about formatting the decimal places? Thanks Dan |
|
|
|
|
|
#6 |
|
Member
Join Date: Aug 2011
Posts: 45
Thanks: 11
Thanked 0 times in 0 posts
|
Ok, I have come up with the following for what I want, though not sure how it's different from the code posted by NT_Bertrand. Of course, I am still at the very early learning stage of NTScripts and C#
![]() Code:
Value.Set(Math.Round(ATR(14)[0],2)); |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Code Snipet: Show to show one Dropdown InstrumentList selectable in chart | jatubio | General Programming | 19 | 07-31-2012 10:12 AM |
| NT Strategy places Orders in the past | Obi | Strategy Development | 1 | 04-08-2009 11:52 AM |
| TradeStation Reentrancy Error - places orders for wrong symbol | Idruna | Automated Trading | 3 | 02-12-2009 12:28 PM |
| Is there a way to see 2 decimal places in SMA? | gsmaster | Charting | 1 | 05-02-2008 12:25 PM |
| Finding decimal places | sbgtrading | General Programming | 3 | 11-25-2007 07:29 PM |