NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 03-24-2009, 09:15 AM   #1
marketstudent
Member
 
Join Date: Nov 2008
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default Simple Strategy is not triggered

I created a simple strategy to play a sound and draw a text on the chart when price crossovers weighted moving average, and this strategy is started within the strategies tab in Control Center. However, this strategy is never triggered, below is code

Thanks!


// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class HSICrossover : Strategy
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#endregion

/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{

CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(Close, WMA(Close, 13), 1))
{
PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\Alert3.wav");
DrawText("Crossover" + CurrentBar, "Crossover", 0, 0, Color.Red);
Log("Crossover occurred", LogLevel.Information);
}
}

#region Properties
#endregion
}
}
marketstudent is offline  
Reply With Quote
Old 03-24-2009, 09:26 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

marketstudent,

Please check the Control Center logs for errors. Remember your strategy is only true when the close price crosses above the WMA.
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple question about a simple strategy. shakira Strategy Development 1 02-14-2009 10:56 AM
Simple strategy rnr123 Strategy Analyzer 1 10-17-2008 07:04 AM
need help with simple strategy mike8943 Strategy Development 1 07-17-2008 08:21 AM
OnBarUpdate triggered by historical bars when starting strategy chyap General Programming 1 07-01-2008 11:06 PM
Simple Strategy Oli Automated Trading 2 03-05-2007 11:42 PM


All times are GMT -6. The time now is 11:47 AM.