I just started learning NT script.I used the existing NT CurrentDayOHL code and tried to apply DrawRegion to currentHigh, currentLow,and created the 50% Mid points. I got it worked but failed to delete those Plot lines.(I tried to command out but didn't work) Could anyone please give me some advice? Thanks in advance!
protected override void OnBarUpdate()
{
if (currentOpen == double.MinValue)
currentOpen = Open[0];
if (Bars.SessionBreak)
{
currentOpen = Open[0];
currentHigh = High[0];
currentLow = Low[0];
}
currentHigh = Math.Max(currentHigh, High[0]);
currentLow = Math.Min(currentLow, Low[0]);
if (ShowOpen)
{
if (!PlotCurrentValue || !Bars.SessionBreak)
CurrentOpen.Set(currentOpen);
else
for (int idx = 0; idx < CurrentOpen.Count; idx++)
CurrentOpen.Set(idx, currentOpen);
}
if (ShowHigh)
{
if (!PlotCurrentValue || currentHigh != High[0])
CurrentHigh.Set(currentHigh);
else
for (int idx = 0; idx < CurrentHigh.Count; idx++)
CurrentHigh.Set(idx, currentHigh);
}
if (ShowLow)
{
if (!PlotCurrentValue || currentLow != Low[0])
CurrentLow.Set(currentLow);
else
for (int idx = 0; idx < CurrentLow.Count; idx++)
CurrentLow.Set(idx, currentLow);
}
mid.Set(Instrument.MasterInstrument.Round2TickSize ((currentHigh+currentLow)/2));
ch1.Set(currentHigh);
cl1.Set(currentLow);
mid1.Set (mid[0]+TickSize*1);
mid2.Set (mid[0]-TickSize*1);
CH1.Set (ch1[0]-TickSize*2);
CL1.Set (cl1[0]+TickSize*2);
DrawRegion("Reg1", CurrentBar, 0, mid1, mid2, Color.Transparent, Color.DarkRed,10);
DrawRegion("Reg2", CurrentBar, 0, ch1, CH1, Color.Transparent, Color.DarkGreen,10);
DrawRegion("Reg3", CurrentBar, 0, cl1, CL1, Color.Transparent, Color.DarkGreen,10);
}
#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries CurrentOpen
{
get { return Values[0]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries CurrentHigh
{
get { return Values[1]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries CurrentLow
{
get { return Values[2]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries mid
{
get { return Values[3]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries mid1
{
get { return Values[4]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries mid2
{
get { return Values[5]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries CH1
{
get { return Values[6]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries CL1
{
get { return Values[7]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries ch1
{
get { return Values[8]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries cl1
{
get { return Values[9]; }
}
[Browsable(true)]
[Gui.Design.DisplayNameAttribute("Show open")]
public bool ShowOpen
{
get { return showOpen; }
set { showOpen = value; }
}
[Browsable(true)]
[Gui.Design.DisplayNameAttribute("Show high")]
public bool ShowHigh
{
get { return showHigh; }
set { showHigh = value; }
}
[Browsable(true)]
[Gui.Design.DisplayNameAttribute("Plot current value only")]
public bool PlotCurrentValue
{
get { return plotCurrentValue; }
set { plotCurrentValue = value; }
}
[Browsable(true)]
[Gui.Design.DisplayNameAttribute("Show low")]
public bool ShowLow
{
get { return showLow; }
set { showLow = value; }
}
#endregion
}
}
Comment