Hello,
I wish to draw a rectangle within an indicator.
I successfully draw rectangles within a price chart using the following lines :
private IRectangleObject PE_07_08,
PE_07_08 = DrwRectangle.Create(new ChartPoint(PE_07_08_START,PE_OPENING), new ChartPoint(PE_07_08_END,PE_CLOSING), false);
But when I try to draw a rectangle within an indicator, it appears in the price chart and not in the indicator chart.
Can someone let me know if it's possible, and if yes could you let me know what I'm doing wrong.
The indicator is set with these lines:
[SameAsSymbol(true)]
[RecoverDrawings(false)]
Thank you in advance for your contributions.
Draw a rectangle within an indicator [SOLVED]
- ABC
- Posts: 731
- Joined: Dec 16 2006
- Location: www.abctradinggroup.com
- Has thanked: 126 times
- Been thanked: 415 times
- Contact:
Hi pdemontferrier,
your code sets the onSameSubchart flag to false i.e. the rectangle will be placed on the price chart. Setting it to true should display it on the indicator subchart.
Regards,
ABC
your code sets the onSameSubchart flag to false i.e. the rectangle will be placed on the price chart. Setting it to true should display it on the indicator subchart.
Regards,
ABC
-
- Posts: 22
- Joined: Jun 22 2017
- Has thanked: 9 times
- Been thanked: 2 times
Hi ABC,
Thank you very much for your contribution but it didn't fix my problem.
Even if I set:
[SameAsSymbol(false)]
The rectangle is still on the price chart.
Regards
Thank you very much for your contribution but it didn't fix my problem.
Even if I set:
[SameAsSymbol(false)]
The rectangle is still on the price chart.
Regards
- ABC
- Posts: 731
- Joined: Dec 16 2006
- Location: www.abctradinggroup.com
- Has thanked: 126 times
- Been thanked: 415 times
- Contact:
Hi pdemontferrier,
you would have to post your code, as the SameAsSymbol attribute is not related to your problem. The onSameSubchart flag is part of DrwRectangle.Create and in the snippet you posted you have set it to false.
Regards,
ABC
you would have to post your code, as the SameAsSymbol attribute is not related to your problem. The onSameSubchart flag is part of DrwRectangle.Create and in the snippet you posted you have set it to false.
Regards,
ABC
Hi ABC,
Thank you very much for your contribution but it didn't fix my problem.
Even if I set:
[SameAsSymbol(false)]
The rectangle is still on the price chart.
Regards
-
- Posts: 22
- Joined: Jun 22 2017
- Has thanked: 9 times
- Been thanked: 2 times
Hi ABC,
Find here under the complete code :
using System;
using System.IO;
using System.Linq;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Collections.Generic;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator
{
[UpdateOnEveryTickAttribute(true)]
[RecoverDrawings(false)]
[SameAsSymbol(false)]
public class RSI_BK_COLOR : IndicatorObject
{
public RSI_BK_COLOR(object ctx) : base(ctx)
{
BK_COLOR = true;
}
[Input]
public bool BK_COLOR { get; set; }
#region Private Variables, Functions, Orders & Flags
//RSI
private PowerLanguage.Function.RSI RSI_FUNC;
private VariableSeries<Double> RSI;
private int RSI_LEN_INP;
//Drawings
private IPlotObject Plot_RSI, Plot_RS1, Plot_RS2, Plot_RS3, Plot_RS4;
private double RSI_RS1, RSI_RS2, RSI_RS3, RSI_RS4;
private IRectangleObject BK_L1, BK_L2, BK_L3, BK_L4, BK_L5, BK_L6;
private DateTime BK_START, BK_FINISH;
private double BK_L1_BEGIN, BK_L2_BEGIN, BK_L3_BEGIN, BK_L4_BEGIN, BK_L5_BEGIN, BK_L6_BEGIN;
private double BK_L1_END, BK_L2_END, BK_L3_END, BK_L4_END, BK_L5_END, BK_L6_END;
#endregion
protected override void Create()
{
RSI_FUNC = new PowerLanguage.Function.RSI(this, 1);
RSI = new VariableSeries<Double>(this, 0, 1, true);
Plot_RSI = AddPlot(new PlotAttributes("RSI", 0, Color.DarkOrange, Color.Empty, 2, EPlotStyle.Solid, true));
Plot_RS1 = AddPlot(new PlotAttributes("RSI_RS1", 0, Color.Silver, Color.Empty, 0, EPlotStyle.Dash, true));
Plot_RS2 = AddPlot(new PlotAttributes("RSI_RS2", 0, Color.Silver, Color.Empty, 0, EPlotStyle.Dash, true));
Plot_RS3 = AddPlot(new PlotAttributes("RSI_RS3", 0, Color.Silver, Color.Empty, 0, EPlotStyle.Dash, true));
Plot_RS4 = AddPlot(new PlotAttributes("RSI_RS4", 0, Color.Silver, Color.Empty, 0, EPlotStyle.Dash, true));
}
protected override void StartCalc()
{
RSI_LEN_INP = 12;
RSI_FUNC.price = BarsOfData(1).Close;
RSI_FUNC.length = RSI_LEN_INP;
RSI_RS1 = 80;
RSI_RS2 = 60;
RSI_RS3 = 40;
RSI_RS4 = 20;
}
protected override void CalcBar()
{
RSI.Value = RSI_FUNC[0];
Plot_RSI.Set(0, RSI.Value);
Plot_RS1.Set(0, RSI_RS1);
Plot_RS2.Set(0, RSI_RS2);
Plot_RS3.Set(0, RSI_RS3);
Plot_RS4.Set(0, RSI_RS4);
BK_START = BarsOfData(1).Time[1];
BK_FINISH = BarsOfData(1).Time[0];
if (BarsOfData(1).Status == EBarState.Close)
{
//BK_L1 0-20
BK_L1 = DrwRectangle.Create(new ChartPoint(BK_START,0), new ChartPoint(BK_FINISH,20), false);
BK_L1.AnchorToBars = false;
BK_L1.FillColor = Color.DarkRed; //Color.DarkRed Color.FromArgb(0,225,0,0)
BK_L1.BorderStyle = ETLStyle.ToolSolid;
BK_L1.Color = Color.DarkRed;
BK_L1.Size = 0;
BK_L1.Locked = true;
}
}
}
}
Again thank you for your collaboration.
Find here under the complete code :
using System;
using System.IO;
using System.Linq;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Collections.Generic;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator
{
[UpdateOnEveryTickAttribute(true)]
[RecoverDrawings(false)]
[SameAsSymbol(false)]
public class RSI_BK_COLOR : IndicatorObject
{
public RSI_BK_COLOR(object ctx) : base(ctx)
{
BK_COLOR = true;
}
[Input]
public bool BK_COLOR { get; set; }
#region Private Variables, Functions, Orders & Flags
//RSI
private PowerLanguage.Function.RSI RSI_FUNC;
private VariableSeries<Double> RSI;
private int RSI_LEN_INP;
//Drawings
private IPlotObject Plot_RSI, Plot_RS1, Plot_RS2, Plot_RS3, Plot_RS4;
private double RSI_RS1, RSI_RS2, RSI_RS3, RSI_RS4;
private IRectangleObject BK_L1, BK_L2, BK_L3, BK_L4, BK_L5, BK_L6;
private DateTime BK_START, BK_FINISH;
private double BK_L1_BEGIN, BK_L2_BEGIN, BK_L3_BEGIN, BK_L4_BEGIN, BK_L5_BEGIN, BK_L6_BEGIN;
private double BK_L1_END, BK_L2_END, BK_L3_END, BK_L4_END, BK_L5_END, BK_L6_END;
#endregion
protected override void Create()
{
RSI_FUNC = new PowerLanguage.Function.RSI(this, 1);
RSI = new VariableSeries<Double>(this, 0, 1, true);
Plot_RSI = AddPlot(new PlotAttributes("RSI", 0, Color.DarkOrange, Color.Empty, 2, EPlotStyle.Solid, true));
Plot_RS1 = AddPlot(new PlotAttributes("RSI_RS1", 0, Color.Silver, Color.Empty, 0, EPlotStyle.Dash, true));
Plot_RS2 = AddPlot(new PlotAttributes("RSI_RS2", 0, Color.Silver, Color.Empty, 0, EPlotStyle.Dash, true));
Plot_RS3 = AddPlot(new PlotAttributes("RSI_RS3", 0, Color.Silver, Color.Empty, 0, EPlotStyle.Dash, true));
Plot_RS4 = AddPlot(new PlotAttributes("RSI_RS4", 0, Color.Silver, Color.Empty, 0, EPlotStyle.Dash, true));
}
protected override void StartCalc()
{
RSI_LEN_INP = 12;
RSI_FUNC.price = BarsOfData(1).Close;
RSI_FUNC.length = RSI_LEN_INP;
RSI_RS1 = 80;
RSI_RS2 = 60;
RSI_RS3 = 40;
RSI_RS4 = 20;
}
protected override void CalcBar()
{
RSI.Value = RSI_FUNC[0];
Plot_RSI.Set(0, RSI.Value);
Plot_RS1.Set(0, RSI_RS1);
Plot_RS2.Set(0, RSI_RS2);
Plot_RS3.Set(0, RSI_RS3);
Plot_RS4.Set(0, RSI_RS4);
BK_START = BarsOfData(1).Time[1];
BK_FINISH = BarsOfData(1).Time[0];
if (BarsOfData(1).Status == EBarState.Close)
{
//BK_L1 0-20
BK_L1 = DrwRectangle.Create(new ChartPoint(BK_START,0), new ChartPoint(BK_FINISH,20), false);
BK_L1.AnchorToBars = false;
BK_L1.FillColor = Color.DarkRed; //Color.DarkRed Color.FromArgb(0,225,0,0)
BK_L1.BorderStyle = ETLStyle.ToolSolid;
BK_L1.Color = Color.DarkRed;
BK_L1.Size = 0;
BK_L1.Locked = true;
}
}
}
}
Again thank you for your collaboration.
- ABC
- Posts: 731
- Joined: Dec 16 2006
- Location: www.abctradinggroup.com
- Has thanked: 126 times
- Been thanked: 415 times
- Contact:
Hi pdemontferrier,
check your usage of DrwRectangle.Create. The onSameSubchart flag is still set to false:
BK_L1 = DrwRectangle.Create(new ChartPoint(BK_START,0), new ChartPoint(BK_FINISH,20), false);
Regards,
ABC
check your usage of DrwRectangle.Create. The onSameSubchart flag is still set to false:
BK_L1 = DrwRectangle.Create(new ChartPoint(BK_START,0), new ChartPoint(BK_FINISH,20), false);
Regards,
ABC
-
- Posts: 22
- Joined: Jun 22 2017
- Has thanked: 9 times
- Been thanked: 2 times
Hi ABC,
Thank you very much, you answer did fix all as I wanted.
Have a nice day.
Regards.
Thank you very much, you answer did fix all as I wanted.
Have a nice day.
Regards.
-
- Posts: 22
- Joined: Jun 22 2017
- Has thanked: 9 times
- Been thanked: 2 times