ninja-patterns
БесплатноБез исполняемых скриптовНе проверенNinjaTrader 8 NinjaScript indicator scaffold and patterns. Provides C# structure guidance and triggers doc-researcher for API verification. Use when…
Об этом скилле
NinjaScript Patterns
Lightweight scaffold for NinjaTrader 8 NinjaScript/C# indicator development.
Before Generating Code
ALWAYS use doc-researcher agent or Ref MCP tools to verify:
- NinjaTrader 8 API methods
- Property attribute usage
- Drawing object APIs
File Conventions
- File naming:
*LB.cs - Author:
// Author: Luther Barnum
Namespace & Class
namespace NinjaTrader.NinjaScript.Indicators.LB
{
public class [Name]LB : Indicator
{
// Implementation
}
}
Lifecycle Methods
OnStateChange()
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "Indicator description";
Name = "IndicatorName";
// Set property defaults
}
else if (State == State.Configure)
{
AddPlot(Brushes.Blue, "PlotName");
}
else if (State == State.DataLoaded)
{
// Initialize Series objects
}
}
OnBarUpdate()
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToPlot) return;
// Calculations
}
Property Attributes
[NinjaScriptProperty]
[Display(Name = "Period", Order = 1, GroupName = "Parameters")]
[Range(1, int.MaxValue)]
public int Period { get; set; }
Session Detection
if (Bars.IsFirstBarOfSession)
{
// Reset session values
}
Series Objects
private Series<double> myValues;
// In State.DataLoaded:
myValues = new Series<double>(this);
Drawing Objects
Draw.Rectangle(this, "tag", startBar, startPrice, endBar, endPrice, Brushes.Blue);
Draw.Line(this, "tag", startBar, startPrice, endBar, endPrice, Brushes.Red);
Draw.Text(this, "tag", "Label", 0, High[0] + TickSize, Brushes.White);
Complete Example
Reference: /Users/lgbarn/Personal/Indicators/Ninjatrader/PEMA.cs
#region Using declarations
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Windows.Media;
using NinjaTrader.Gui.Chart;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
// Author: Luther Barnum
namespace NinjaTrader.NinjaScript.Indicators.LB
{
public class SimpleMALB : Indicator
{
private EMA fastEma;
private SMA slowSma;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "Simple MA Crossover Indicator";
Name = "SimpleMALB";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
// Default parameters
FastPeriod = 9;
SlowPeriod = 21;
// Add plots
AddPlot(Brushes.Cyan, "FastMA");
AddPlot(Brushes.Orange, "SlowMA");
Plots[0].Width = 2;
Plots[1].Width = 2;
}
else if (State == State.DataLoaded)
{
fastEma = EMA(Close, FastPeriod);
slowSma = SMA(Close, SlowPeriod);
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < SlowPeriod)
return;
FastMA[0] = fastEma[0];
SlowMA[0] = slowSma[0];
}
#region Properties
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "Fast Period", Order = 1, GroupName = "Parameters")]
public int FastPeriod { get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "Slow Period", Order = 2, GroupName = "Parameters")]
public int SlowPeriod { get; set; }
[Browsable(false)]
[XmlIgnore]
public Series<double> FastMA { get { return Values[0]; } }
[Browsable(false)]
[XmlIgnore]
public Series<double> SlowMA { get { return Values[1]; } }
#endregion
}
}
VWAP Calculation Pattern
private double cumVolume;
private double cumVwap;
private double cumVwap2;
protected override void OnBarUpdate()
{
if (Bars.IsFirstBarOfSession)
{
cumVolume = 0;
cumVwap = 0;
cumVwap2 = 0;
}
double typicalPrice = (High[0] + Low[0] + Close[0]) / 3.0;
cumVolume += Volume[0];
cumVwap += Volume[0] * typicalPrice;
cumVwap2 += Volume[0] * typicalPrice * typicalPrice;
if (cumVolume > 0)
{
double vwap = cumVwap / cumVolume;
double variance = (cumVwap2 / cumVolume) - (vwap * vwap);
double stdev = variance > 0 ? Math.Sqrt(variance) : 0;
VWAP[0] = vwap;
UpperBand[0] = vwap + stdev;
LowerBand[0] = vwap - stdev;
}
}
Error Handling Patterns
Check bar history
protected override void OnBarUpdate()
{
// Ensure enough bars for calculation
if (CurrentBar < BarsRequiredToPlot)
return;
// Or use specific period
if (CurrentBar < Period - 1)
Установить ninja-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл ninja-patterns?
NinjaTrader 8 NinjaScript indicator scaffold and patterns. Provides C# structure guidance and triggers doc-researcher for API verification. Use when developing NinjaTrader indicators.
Как установить скилл ninja-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ninja-patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic