ChartObjects.DrawText in cBots

Created at 21 Jul 2015, 17:14
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!
.I

.ics

Joined 10.03.2015

ChartObjects.DrawText in cBots
21 Jul 2015, 17:14


Hi,

I was wondering if it's possible to use the ChartObjects.DrawText methode in cBots?
The goal is when opening a position successfully, to draw an arrow under (when buy) or above (when sell) the candlestick.

If this is possible, how to receive the index of the specific candlestick?

Thanks.


@.ics
Replies

Spotware
21 Jul 2015, 17:33

Dear Trader,

Please take a look at the following indicator: /algos/indicators/show/253 and at the GetIndexByExactTime reference.

We hope this helps you.


@Spotware

.ics
21 Jul 2015, 22:37

Thanks for the guidance Spotware, but still getting below error:
03/01/2000 03:00:00.000 | Crashed in OnBar with NullReferenceException: Object reference not set to an instance of an object.

Here is the snippet of code what is causing the error:

protected override void OnBar()
{
    
    dblLots = 0.1;

    TradeResult result = PlaceStopOrder(TradeType.Buy, Symbol, Symbol.QuantityToVolume(dblLots), dblPriceBuy, String.Concat("myStopBuy-", dblLots), dblSlBuy, dblPipsTP, Server.Time.AddHours(1));
    if (result.IsSuccessful)
    {
       ChartObjects.DrawText(String.Concat("myStopBuy-", result.Position.Id), strArrowUp, MarketSeries.OpenTime.GetIndexByTime(result.Position.EntryTime), result.Position.EntryPrice - 5 * Symbol.PipSize, VerticalAlignment.Bottom, HorizontalAlignment.Center);
    }
    else
    {
        Print("myStopBuy was not successful. Error: {0} - Lots: {1}", result.Error.Value, dblLots);
    }
    
}

 


@.ics

Spotware
22 Jul 2015, 11:06

Dear Trader,

Please take a look at the following article regarding NullReferenceExceptions: https://msdn.microsoft.com/en-us/library/system.nullreferenceexception(v=vs.110).aspx

Please note that we do not provide coding assistance services. We more than glad to assist you with specific questions about cAlgo.API. You also can contact one of our Partners or post a job in Development Jobs section for further coding assistance.


@Spotware