![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Nov 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
Ok let's say I want to compare the current MACD value to the previous value:
double macd1 = MACD(period1, period2, smooth).Avg[0]; double macd2 = MACD(period, period2, smooth).Avg[1]; if (macd1<macd2) {do something} macd1 seems to be computing fine but macd2 is not. Where am I messing up? Thanks! |
|
|
|
|
|
#2 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
I think...
Code:
double macd2 = MACD(period, period2, smooth)[1].Avg;
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"
PureLogikTrading |
|
|
|
|
|
#3 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
Try adding this before the condition: Print(macd1 + " macd1"); Print(macd2 + " macd2"); Then go to Tools>Output Window and see what prints when the strategy is running. If that doesn't work try printing your macd parameters before they are assigned to macd1 and macd2. Another possible issue may be that you do not have enough bars to calculate the macd. Please review this link: http://www.ninjatrader-support2.com/...ead.php?t=3170
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Nov 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
When I put this in I get nothing
Print(macd1 + " macd1"); Print(macd2 + " macd2"); If I remove the macd2 line I get all the values for macd1 in the output window. |
|
|
|
|
|
#5 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
I think what ben means is the following
Code:
Print("MACD1 = " + macd1.ToString());
Print("MACD2 = " + macd2.ToString());
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"
PureLogikTrading |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
The issue is probably arising from not adding if(CurrentBar > some_number) return; at the top of the OnBarUpdate() block.
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Nov 2008
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| barsAgo | NinjaCustomer | Indicator Development | 2 | 05-19-2008 07:24 AM |
| Noob questions... | FubaR | Miscellaneous Support | 1 | 04-02-2008 10:49 AM |
| How to Plot a Dot 50 BarsAgo | robhef | Indicator Development | 2 | 01-21-2008 02:30 PM |
| Retrieve Indicator Value n BarsAgo | TAJTrades | Indicator Development | 1 | 12-27-2007 04:27 AM |
| barsago error | Jim-Boulder | Strategy Development | 1 | 10-18-2007 02:17 PM |