![]() |
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
|
|||||||
| Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Aug 2008
Posts: 325
Thanks: 0
Thanked 0 times in 0 posts
|
Is there a way to calculate differences between 2 SMA using strategy, and if at certain distance, the condition is true.
I only see >= and <=, but nothing says larger(smaller) by a certain tick. Any way to do this? |
|
|
|
|
|
#2 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
If it doesn't matter which SMA is above the other you can do something like...
if(Math.Abs(SMA1 - SMA2) >= someValue) { //insert logic here } if it does matter which is greater than the other just add && sma1 > sma2 or && sma1 < sma2 hope this helps |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Aug 2008
Posts: 325
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks. Yes in my case, which one is above which matters.
So I will have 2 "if"s for above, and below. |
|
|
|
|
|
#4 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
yes
if(Math.Abs(SMA1 - SMA2) >= someValue && SMA1 > SMA2) { //logic 1 here } else if(Math.Abs(SMA1 - SMA2) >= someValue && SMA1 < SMA2) { //logic 2 here } |
|
|
|
|
|
#5 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Also remember if you want "some" tick value to use TickSize.
Code:
10 * TickSize
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Aug 2008
Posts: 325
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks for advice, guys.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tick Chart Differences | Kardinal | Charting | 6 | 08-14-2008 07:15 AM |
| Help with coding Moving average differences | zphinx | Strategy Development | 1 | 05-14-2008 07:07 AM |
| Significant Differences between NT 6.0 and 6.5 Backtest Results | kgillis23 | General Programming | 1 | 03-15-2008 12:09 PM |
| ESignal & IB Decimal Differences | TraderGuy | Connecting | 3 | 12-17-2007 07:04 AM |
| Calculation differences | ThePatientOne | Strategy Development | 1 | 05-24-2007 12:07 PM |