Help About CBot based on renko charts

Created at 09 Aug 2023, 12:08
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!
TE

Termi80

Joined 06.12.2020

Help About CBot based on renko charts
09 Aug 2023, 12:08


Good morning,
I would need to recover the following information
-Catch the creation of the new brick
-Get the color of the last brick

How i can do it?

Thanks

 


@Termi80
Replies

firemyst
10 Aug 2023, 00:31

-Catch the creation of the new brick

When the “OnBar” event happens.

Or write your own in the “OnTick” method:

_currentIndex = Bars.OpenTimes.GetIndexByTime(Bars.OpenTimes.LastValue);

               if (_currentIndex != _previousIndex)
               {
               //Call your own OnBar method
                   OnBarForBot();
                   _previousIndex = _currentIndex;
               }

 

-Get the color of the last brick

Do you mean actual color? Or is what you really want to know whether the bar closed up or down?

I'll assume the latter since most bots/indicators don't care about actual colors - just check if the previous close price is > or < the previous open price.

if (Bars.ClosePrices.Last(1) > Bars.OpenPrices.Last(1))

   ///bullish bar

else

   ///bearish bar

 


@firemyst