cbot successfully created but does not execute orders when the trigger is triggered 2

Created at 06 Jun 2023, 16:47
UB

ubiratamoreira.trader

Joined 03.06.2023

cbot successfully created but does not execute orders when the trigger is triggered 2
06 Jun 2023, 16:47


I made modifications, it activates, I put a few pips for testing and it does not execute orders.
follows modified code

 

using System;
using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class PipsDeVelas : Robot
    {
        [Parameter("Pips de Compra", DefaultValue = 40)]
        public int CompraPips { get; set; }

        [Parameter("Pips de Venda", DefaultValue = 40)]
        public int VendaPips { get; set; }

        [Parameter("Trailing Stop (Pips)", DefaultValue = 30)]
        public int TrailingStopPips { get; set; }

        [Parameter("Tamanho do Lote", DefaultValue = 0.01)]
        public double LotSize { get; set; }

        protected override void OnStart()
        {
            Positions.Closed += OnPositionClosed;
        }

        protected override void OnBar()
        {
            double currentCandleRange = Symbol.Bid - Symbol.Ask;
            double compraPipsValue = CompraPips * Symbol.PipSize;
            double vendaPipsValue = VendaPips * Symbol.PipSize;

            if (currentCandleRange > compraPipsValue)
            {
                double volume = Symbol.QuantityToVolumeInUnits(LotSize);
                ExecuteMarketOrder(TradeType.Buy, Symbol.Name, volume, "Compra", null, null, null, GetTrailingStop());
            }

            if (currentCandleRange > vendaPipsValue)
            {
                double volume = Symbol.QuantityToVolumeInUnits(LotSize);
                ExecuteMarketOrder(TradeType.Sell, Symbol.Name, volume, "Venda", null, null, null, GetTrailingStop());
            }
        }

        private void OnPositionClosed(PositionClosedEventArgs args)
        {
            Print("Position closed: " + args.Position.Label);
        }

        private bool GetTrailingStop()
        {
            return true;
        }
    }
}
 


@ubiratamoreira.trader