![]() |
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: Jan 2012
Posts: 13
Thanks: 1
Thanked 0 times in 0 posts
|
Hi,
I have created a simple strategy using the Wizard. The strategy I have is when price crosses above a 50 EMA a buy will occur and when the price crosses below the EMA is triggers a sell. When backtesting it no trades occur, not sure if my code is correct. Screenshots: Code: ![]() ![]() Uploaded with ImageShack.us ![]() ![]() Thanks Ivan
Last edited by ibrown; 01-09-2012 at 11:33 AM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
ibrown,
You are adding EMA's with 0 period. You will want to use something like EMA(50), etc. Currently what you have is a CrossAbove() and CrossBelow() condition for two equal EMA's. Please let me know if I may assist further.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jan 2012
Posts: 13
Thanks: 1
Thanked 0 times in 0 posts
|
I have now added the 50 but still not getting anything.
Code: protectedoverridevoid Initialize() { Add(EMA(50)); Add(EMA(50)); Add(EMA(50)); Add(EMA(50)); SetProfitTarget("", CalculationMode.Ticks, 50); SetStopLoss("", CalculationMode.Ticks, 25, false); CalculateOnBarClose = true; } ///<summary> /// Called on each bar update event (incoming tick) ///</summary> protectedoverridevoid OnBarUpdate() { // Condition set 1 if (CrossAbove(EMA(50), EMA(50), 1)) { EnterLong(1, ""); } // Condition set 2 if (CrossBelow(EMA(50), EMA(50), 1)) { EnterShort(1, ""); } |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Jan 2012
Posts: 13
Thanks: 1
Thanked 0 times in 0 posts
|
not sure if it makes any difference I trading the EUR/USD on 24/7 session templete using a tick chart.
|
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
ibrown,
CrossAbove(EMA(50),EMA(50),1) will never occur because its basically asking, if a 50 period ema crosses above a 50 period ema. I would suggest using two different periods for the EMA. What are you trying to do? Close crossing the EMA or two EMA's crossing eachother?
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jan 2012
Posts: 13
Thanks: 1
Thanked 0 times in 0 posts
|
i am wanting to use just 1 EMA with price crossing it.
|
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
ibrown,
You probably want to use CrossAbove(Close,EMA(50),1) and CrossBelow(Close,EMA(50),1). Please let me know if I may assist further.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Jan 2012
Posts: 13
Thanks: 1
Thanked 0 times in 0 posts
|
not sure what to do next. can't work out how to do it in the Wizard but I haven't compiled or clicked unlock code.
|
|
|
|
|
|
#9 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
ibrown,
Please see the attached screenshot. It should show you how to implement the CrossAbove condition. Please let me know if I may assist further.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Jan 2012
Posts: 13
Thanks: 1
Thanked 0 times in 0 posts
|
|
|
|
|
|
|
#11 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
ibrown,
I am happy you have resolved your issue. Here is a youtube video on automated strategy development : https://www.youtube.com/watch?v=fVFq...1&feature=plcp Please don't hesitate to contact us should you require additional assistance.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_AdamP for this post: |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Strategy not working | trader413 | Strategy Development | 15 | 06-27-2011 10:43 AM |
| Strategy not working correct | L. Williams | Strategy Development | 3 | 05-11-2011 11:09 AM |
| Strategy not working | deurich | Version 7 Beta General Questions & Bug Reports | 2 | 02-12-2010 09:23 AM |
| Strategy not working?? | raycam | Strategy Development | 4 | 07-09-2009 05:03 AM |
| strategy analyser not working with my strategy | junkone | Strategy Analyzer | 9 | 05-31-2009 01:37 PM |