Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Backtesting a strategy
Collapse
X
-
Backtesting a strategy
I have used the wiz to create a simple strategy and I am trying to backtest it. The only indi I want to use is Williams %R. The lines in %R are at -25 and -75. When I try to get these negative values into the tester, it shows the parameters for these values as '1' in each case and not the negative values specified. How can I make these negative numbers? The tester does not work at present with the 1 as shown. -
Backtesting a strategy
Hi Bertrand
Your suggestion worked well but unfortunately the strategy sucks!! It was really only to have a go at using the Wiz to write a strategy. I usually trade FX because the hours suit me better in Aus but I am looking at FESX as Europe opens at a more civilised hour!! NY does not open until 11.30pm or 12.30am my time, (depending on DST), so its a bit hard to fire up at that time of night!!
Thanks for your help.
Karl
Comment
-
Hi Bertrand
I have been persevering with Williams%R filtered with a couple of other indis but I want to generate an alert and show an arrow when the W%R crosses the upper or lower lines. I have used the wiz but cannot generate a sound or draw the arrow. Computers are so frustrating and the hours one can spend trying to do things by trial and error!! The code generated by the wiz is below. I want the alert when the PA first crosses the line not just at end of the bar. I can then watch and decide on action to take - or not.
Would you be so kind as to have a look and see if you can suggest what I may be doing incorrectly. Thanks.
Karl
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// SoundAlert when Williams crosses lines
/// </summary>
[Description("SoundAlert when Williams crosses lines")]
public class WilliamsAlert : Strategy
{
#region Variables
// Wizard generated variables
private int upperline = -25; // Default setting for Upperline
private int lowerline = -75; // Default setting for Lowerline
// 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 = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossBelow(WilliamsR(8), Upperline, 1))
{
PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\Alert4.wav");
DrawArrowDown("My down arrow" + CurrentBar, false, 0, 0, Color.Green);
}
// Condition set 2
if (CrossAbove(WilliamsR(8), Lowerline, 1))
{
PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\Alert4.wav");
DrawArrowUp("My up arrow" + CurrentBar, false, 0, 0, Color.Lime);
}
}
#region Properties
[Description("")]
[Category("Parameters")]
public int Upperline
{
get { return upperline; }
set { upperline = Math.Max(1, value); }
}
[Description("")]
[Category("Parameters")]
public int Lowerline
{
get { return lowerline; }
set { lowerline = Math.Max(1, value); }
}
#endregion
}
}
Comment
-
Hi Karl, are you testing in realtime or Market Replay? Then it should fire intrabar as you've set CalculateOnBarClose to false, however of course in backtesting this would be set to true all the time. For your Draw arrow calls, you set a Y axis value of 0, hence you would just not see those plotting on your conditions getting hit -
BertrandNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bmartz, 03-12-2024, 06:12 AM
|
4 responses
31 views
0 likes
|
Last Post
by bmartz
Today, 08:02 AM
|
||
Started by Aviram Y, Today, 05:29 AM
|
4 responses
12 views
0 likes
|
Last Post
by Aviram Y
Today, 07:57 AM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
3 responses
28 views
0 likes
|
Last Post Today, 07:41 AM | ||
Is it possible to have a drawing, such as a line, cycle through different colors?
by gentlebenthebear
Started by gentlebenthebear, Today, 01:30 AM
|
1 response
8 views
0 likes
|
Last Post Today, 07:30 AM | ||
Started by cls71, Today, 04:45 AM
|
1 response
7 views
0 likes
|
Last Post Today, 07:25 AM |
Comment