chartObjects

Created at 14 Dec 2012, 07:23
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
lec0456's avatar

lec0456

Joined 14.11.2012

chartObjects
14 Dec 2012, 07:23


Can I use the Chart object in a robot to mark the chart everytime I execute an order?  any ideas how to do this?


@lec0456
Replies

admin
14 Dec 2012, 09:45 ( Updated at: 15 Jan 2024, 14:51 )

Please look at the examples in the API Reference for the methods in [ChartObjects]. If you like to DrawText everytime the order is executed you should use this in the  OnPositionOpened method.

For example:

		protected override void OnPositionOpened(Position openedPosition)
		{
			ChartObjects.DrawText("myObject", "text", StaticPosition.TopLeft);
		}



 


@admin

lec0456
14 Dec 2012, 15:52 ( Updated at: 23 Jan 2024, 13:11 )

RE:
admin said:

Please look at the examples in the API Reference for the methods in [ChartObjects]. If you like to DrawText everytime the order is executed you should use this in the  OnPositionOpened method.

For example:

		protected override void OnPositionOpened(Position openedPosition)
		{
			ChartObjects.DrawText("myObject", "text", StaticPosition.TopLeft);
		}



 

So, yes, I have this line in my OnPositionOpened.  it does not crash but it does not place a B or S on the chart where trades were executed???

 ChartObjects.DrawText("Trade" + TradeBarID.ToString(), position.TradeType==TradeType.Buy?"B"+position.Id:"S", MarketSeries.Close.Count-1, position.EntryPrice+3*Symbol.PipSize, VerticalAlignment.Center, HorizontalAlignment.Center, Colors.Yellow);


@lec0456

admin
04 Jan 2013, 16:55 ( Updated at: 21 Dec 2023, 09:20 )

What is being printed is in the second parameter.

The third parameter is the index (x-axis), the fourth is the price (y-axix) giving the position on the chart where the text is drawn.

see the intellisense.

 


@admin