I begin in scripting.
My goal is to have a line 16 ticks above the current price and one under the current price.
I don't want a horizontal line accross the chart, but a short one.
Right now I'm trying to diplay a line with no success...
#region Using declarations
using System;
using NinjaTrader.Cbi;
using NinjaTrader.Gui.Tools;
using NinjaTrader.NinjaScript;
using NinjaTrader.Data;
using System.Windows.Media; // Add this namespace for Brushes
using System.ComponentModel.DataAnnotations; // Add this namespace for DisplayAttribute
#endregion
// This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
public class LineAbovePrice : Indicator
{
private double tickSize;
[NinjaScriptProperty]
[Display(Name = "Ticks Above", Order = 1, GroupName = "Parameters")]
public int TicksAbove { get; set; }
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"An indicator that draws a line 16 ticks above the current price, starting 3 bars before the current bar and extending to the right.";
Name = "LineAbovePrice";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
TicksAbove = 16;
}
else if (State == State.Configure)
{
tickSize = TickSize;
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < 3) return; // Ensure there are enough bars to calculate
double currentPrice = Close[0];
double linePrice = currentPrice + (TicksAbove * tickSize);
// Draw line starting from 3 bars before the current bar and extending to the right
Draw.Line(this, "LineAbovePrice", false, 3, linePrice, 0, linePrice, Brushes.Green, DashStyleHelper.Solid, 2);
}
}
}
The name 'Draw' does not exist in the current context
The name 'DashStyleHelper' does not exist in the current context
Thanks in advance

Comment