![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Dec 2008
Posts: 25
Thanks: 0
Thanked 0 times in 0 posts
|
I am having a puzzling time figuring out some NT performance errors. I have a simple strategy that enters a LONG trade when several indicators are all moving UP. The reverse is true for SHORT trades. However, I am finding several instances where NT executes a LONG trade when the SMA is actually going DOWN. Yikes! I have attached a screen shot to illustrate. The gold line is the SMA of price. It is clearly going DOWN, but NT executes a LONG trade. Here is the code from the strategy:
protected override void OnBarUpdate() {... double sma1 = SMA(Close, periodMovingAverage)[1]; double sma0 = SMA(Close, periodMovingAverage)[0]; ... bool HigherSMA = false; ... if(sma0 > sma1) HigherSMA = true; ... If(HigherSMA) {EnterLongLimit(...)} Any ideas why NT enters a LONG trade when the condition is visibly not met? I have confirmed the action by manually observing the SMA values in the data box. SMA is definitely going down, not up. Thanks for your feedback, D |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
You should print the values of your bools each step of the way and isolate what is happening under the hood.
Print(HigherSMA);
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| getting out of a trade going the wrong way | paschall | Strategy Development | 1 | 09-14-2009 12:47 AM |
| Strategy: Using Rising and Falling conditions in the Strategy Wizard | NinjaTrader_Josh | Reference Samples | 0 | 08-05-2009 01:43 PM |
| Strategy conditions | jthom | ATM Strategies (Discretionary Trading) | 20 | 06-11-2009 12:54 PM |
| Strategy executes differntly backtest vs live | latkinso | Strategy Development | 7 | 05-19-2008 07:13 AM |
| Strategy: Halting a Strategy Once User Defined Conditions Are Met | NinjaTrader_Josh | Reference Samples | 0 | 01-04-2008 12:09 AM |