PDA

View Full Version : Strategy not working correct


L. Williams
05-11-2011, 09:18 AM
I have created a simple strategy that should buy when the price is above a SMA 60 AND SMA 240.

Then it should exit when the price hits the SMA 60 or SMA 240 again


When I backtest this there are alot of trades that qualify for these conditions but are not traded. Also the entry point and exit point are not correct.

Why?

I have been trying to find a solution for several days now.

http://www.filethief.com/download/4616/strategy.cs.html

NinjaTrader_RyanM
05-11-2011, 09:24 AM
Hello L.Williams,

Welcome to the NinjaTrader forums. You can attach small files directly to this forum with the paper clip icon when composing posts.

What you will want to do here is follow a debug procedure to track what your strategy is doing. Use plenty of Print() statements to verify values are what you expect.

Add TraceOrders = true to your Initialize method and you can then view output related to strategy submitted orders through Tools > Output window.

It may also help to add drawing objects to your chart for signal confirmation. Additional help for these items is available at the following links:

Debugging your NinjaScript code. (http://www.ninjatrader.com/support/forum/showthread.php?t=3418)
TraceOrders (http://www.ninjatrader.com/support/forum/showthread.php?t=3627)
Drawing Objects. (http://www.ninjatrader.com/support/forum/showthread.php?t=3419)

L. Williams
05-11-2011, 10:06 AM
Thanks for your quick response
Unfortunately I have no skills in programming at all.
Which is the main reason I choose Ninjatrader.
I can however post screenshots of the simple strategy I created, would that help?

NinjaTrader_RyanM
05-11-2011, 11:09 AM
NinjaTrader's automated trading engine is built with C#, a full programming language. You can use the condition builder to get started without programming (http://www.ninjatrader.com/support/helpGuides/nt7/strategy_wizard.htm), but a complete evaluation of your strategies functionality will require a bit of working with code. TraceOrders is very useful for tracking strategy order submission and requires unlocking code.

If you're not yet ready to work with code, you can use the actions Draw and Print to output window to track what your strategy is doing. Adding visual confirmation through drawing objects can be helpful, and you can still print values to the output window using only the strategy wizard.

Since you're just getting started, it's also helpful to simplify a good deal the conditions you're evaluating. Use only one condition for entry until you verify everything works as you expect and then start adding additional conditions.