Error in routine after upgrade in system

Created at 06 May 2020, 17:29
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!
EL

eliezer_barros

Joined 21.12.2018

Error in routine after upgrade in system
06 May 2020, 17:29


Hi, good morning

This routine below was running well but have a error because the system received a upgrade and I don't know this information.

Please, can you check for me?

Thank you

Eli.

 

 

using cAlgo.API;

using cAlgo.API.Internals;
namespace cAlgo.Robots
{

    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Testeusandohoraanteriorcomoreferencia : Robot
    {
        [Parameter(DefaultValue = 1)]
        public double VolumeToOpenOrders { get; set; }

        [Parameter(DefaultValue = 1000)]
        public int TakeProfitInPips { get; set; }

        [Parameter("Stop Loss", DefaultValue = 2000)]
        public int StopLoss { get; set; }

        [Parameter("Hora Abertura   H", DefaultValue = 5)]
        public int LastValue { get; set; }



        protected override void OnBar()
        {
            if (Bars.OpenTimes.LastValue.Hour == LastValue)
            {
                //  var PreviusClose = Bars.Close.Last(5);
                var PreviusClose = Bars.ClosePrices(5);
                var PreviusOpen = Bars.OpenPrices(5);

                if (PreviusClose != PreviusOpen)
                {
                    if (PreviusClose > PreviusOpen)
                        ExecuteMarketOrder(TradeType.Buy, Symbol.Name, VolumeToOpenOrders, "", StopLoss, TakeProfitInPips);
                    {
                        if (PreviusClose < PreviusOpen)
                            ExecuteMarketOrder(TradeType.Sell, Symbol.Name, VolumeToOpenOrders, "", StopLoss, TakeProfitInPips);
                        {
                        }
                    }
                }
            }
        }
    }
}


@eliezer_barros
Replies

PanagiotisCharalampous
07 May 2020, 08:37

Hi Eliezer,

You still need to use Last() for ClosePrices. See below

 var PreviusClose = Bars.ClosePrices.Last(5);

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous