I would like to enter order in my strategy script when an indicator pattern is found in an indicator script. How do I do this? Below is part of the indicator script. I would like to EnterLong() on my strategy script when (CurrentBar - barback != myBarUp)
thank you for your help!
#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;
//using System.Speech.AudioFormat;
#endregion
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
public class NinjaPriceAction : Indicator
{
private int barsback;
private double prevhigh;
private double prevlow;
private double curhigh;
private double curlow;
private double offset;
private double curATR;
private double toffset;
private ATR myATR;
private Swing mySwing;
private double tOffset;
private int myBarUp, myBarDown;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Labels the swing points";
Name = "NinjaPriceAction";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
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;
Strength = 3;
TextOffset = 3;
LookBack = 50;
DTBStrength = 15;
TextFont = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 12);
DBcolor = Brushes.Gold;
DTcolor = Brushes.Gold;
HHcolor = Brushes.Green;
HLcolor = Brushes.White;
LLcolor = Brushes.Red;
LHcolor = Brushes.White;
}
else if (State == State.DataLoaded)
{
myATR = ATR(14);
mySwing = Swing(Strength);
tOffset = TextOffset * TickSize;
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < LookBack + 1) return;
barsback = mySwing.SwingHighBar(0,2,LookBack);
if (barsback == -1)
return;
prevhigh = mySwing.SwingHigh[barsback];
barsback = mySwing.SwingHighBar(0,1,LookBack);
if (barsback == -1)
return;
curhigh = mySwing.SwingHigh[barsback];
curATR = myATR[barsback];
offset = curATR * DTBStrength / 100;
if (curhigh < prevhigh + offset && curhigh > prevhigh - offset && CurrentBar - barsback != myBarUp)
{
myBarUp = CurrentBar - barsback;
Draw.Text(this, "DT"+CurrentBar, true, "DT", barsback, High[barsback] + tOffset, 0, DTcolor,
TextFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
}
else if (curhigh > prevhigh && CurrentBar - barsback != myBarUp)
{
myBarUp = CurrentBar - barsback;
Draw.Text(this, "HH"+CurrentBar, true, "HH", barsback, High[barsback] + tOffset, 0, HHcolor,
TextFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
}
else if [COLOR=#00FF00](CurrentBar - barsback != myBarUp)[/COLOR]
{
myBarUp = CurrentBar - barsback;
Draw.Text(this, "LH"+CurrentBar, true, "LH",barsback, High[barsback] + tOffset, 0, LHcolor,
TextFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
}

Comment