Topics

Forum Topics not found

Replies

MRSV
30 May 2016, 18:45

RE:

michele.carofiglio said:

Hi

when my program finds an asset like UK100 on today (open market but no data because today is holiday in UK) the "MarketData.GetSeries(_symbol2, TimeFrame)" runs in a loop to infinity.

I don't know how I can avoid this problem.

Thanks for your help in advance.

Mike

You could make a method that checks if the current day is a holiday, an add if(isHoliday()== false).

 


@MRSV

MRSV
30 May 2016, 16:50

RE:

marc.sischka said:

Hi all, 

The strategy creates a position onBar (daily). I want the strategy to close the position on the next bar no matter what. 

Could you please help me how I can achieve that. 

Thanks

 

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

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

        protected override void OnBar()
        {
            if (Positions.Count != 0)
            {
                ClosePosition(Positions.Find("pos"));
            }
            
            ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "pos");
        }

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

Set timeframe to daily. You didn't say if you wantet to open a buy or sell position, so I set it to open a buy position.


@MRSV