Opening transaction when candle closed

Created at 05 Feb 2019, 17:32
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!
AR

aricesar

Joined 30.01.2019

Opening transaction when candle closed
05 Feb 2019, 17:32


Hi all! I wanna do a very simple think. I want execute transaction when one candle close and open a new candle. How i can do this?

@aricesar
Replies

PanagiotisCharalampous
05 Feb 2019, 17:40

Hi aricesar,

Thank you for posting in our forum. You can use the OnBar() function. See below an example

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        protected override void OnStart()
        {
            // Put your initialization logic here
        }

        protected override void OnBar()
        {
            ExecuteMarketOrder(TradeType.Buy, Symbol, 1000);
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous