#region Using declarations
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.SuperDom;
using NinjaTrader.Gui.Tools;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators.MackPATS
{
public class ShowBidAskwh : Indicator
{
private bool displayText = true;
private int endbarsago = -12;
private int startbarsago = -3;
private int thickness = 1;
private Brush bidColor = Brushes.Red;
private Brush askColor = Brushes.Blue;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Puts a horizontal line at the ask price";
Name = "ShowBidAskwh";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
DisplayInDataBox = false;
DrawOnPricePanel = true;
DrawHorizontalGridLines = false;
DrawVerticalGridLines = false;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
// DisplayText = true;
// bidColor = Brushes.Red;
// askColor = Brushes.Blue;
// Endbarsago = -12;
// Startbarsago = -3;
// Thickness = 1;
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
//Add your custom indicator logic here.
}
protected override void OnMarketData(MarketDataEventArgs e)
{
double a=e.Ask;
double b=e.Bid;
double TValue = Instrument.MasterInstrument.PointValue * TickSize;
double SpreadCost = (a-b)/TickSize * TValue;
/*removed currency symbol - some users don't trade $ denom instruments so it could be misleading.
You can convert whatever symbols currency into your own trading currency but it's way too complicated
for this small piece of code.
*/
string v = "Ask/Bid Spread:\n"+SpreadCost.ToString("0.00");
if(displayText)
Draw.TextFixed(this, "text",v,TextPosition.TopLeft);
{
if ( e.MarketDataType == MarketDataType.Ask)
{
Draw.Line(this, "ask", false, startbarsago, e.Price , endbarsago, e.Price, AskColor, DashStyleHelper.Solid, Thickness);
}
else if (e.MarketDataType == MarketDataType.Bid)
{
Draw.Line(this, "bid", false, startbarsago, e.Price, endbarsago, e.Price, BidColor, DashStyleHelper.Solid, Thickness);
}
}
}
#region Properties
[NinjaScriptProperty]
[Display(Name="DisplayText", Description="Display Text", Order=1, GroupName="Parameters")]
public bool DisplayText
{
get { return displayText; }
set { displayText = value; }
}
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name="BidColor", Description="Bid Color", Order=2, GroupName="Parameters")]
public Brush BidColor
{
get { return bidColor; }
set { bidColor = value; }
}
[Browsable(false)]
public string BidColorSerializable
{
get { return Serialize.BrushToString(BidColor); }
set { BidColor = Serialize.StringToBrush(value); }
}
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name="AskColor", Description="Ask Color", Order=3, GroupName="Parameters")]
public Brush AskColor
{
get { return askColor; }
set { askColor = value; }
}
[Browsable(false)]
public string AskColorSerializable
{
get { return Serialize.BrushToString(AskColor); }
set { AskColor = Serialize.StringToBrush(value); }
}
[NinjaScriptProperty]
[Display(Name="Endbarsago", Description="Negative nos extends line further into the future.", Order=4, GroupName="Parameters")]
public int Endbarsago
{
get { return endbarsago; }
set { endbarsago = value; }
}
[NinjaScriptProperty]
[Display(Name="Startbarsago", Description="Negative nos pushes line start to the right.", Order=5, GroupName="Parameters")]
public int Startbarsago
{
get { return startbarsago; }
set { startbarsago = value; }
}
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Thickness", Description="Thickness of line", Order=6, GroupName="Parameters")]
public int Thickness
{
get { return thickness; }
set { thickness = value; }
}
#endregion
}
}
#region NinjaScript generated code. Neither change nor remove.
namespace NinjaTrader.NinjaScript.Indicators
{
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
{
private MackPATS.ShowBidAskwh[] cacheShowBidAskwh;
public MackPATS.ShowBidAskwh ShowBidAskwh(bool displayText, Brush bidColor, Brush askColor, int endbarsago, int startbarsago, int thickness)
{
return ShowBidAskwh(Input, displayText, bidColor, askColor, endbarsago, startbarsago, thickness);
}
public MackPATS.ShowBidAskwh ShowBidAskwh(ISeries<double> input, bool displayText, Brush bidColor, Brush askColor, int endbarsago, int startbarsago, int thickness)
{
if (cacheShowBidAskwh != null)
for (int idx = 0; idx < cacheShowBidAskwh.Length; idx++)
if (cacheShowBidAskwh[idx] != null && cacheShowBidAskwh[idx].DisplayText == displayText && cacheShowBidAskwh[idx].BidColor == bidColor && cacheShowBidAskwh[idx].AskColor == askColor && cacheShowBidAskwh[idx].Endbarsago == endbarsago && cacheShowBidAskwh[idx].Startbarsago == startbarsago && cacheShowBidAskwh[idx].Thickness == thickness && cacheShowBidAskwh[idx].EqualsInput(input))
return cacheShowBidAskwh[idx];
return CacheIndicator<MackPATS.ShowBidAskwh>(new MackPATS.ShowBidAskwh(){ DisplayText = displayText, BidColor = bidColor, AskColor = askColor, Endbarsago = endbarsago, Startbarsago = startbarsago, Thickness = thickness }, input, ref cacheShowBidAskwh);
}
}
}
namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
{
public Indicators.MackPATS.ShowBidAskwh ShowBidAskwh(bool displayText, Brush bidColor, Brush askColor, int endbarsago, int startbarsago, int thickness)
{
return indicator.ShowBidAskwh(Input, displayText, bidColor, askColor, endbarsago, startbarsago, thickness);
}
public Indicators.MackPATS.ShowBidAskwh ShowBidAskwh(ISeries<double> input , bool displayText, Brush bidColor, Brush askColor, int endbarsago, int startbarsago, int thickness)
{
return indicator.ShowBidAskwh(input, displayText, bidColor, askColor, endbarsago, startbarsago, thickness);
}
}
}
namespace NinjaTrader.NinjaScript.Strategies
{
public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
{
public Indicators.MackPATS.ShowBidAskwh ShowBidAskwh(bool displayText, Brush bidColor, Brush askColor, int endbarsago, int startbarsago, int thickness)
{
return indicator.ShowBidAskwh(Input, displayText, bidColor, askColor, endbarsago, startbarsago, thickness);
}
public Indicators.MackPATS.ShowBidAskwh ShowBidAskwh(ISeries<double> input , bool displayText, Brush bidColor, Brush askColor, int endbarsago, int startbarsago, int thickness)
{
return indicator.ShowBidAskwh(input, displayText, bidColor, askColor, endbarsago, startbarsago, thickness);
}
}
}
#endregion
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Converted indicator from NT7 to NT8 compiled, no errors, still not working.
Collapse
X
-
Converted indicator from NT7 to NT8 compiled, no errors, still not working.
Converted another indicator from NT7 to NT8. This one is compiling, no errors in logs, but is still not putting any info on the chart. The original NT7 code works fine. NT8 code is below.
6.5.0Code:
Tags: None
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
633 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
567 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment