Help

Created at 14 Dec 2020, 12:26
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!
DO

dordkash@gmail.com

Joined 30.09.2017

Help
14 Dec 2020, 12:26


Hi

Hello
This bot does not work, please help me
I want to buy and sell based on the Heicken

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 HEIKEN : Robot
    {



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


        private IndicatorDataSeries heikenopen;
        private IndicatorDataSeries heikenclose;


        protected override void OnStart()
        {
            // Put your initialization logic here




        }

        protected override void OnBar()
        {
            // Put your core logic here

            heikenopen = CreateDataSeries();
            heikenclose = CreateDataSeries();

            int index = Bars.ClosePrices.Count - 1;


            var open = Bars.OpenPrices[index];
            var high = Bars.HighPrices[index];
            var low = Bars.LowPrices[index];
            var close = Bars.ClosePrices[index];



            double haOpen;

            if (index > 0)
                haOpen = (heikenopen[index - 1] + heikenclose[index - 1]) / 2;
            else
                haOpen = (open + close) / 2;



            var haClose1 = (open + high + low + close) / 4;







            if (haClose1 > haOpen)
            {
                foreach (var position in Positions.FindAll("sell"))
                    ClosePosition(position);

                ExecuteMarketOrder(TradeType.Buy, SymbolName, 1000, "buy");
            }
            else if (haClose1 < haOpen)
            {
                foreach (var position in Positions.FindAll("buy"))
                    ClosePosition(position);

                ExecuteMarketOrder(TradeType.Sell, SymbolName, 1000, "sell");
            }


            heikenopen[index] = haOpen;
            heikenclose[index] = haClose1;




        }

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

Ashi indicator


@dordkash@gmail.com
Replies

PanagiotisCharalampous
14 Dec 2020, 12:29

Hi dordkash@gmail.com,

If you need somebody to develop the cBot for you, you can post a Job or contact a Consultant.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous