Could somebody help me figure out what my error is?
I have tried to make this as clear as possible with what is going on. Also written is an explanation of what the strategy is supposed to do so that you are not just blindly trying to figure it out. Please let me know if you have any questions or if I just did not make it clear enough. Any help is really appreciated! :)
Below is posted the entire NinjaTrader code in order to make it easier. The areas in question are marked in color.
When the 2 Red lines are commented out, all of the draw objects draw correctly. When they are not commented out, that is where I start running into issues.
In the section for TrendDirection.Up (Line #119), when the LongEntry is uncommented (Line #109 - in Red), the draw objects will draw correctly until a long trade is placed. As soon as that happens, no more draw objects will be drawn. The Output Window says,
When I look at the OnExecution area to find out what it might be, I don't see what the problem could be. (I expect that it is referring to line #183 - 189 - Blue Section)
Would somebody be willing to take a look at this and see if this is, in fact, where my problem is and let me know what I could to fix it?
Maybe you want a bit of an idea of what this code is supposed to do.
In its current form, it is supposed to find a range (between 2:00 am and 9:00 am). With that range it is supposed to find the highest bar and the lowest bar and take note of the High and Low respectively. When it finds the high, for example, and the TrendDirection is Up, then it is supposed to place a EnterLongStop order x pips above that high and x pips below the low of the range. It is then supposed to place a SellLimit order above the Entry Order. If the Entry Order is not triggered by a particular time (22:00) then it is to be cancelled.
It is only supposed to take one trade per day, therefore a flag was created (restrictTrade). When the Entry Order is triggered then the flag is to be set to true, thus not allowing any more trading to happen for that day. Then, on the next day, during the range then the flag is changed back to false in order to allow trading. (I have tried various combinations of this flag to see if it is causing the problem, but it does not appear to be the issue).
If you have any more questions, feel free to ask me. Thank you in advance for any help that anyone is able to give.
#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
{
///
/// Basic London Breakout - Manually Defined Inputs
///
[Description("Basic London Breakout - Manually Defined Inputs")]
public class LondonBreakout : Strategy
{
#region Variables
// Range Variables
private DateTime startRange = DateTime.Today.AddHours(2); // Hour that the range will start
private int endRangeHr = 09; // Hour that the range will end
private int endRangeMin = 00; // Minute that the range will end
private int removeOrderHr = 22; // Hour that unfilled entry orders will be removed
private int removeOrderMin = 00; // Minute that that unfilled entry orders will be removed
private double rangeHigh = 0; // High of range
private double rangeLow; // Low of range
// Trend Variables
private TrendDirection direction = TrendDirection.NoTrend; // holds direction of trend to determine direction of trade
private string noTrend; // user defined stating no trend
private string up; // user defined stating Up Trend
private string down; // user defied stating Down Trend
// Misc. Variables
private int positionSize = 1; // Default setting for PositionSize
private double pipBuffer = 0.0000; // distance from range that trade will be placed
private …