drawing rectangles on last bar
drawing rectangles on last bar
23 Oct 2020, 18:13
hi
i'm trying to draw 3 rectangles only on last candle(i mean by time moving forward,our rectangles move further) which we determine each one's width by 'Period's and their height will be the highest and lowest point within the periods
i've tried this code but it would not work,what is the problem with that
also i get these errors: Error CS1001: Identifier expected
/*
==================================================================================
==================================================================================
TKRectangles
Copyright © 2020, MRM
Developer: MRM
==================================================================================
==================================================================================
with this indicator you can shift ichimoku forward or backward
*/
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class TKRectangles : Indicator
{
[Parameter(DefaultValue = 9)]
public int periodFast { get; set; }
[Parameter(DefaultValue = 26)]
public int periodMedium { get; set; }
[Parameter(DefaultValue = 52)]
public int periodSlow { get; set; }
[Parameter(DefaultValue = 26)]
public int DisplacementFast { get; set; }
[Parameter(DefaultValue = 26)]
public int DisplacementMedium { get; set; }
[Parameter(DefaultValue = -26)]
public int DisplacementSlow { get; set; }
double maxfast, minfast, maxmedium, minmedium, maxslow, minslow;
public override void Calculate(int index)
{
if ((index < periodFast) || (index < periodSlow))
{
return;
}
maxfast = MarketSeries.High[index];
minfast = MarketSeries.Low[index];
maxmedium = MarketSeries.High[index];
minmedium = MarketSeries.Low[index];
maxslow = MarketSeries.High[index];
minslow = MarketSeries.Low[index];
for (int i = 0; i < periodFast; i++)
{
if (maxfast < MarketSeries.High[index - i])
{
maxfast = MarketSeries.High[index - i];
}
if (minfast > MarketSeries.Low[index - i])
{
minfast = MarketSeries.Low[index - i];
}
}
for (int i = 0; i < periodMedium; i++)
{
if (maxmedium < MarketSeries.High[index - i])
{
maxmedium = MarketSeries.High[index - i];
}
if (minmedium > MarketSeries.Low[index - i])
{
minmedium = MarketSeries.Low[index - i];
}
}
for (int i = 0; i < periodSlow; i++)
{
if (maxslow < MarketSeries.High[index - i])
{
maxslow = MarketSeries.High[index - i];
}
if (minslow > MarketSeries.Low[index - i])
{
minslow = MarketSeries.Low[index - i];
}
}
int index1 = 0;
int index2 = periodFast;
int index3 = periodMedium;
int index4 = periodSlow;
}
public ChartRectangle DrawRectangle(string Fast, int index1, double minfast, int index2, double maxfast, Color = Color.BlueViolet, int thickness = 1, LineStyle = LineStyle.Lines);
public ChartRectangle DrawRectangle(string Medium, int index1, double minmedium, int index3, double maxmedium, Color = Color.BlueViolet, int thickness = 1, LineStyle = LineStyle.Lines);
public ChartRectangle DrawRectangle(string Slow, int index1, double minslow, int index4, double maxslow, Color = Color.BlueViolet, int thickness = 1, LineStyle = LineStyle.Lines);
}
}
Replies
m.mohammadreza.m.s
26 Oct 2020, 09:10
RE: i am trying to draw 3 rectangles on the last candle which 1st is 9 candles wide and its height is the distance from lowest price of the 9 candles to the highest price,2nd is 26 candles wide and the height is the same but for 26 candles and 3rd for 52.
PanagiotisCharalampous said:
Hi m.mohammadreza.m.s,
The below lines of code do not make much sense. I am not sure what are you trying to do
public ChartRectangle DrawRectangle(string Fast, int index1, double minfast, int index2, double maxfast, Color = Color.BlueViolet, int thickness = 1, LineStyle = LineStyle.Lines); public ChartRectangle DrawRectangle(string Medium, int index1, double minmedium, int index3, double maxmedium, Color = Color.BlueViolet, int thickness = 1, LineStyle = LineStyle.Lines); public ChartRectangle DrawRectangle(string Slow, int index1, double minslow, int index4, double maxslow, Color = Color.BlueViolet, int thickness = 1, LineStyle = LineStyle.Lines);
Best Regards,
Panagiotis
m.mohammadreza.m.s
26 Oct 2020, 13:15
( Updated at: 21 Dec 2023, 09:22 )
RE: something like this
PanagiotisCharalampous said:
Hi m.mohammadreza.m.s,
The below lines of code do not make much sense. I am not sure what are you trying to do
public ChartRectangle DrawRectangle(string Fast, int index1, double minfast, int index2, double maxfast, Color = Color.BlueViolet, int thickness = 1, LineStyle = LineStyle.Lines); public ChartRectangle DrawRectangle(string Medium, int index1, double minmedium, int index3, double maxmedium, Color = Color.BlueViolet, int thickness = 1, LineStyle = LineStyle.Lines); public ChartRectangle DrawRectangle(string Slow, int index1, double minslow, int index4, double maxslow, Color = Color.BlueViolet, int thickness = 1, LineStyle = LineStyle.Lines);
Best Regards,
Panagiotis
PanagiotisCharalampous
26 Oct 2020, 15:11
Hi m.mohammadreza.m.s,
What do you need exactly? An example of how to draw a rectangle or somebody to write the complete code for you?
Best Regards,
Panagiotis
@PanagiotisCharalampous
m.mohammadreza.m.s
26 Oct 2020, 15:21
if someone writes the code,that would be the best,but an example can solve the problem too,thanks in advance
PanagiotisCharalampous said:
Hi m.mohammadreza.m.s,
What do you need exactly? An example of how to draw a rectangle or somebody to write the complete code for you?
Best Regards,
Panagiotis
PanagiotisCharalampous
26 Oct 2020, 15:25
Hi m.mohammadreza.m.s,
I cannot write the code for you but I can provide you with an example. See below
Chart.DrawRectangle("fast", Bars.Count - 3, maxfast, Bars.Count - 1, minfast, Color.Red);
Best Regards,
Panagiotis
@PanagiotisCharalampous
m.mohammadreza.m.s
26 Oct 2020, 16:46
RE: thank you very much for your help.
PanagiotisCharalampous said:
Hi m.mohammadreza.m.s,
I cannot write the code for you but I can provide you with an example. See below
Chart.DrawRectangle("fast", Bars.Count - 3, maxfast, Bars.Count - 1, minfast, Color.Red);
Best Regards,
Panagiotis
PanagiotisCharalampous
26 Oct 2020, 07:58
Hi m.mohammadreza.m.s,
The below lines of code do not make much sense. I am not sure what are you trying to do
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous