Coding almost finished strategy

100 USD  Payment method:  Direct Payment
Open

Hi,

Somehow when I run the cbot below it does not trade, although there are no error messages.

Can you make this cbot work? 

If you need more information, please send an E-Mail at: david.sanchez@hotmail.ch

using System;
using System.Linq;
using System.Collections.Generic;
using cAlgo.API;
using cAlgo.API.Requests;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Arbitrage1 : Robot
    {


        private BollingerBands boll;

        protected override void OnStart()
        {

            var ticks = MarketData.GetTicks("AUDUSD");
            var series = CreateDataSeries();
            int i = 0;
            foreach (var tick in ticks)
            {
                series[i] = tick.Ask;
                i++;
            }

            var ticks2 = MarketData.GetTicks("EURUSD");
            var series2 = CreateDataSeries();
            int t = 0;
            foreach (var tick in ticks2)
            {
                series2[t] = tick.Bid;
                t++;
            }

            var Spread = CreateDataSeries();

            for (int X = 0; X < 10; X++)
            {

                Spread[X] = series[X] - series2[X];

            }

            boll = Indicators.BollingerBands(Spread, 10, 1, MovingAverageType.Simple);

        }

        protected override void OnTick()
        {

            var ticks = MarketData.GetTicks("AUDUSD");
            var series = CreateDataSeries();
            int i = 0;
            foreach (var tick in ticks)
            {
                series[i] = tick.Ask;
                i++;
            }

            var ticks2 = MarketData.GetTicks("EURUSD");
            var series2 = CreateDataSeries();
            int t = 0;
            foreach (var tick in ticks)
            {
                series2[t] = tick.Bid;
                t++;
            }

            var Spread = CreateDataSeries();

            for (int X = 0; X < 10; X++)
            {

                Spread[X] = series[X] - series2[X];

            }

            boll = Indicators.BollingerBands(Spread, 10, 1, MovingAverageType.Simple);



            if (boll.Top[0] <= Spread[0])
            {

                var openPositions1 = Positions.FindAll("Arbitrage1", "AUDUSD");

                foreach (var order in openPositions1)
                {
                    ClosePosition(order);
                }

                var openPositions2 = Positions.FindAll("Arbitrage1", "EURUSD");

                foreach (var order in openPositions2)
                {
                    ClosePosition(order);
                }

                ExecuteMarketOrder(TradeType.Sell, "AUDUSD", 100000, "Arbitrage1");
                ExecuteMarketOrder(TradeType.Buy, "EURUSD", 100000, "Arbitrage1");

            }

            else if (boll.Bottom[0] >= Spread[0])
            {

                var openPositions1 = Positions.FindAll("Arbitrage1", "AUDUSD");

                foreach (var order in openPositions1)
                {
                    ClosePosition(order);
                }

                var openPositions2 = Positions.FindAll("Arbitrage1", "EURUSD");

                foreach (var order in openPositions2)
                {
                    ClosePosition(order);
                }

                ExecuteMarketOrder(TradeType.Buy, "AUDUSD", 100000);
                ExecuteMarketOrder(TradeType.Sell, "EURUSD", 100000);
            }

        }
    }
}

 

Hi. I can do that. Write me and tell me what do you need exactly.

Email: Bienve.pf@hotmail.com 

Whatsapp: +34654115547

Regards