Files
nt8-sdk/rules/Compile error guidance.md
Billy Valentine 92f3732b3d
Some checks failed
Build and Test / build (push) Has been cancelled
Phase 0 completion: NT8 SDK core framework with risk management and position sizing
2025-09-09 17:06:37 -04:00

204 lines
5.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

ALWAYS verify with the live Ninjascript reference available on the web at https://developer.ninjatrader.com/docs/desktop before making final edits.
This third file confirms a recurrence of CS0246 compiler errors in VWAP_Pro.cs, specifically related to undefined types like ModeType and AnchorModeType.
🔍 CS0246 - "The type or namespace name 'X' could not be found"
Line Column Missing Type
371 28 ModeType
371 43 AnchorModeType
391 39 ModeType
391 54 AnchorModeType
376 51 ModeType
✅ How to Fix It
🔧 1. Define Missing Enums (Recommended Fix)
It seems that ModeType and AnchorModeType are custom enums that were expected to exist in the code but were never declared.
Create a separate file or include this in the same VWAP_Pro.cs file near the top:
public enum ModeType
{
Standard,
Aggressive,
Conservative
}
public enum AnchorModeType
{
SessionStart,
FixedTime,
Custom
}
Youll need to customize the enum values (Standard, Aggressive, etc.) to match your strategy logic. These names are placeholders based on typical VWAP settings.
🔧 2. OR Add Missing using Directives
If these types exist in another NinjaTrader script or add-on you've imported before, ensure you include the right namespace:
using NinjaTrader.NinjaScript.AddOns.MyVWAPEnums; // Example
But since these errors suggest the types are completely undefined, it's much more likely they are simply not declared anywhere.
🔧 3. Verify File Inclusion in NinjaTrader
If these enums are defined in another file (e.g., VWAPTypes.cs), make sure:
It's saved in the same directory as VWAP_Pro.cs
It's added to the NinjaScript Editor, not just sitting in the file system
You can add it using:
Tools > NinjaScript Editor > Right-click > Add > Existing Item...
🧼 Suggested Organization
If these enums are used across multiple indicators/strategies, you should centralize them:
VWAP_Enums.cs
namespace NinjaTrader.NinjaScript.VWAP
{
public enum ModeType
{
Standard,
Aggressive,
Conservative
}
public enum AnchorModeType
{
SessionStart,
FixedTime,
Custom
}
}
Then use:
using NinjaTrader.NinjaScript.VWAP;
These are occurring in VWAP_Pro.cs, mainly on lines 132134:
Line Error Message (Truncated)
132 Argument 2: cannot convert from 'int' to 'NinjaTrader.Gui.Tools.SimpleFont'
132 Argument 3: cannot convert from 'NinjaTrader.Gui.Tools.SimpleFont' to 'System.Windows.Media.Brush'
133 Same as above
134 Same as above
🔧 Interpretation:
It looks like a method (likely a drawing method like Draw.Text() or Draw.TextFixed()) is being called with the wrong argument types — specifically:
An int is being passed where a SimpleFont is expected.
A SimpleFont is being passed where a Brush is expected.
This suggests that arguments are out of order or misassigned.
✅ Proper Fix
Lets consider the proper usage of Draw.Text() in NinjaTrader 8:
Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, Brush textBrush, SimpleFont font, TextAlignment alignment, Brush outlineBrush, int outlineWidth);
Or for simpler usage:
Draw.Text(this, "tag1", "Hello", 0, Close[0], Brushes.White);
Your issue likely looks like this:
Draw.Text(this, "tag1", true, "Label", 0, 100, 12, someFont, ...);
Where 12 (int) is mistakenly passed as a font or brush, causing the error.
🔧 Corrected Example:
Assuming you want to draw text with a specific font and color:
SimpleFont font = new SimpleFont("Arial", 12);
Draw.Text(this, "tag1", true, "VWAP Label", 0, Close[0], Brushes.White, font, TextAlignment.Center, Brushes.Black, 1);
Brushes.White → text color
font → SimpleFont object
TextAlignment.Center → alignment
Brushes.Black → outline brush
1 → outline width
✅ Steps to Fix:
Replace the integer (e.g., 12) with a SimpleFont:
new SimpleFont("Arial", 12)
Ensure arguments are in the correct order:
Double-check the method signature from the NinjaTrader 8 Help Guide
.
Use Brushes for colors, not fonts.
Summary of Errors:
Line Column Missing Type
403 39 ModeType
403 54 AnchorModeType
408 63 ModeType
408 78 AnchorModeType
367 28 ModeType
✅ Fixes:
These types — ModeType and AnchorModeType — are not recognized. Here are the likely causes and solutions:
🔍 1. Missing using Directive
These types might be defined in a different namespace. If they are from a custom or NinjaTrader add-on:
Fix: Add the appropriate using statement at the top of your file.
Example:
using NinjaTrader.NinjaScript.AddOns.VWAP;
Adjust according to where ModeType and AnchorModeType are defined.
🔍 2. Missing Class Definitions
If they are not in any existing libraries, they might be custom enum types that should be defined in your project but are missing.
Fix: Add enum declarations like these (if applicable):
public enum ModeType
{
Standard,
Aggressive,
Conservative
}
public enum AnchorModeType
{
SessionStart,
FixedTime,
Custom
}
Only do this if you know what the enum values should be. These names are placeholders — you should match them with how your indicator/strategy is designed.