API Support Forum
OEC API > API Support > Chart Markers
Author Topic: Chart Markers
(3 messages, Page 1 of 1)
Moderators: VPfau
PDavies541
Posts: 21
Joined: Feb 01, 2013


Posted: May 29, 2013 @ 10:38 PM             Msg. 1 of 3
Hi

I have some indicator code that needs to put markers on the chart.

I understand that I can use graphics commands to do this as well as to find the boundaries of the chart but I actually need to put markers at specific prices on specific bars.

For example, I have an iceberg order alert which shows where an iceberg order is. It's important that this appears at the time/price the iceberg occured.

I can't find any documentation on how to do this, how to calculate the co-ordinates.

Can you help?

Cheers

Pete

Peter Davies
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 31, 2013 @ 01:08 PM             Msg. 2 of 3
Please check this sample indicator below. Is it what are you looking for?


using System;
using System.Collections.Generic;
using System.ComponentModel;
using OEC.UI;
using OEC.Chart;
using OEC.Chart.Indicators;
using OEC.Chart.Details;
using OEC.Chart.BaseSeries;
using OEC.EL.Runtime;
using System.Runtime.InteropServices;
using System.Drawing.Drawing2D;

namespace OEC.Chart.Custom.Sandbox
{

[TimeSeries("ArrowsSample", "ArrowsSample", "Samples", AreaScale.Any, SourceScale=AreaScale.Price)]
public sealed class ArrowsSample : OEC.Chart.Custom.CustomIndicator
{
[XmlSerializable, Category("Data")]
public int Window = 15;

protected override void Calculate()
{
double sma = SMA(Close,15);
Result.Value = sma;
if(sma < Close)
{
DrawArrow(Low, Low - 2 * ContractInfo.TickSize, Color.Red);
}
else
{
DrawArrow(High, High + 2 * ContractInfo.TickSize, Color.Green);
}
}

DrawingTools.Arrow LastArrow = null;
DateTime LastArrowDate = DateTime.MinValue;

void DrawArrow(double oneY, double twoY, System.Drawing.Color color)
{
DateTime x = this.DateTimeEL[0];

if(LastArrow != null && LastArrowDate == x && LastArrow.Corner1.Y == oneY)
{
return ;
}
DrawingTools.Arrow arrow = DrawingObjects.Create<DrawingTools.Arrow>(x, oneY, x, twoY);
arrow.BackColor = color;
arrow.ArrowStyle = DrawingTools.ArrowStyle.Simple;
arrow.ArrowSize = 3;
arrow.Locked = true;
arrow.AutoZoom = false;
if(LastArrow != null && x == LastArrowDate)
{
DrawingObjects.Remove(LastArrow);
}
LastArrow = arrow;
LastArrowDate = x;
}

protected override DataSeries[] DefaultSubseries
{
get
{
return new DataSeries[]{
new DataSeries(this, "Value", new ChartStyle(SeriesChartType.Line,System.Drawing.Color.FromArgb(0xff0000),1,DashStyle.Solid))

};
}
}
}
}


Victor Vins
Lead Software Developer
PDavies541
Posts: 21
Joined: Feb 01, 2013


Posted: Jun 06, 2013 @ 02:14 AM             Msg. 3 of 3
Brilliant! Works a treat, thanks for taking time to replu.

Peter Davies