![]() |
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
|
|||||||
| NinjaScript File Sharing Discussion Discussion for shared NinjaScript files. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Mar 2007
Posts: 212
Thanks: 0
Thanked 3 times in 3 posts
|
I try to port an existing VSA Indicator from an Amibroker code. Anyone can check the AFL File to see if the port is good?, first time working with Ami codes. Also comments from VSA Fans are welcome to see if we can have a useful indicator
![]() Here you can find the Original code: http://www.vpanalysis.blogspot.com/ PD Thanks Roonius for the fix in the shading routine. ![]() Regards
Last edited by PrTester; 01-04-2009 at 03:35 PM.
Reason: update File
|
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Dec 2004
Location: , ,
Posts: 224
Thanks: 0
Thanked 11 times in 8 posts
|
Here is my take on the same AmiBroker code.
Notes: I coded a Wilder MA indicator that is included in the attached file. I also used LinRegSlopSFX to find the slope. Also, I used a slightly different color scheme to paint the bars with. |
|
|
|
|
The following user says thank you to scjohn for this post: |
|
|
|
#3 | |
|
Senior Member
Join Date: Mar 2007
Posts: 212
Thanks: 0
Thanked 3 times in 3 posts
|
Quote:
I will check it and revise, he, he.Best Regards, and Happy Holidays. |
|
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Mar 2007
Posts: 212
Thanks: 0
Thanked 3 times in 3 posts
|
With the help of scjohn code I made some updates and fix to my port, uploaded in the first post.
|
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
|
Thanks PrTester and scjohn, great work!
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Mar 2008
Location: UK West Sussex
Posts: 665
Thanks: 9
Thanked 9 times in 7 posts
|
great code and thanks for sharing.
Code:
// Price information upbar.Set(Close[0] > Close[1] ? true : false); dnbar.Set(Close[0] < Close[1] ? true : false); Cloc=Close[0]-Low[0]; x=spread[0]/Cloc; x1 =( Close[0] - Low[0] == 0.00 ? arg[0] : x ); |
|
|
|
|
|
#7 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Potentially double.Epsilon issues: http://www.ninjatrader-support2.com/...ead.php?t=3929
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Mar 2008
Location: UK West Sussex
Posts: 665
Thanks: 9
Thanked 9 times in 7 posts
|
Interesting. How does the close/low ever equal something that was not traded? I assume that NT just takes the transmitted data price ( in my case IB)?
eg close = 2157. It can't equal for example 2157.000000001 or can it? Would the correct code therefore be nb I have now removed the cloc variable altogether Code:
if (Instrument.MasterInstrument.Compare (Close[0], Low[0]) == 0
{x = 0;}
else
{x = range[0] / (Close[0] - Low[0]);}
Dollars are in the detail.
Last edited by Mindset; 01-05-2009 at 11:21 AM.
|
|
|
|
|
|
#9 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
When you do any subtraction, multiplication, etc with double values they can end up not equaling zero exactly. Long story short, you have to be mindful of the double.Epsilon. This is a more technical C# topic. For more information try combing through google.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Mar 2008
Location: UK West Sussex
Posts: 665
Thanks: 9
Thanked 9 times in 7 posts
|
Ok but just to confirm if Low[0] = 1234 then it always equals 1234 unless you start to manipulate it. NT doesn't do any "data processing" of it's own?
In which case, Close[0] = low[0] could return zero - and I am right back to the original query - how is the div by zero error avoided? I am not being difficult but I need to understand. |
|
|
|
|
|
#11 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
NT does not change the data it receives. Your check for 0 is already manipulating it. Close[0] - Low[0] is stored into your temp variable. That temp variable is no guaranteed to be 0.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Mar 2008
Location: UK West Sussex
Posts: 665
Thanks: 9
Thanked 9 times in 7 posts
|
Well I spent some time last night testing out this data concept and it appears you are right - 3.56 - 3.55 does not equal .01 difference.
It often has rogue digits 4,5 or even 10 decimal places away! One thing however - where close and low were equal my print statement always returned zero. But now I don't know whether that really is a true zero or has some weird digit 17 decimal places away that I can't see ( I understand that double values go approx 15- 16 decimal places?)
Last edited by Mindset; 01-06-2009 at 09:09 AM.
Reason: sp
|
|
|
|
|
|
#13 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Mindset,
This is C# and the concept revolves around double.Epsilon. It may be best for you to research this matter on MSDN. Unfortunately I cannot provide any more assistance on this.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#14 |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
Hello Mindset,
when I have to use price bar numbers heavily for calculations then I convert them into the tick representation before usage. That also avoids these special double-issues. Regards Ralph |
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Mar 2008
Location: UK West Sussex
Posts: 665
Thanks: 9
Thanked 9 times in 7 posts
|
Do you mean TickSize?
Perhaps you could show an example? |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VSA indicator request | dokebilee | Indicator Development | 8 | 01-11-2010 10:37 AM |
| VSA - Volume Spread Analysis | markm | NinjaScript File Sharing Discussion | 4 | 12-30-2008 06:12 PM |
| VSA Trade Alerts | kronie | Indicator Development | 3 | 11-17-2008 12:11 PM |
| 6.5 Beta 6 - the same downloaded file as Beta 5 | cmrodrig | Historical NinjaTrader 6.5 Beta Threads | 4 | 01-17-2008 02:05 AM |
| Beta 6.5 | pgabriel | Historical NinjaTrader 6.5 Beta Threads | 17 | 11-26-2007 02:52 PM |