I am running a strategy and it is getting quite lengthy. In an effort to clean it up, I started moving some of my methods out of the strategy file and into the appropriately named file "ninjaweapons.cs." I have a number of methods that I offloaded there, and they function without issue. I have one method, however, that is no longer functioning after the move. I could go back to the way things were when they worked, but I feel there is a fundamental lesson I need to learn at this point. As a programmer, I need to understand completely how to call methods from another file!
When the method was IN the strategy file, it served as the entry signal (kind of important). So my strategy would buy and sell as intended. After moving it from my strategy file to ninjaweapons.cs, it no longer triggers those entries. Typically I'll insert Print()'s along the way to debug, but what I'm finding in my ninjaweapons.cs file, is that Print() generates a compile error CS0103 The name 'Print' does not exist in the current context. This is potentially a separate issue all together, or perhaps it's related, not sure, but figured it was worth mentioning.
I have been working with Ninjascripts for a while now (going on 3 years), so I think I know some things, but there are certainly some holes in my game as I am entirely self-taught, and most of my learning comes from necessity (not best practices). That being said, I have a feeling I'm making some newbie error in calling methods from other files. Maybe passing variables incorrectly, or failing to call a namespace or something. I don't know!
Below is some code. If you need more context, please let me know. Thank you for your time and help in advance!
Note that the method giving me trouble is CompletePricePivot(). From my strategy I'm writing something like this:
{
if (SecondLowBar != 0 && PullbackStartBar == 0 && PullbackOccurs(TrendBreakBar, MinRedBars, MaxRedBars, Midnight, Open, High, Low, Close, Volume, CurBar))
return true;
else return false;
}
{
if (ninjaweapons.CompletePricePivot(MinRedBars, MaxRedBars, Midnight, CurBar, TrendBreakBar, Open, High, Low, Close, Volume, CurBar).bar > TrendBreakBar)
.
.
.
{
And in ninjaweapons.cs it looks like this:
public static Point CompletePricePivot(int MinRedBars, int MaxRedBars, int Midnight, int StartBar, int SeekToBar, ISeries<double> Open, ISeries<double> High, ISeries<double> Low, ISeries<double> Close, ISeries<double> Volume, int CurBar)
{
.
.
.
{
It is my thought that I have to pass all of my ISeries<double> Open, High, Low, Close, Volume, Time and CurrentBar into any method I call lfrom OnBarUpdate().
One last thing, the beginning of ninjaweapons.cs looks like this:
using NinjaTrader.NinjaScript;
using NinjaTrader.NinjaScript.Indicators;
using System;
using System.Linq;
namespace NinjaTrader.Custom.NinjaWeapons
{
Comment