I'm developing a strategy that plot arrow line and text while I am trading by hands. The strategy should plot the objects each time when my orders are executed. I place limit orders through SuperDom.
I know that I can use Plot Execution in data series, but I'd like to use my strategy.
In my strategy I use OnExecution() method to draw the objects. I used the same code in my other strategies which placed orders and they draw objects during testing in Strategy Analizer. But this code doesn't work when I attached it to chart and trade by hand.
Please, help me with my strategy.
below the code of my strategy
#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>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class Screens : Strategy
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
private int n=0;
private int k=0;
// 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;
AllowRemovalOfDrawObjects = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
}
protected override void OnExecution(IExecution execution)
{
foreach (IDrawObject draw in DrawObjects)
{
draw.Locked = false;
}
double price = execution.Price;
double ts = TickSize;
DrawArrowLine("k"+n,false,10,price+10*ts,0,price,C olor.Red,DashStyle.Solid, 2);
DrawText("n"+k,false, ""+price, 10,price+10*ts,10,Color.Black,new Font("Calibri",14,FontStyle.Bold),StringAlignment. Center,Color.Transparent ,Color.Transparent,1);
n=n+1;
k=k+1;
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}
#endregion
}
}
Comment