PanagiotisCharalampous's avatar
PanagiotisCharalampous
26 follower(s) 0 following 1006 subscription(s)
Replies

PanagiotisCharalampous
13 Mar 2019, 09:09

Hi hmozahem,

We cannot reproduce such a behavior. Did you try restarting your cTrader? Do you still experience the same issue after restarting? If yes, can you please send us a full screenshot of cTrader so that we can see all the information in the application? After that, please send us some troubleshooting information as well. To do so, please press Ctrl+Alt+Shift+T, paste a link to this discussion in the text box and press Submit.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Mar 2019, 09:01

Hi a.fernandez.martinez,

Server.Time is a DateTiime. If you subtract two DateTime variables, you can find the TimeSpan between them.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
13 Mar 2019, 08:57

Hi Xavier,

You are using Reflection to get the default value of the property. Reflection cannot give you the current value in memory, just the value compiled in the assembly. 

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 17:38

Hi Nasser,

Can you please provide a small code example demonstrating that this function does not work properly? Maybe you are not using it correctly.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 17:21

Hi dmn,

We checked this but we cannot reproduce such behavior. Can you please let us know your screens resolution and scale of display?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 16:30

Hi a.fernandez.martinez,

Tick based timeframes are not supported yet for TimeFrame enum and for backtesting. However you can use them in live trading through a parameter. See below

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
    {
        [Parameter(DefaultValue = 0.0)]
        public TimeFrame Parameter { get; set; }

        protected override void OnStart()
        {
           
        }

        protected override void OnTick()
        {
            var series = MarketData.GetSeries(Parameter);
            Print(series.OpenTime.LastValue);
        }

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

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 16:01

Hi Patrick,

We never actually reported that this was fixed. We are still working on this. In the meanwhile, please avoid using dotted lines.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 15:56

Hi 

You can use the following function to get data from other timeframes.

   var series = MarketData.GetSeries(TimeFrame);

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 15:49

Hi Xavier,

What you are trying to do is not supported. The proper way to read output attributes is the below

            PropertyInfo[] props = typeof(TestOutputAttributes).GetProperties();
            foreach (PropertyInfo prop in props)
            {
                object[] attrs = prop.GetCustomAttributes(true);
                foreach (object attr in attrs)
                {
                    OutputAttribute outputAttr = attr as OutputAttribute;
                    if (outputAttr != null)
                    {
                        Print(outputAttr.LineColor.ToString());
                    }
                }
            }

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 15:47

Hi thamimsibi3,

Thanks for the clarification, that was not very clear.

See below the cBot based on your clarification

// -------------------------------------------------------------------------------------------------
//
//    This code is a cAlgo API sample.
//
//    This cBot is intended to be used as a sample and does not guarantee any particular outcome or
//    profit of any kind. Use it at your own risk
//
//    The "Sample Martingale cBot" creates a random Sell or Buy order. If the Stop loss is hit, a new 
//    order of the same type (Buy / Sell) is created with double the Initial Volume amount. The cBot will 
//    continue to double the volume amount for  all orders created until one of them hits the take Profit. 
//    After a Take Profit is hit, a new random Buy or Sell order is created with the Initial Volume amount.
//
// -------------------------------------------------------------------------------------------------

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 SampleMartingalecBot : Robot
    {
        [Parameter("Initial Quantity (Lots)", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
        public double InitialQuantity { get; set; }

        [Parameter("Stop Loss", DefaultValue = 3)]
        public int StopLoss { get; set; }

        [Parameter("Take Profit", DefaultValue = 3)]
        public int TakeProfit { get; set; }

        private Random random = new Random();

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

            ExecuteOrder(InitialQuantity, GetRandomTradeType());
        }


        private void ExecuteOrder(double quantity, TradeType tradeType)
        {
            var volumeInUnits = Symbol.QuantityToVolumeInUnits(quantity);
            var result = ExecuteMarketOrder(tradeType, Symbol, volumeInUnits, "Martingale", StopLoss, TakeProfit);

            if (result.Error == ErrorCode.NoMoney)
                Stop();
        }

        private void OnPositionsClosed(PositionClosedEventArgs args)
        {
            Print("Closed");
            var position = args.Position;

            if (position.Label != "Martingale" || position.SymbolCode != Symbol.Code)
                return;

            if (position.GrossProfit > 0)
            {
                ExecuteOrder(InitialQuantity, position.TradeType);
            }
            else
            {
                if (position.TradeType == TradeType.Sell)
                    ExecuteOrder(position.Quantity * 2, TradeType.Buy);
                else
                    ExecuteOrder(position.Quantity * 2, TradeType.Sell);
            }
        }

        private TradeType GetRandomTradeType()
        {
            return random.Next(2) == 0 ? TradeType.Buy : TradeType.Sell;
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 15:18

Hi ryan.a.blake,

As the name indicates Spotware Beta is a beta version of cTrader. So usually it is one or two versions ahead. After properly tested and stabilized it is released to brokers.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 15:02

Hi astevani,

This is an old thread. Do you still experience the issue of indicators displaying differently on normal chart and on a backtesting chart? If yes, can you share one to check?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 14:48

Hi a.fernandez.martinez,

Here is an example

            var series = MarketData.GetSeries(TimeFrame.Minute);
            Print(series.TickVolume.LastValue);

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 14:45

Hi thamimsibi3,

Thanks for posting in our forum. See below

// -------------------------------------------------------------------------------------------------
//
//    This code is a cAlgo API sample.
//
//    This cBot is intended to be used as a sample and does not guarantee any particular outcome or
//    profit of any kind. Use it at your own risk
//
//    The "Sample Martingale cBot" creates a random Sell or Buy order. If the Stop loss is hit, a new 
//    order of the same type (Buy / Sell) is created with double the Initial Volume amount. The cBot will 
//    continue to double the volume amount for  all orders created until one of them hits the take Profit. 
//    After a Take Profit is hit, a new random Buy or Sell order is created with the Initial Volume amount.
//
// -------------------------------------------------------------------------------------------------

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 SampleMartingalecBot : Robot
    {
        [Parameter("Initial Quantity (Lots)", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
        public double InitialQuantity { get; set; }

        [Parameter("Stop Loss", DefaultValue = 3)]
        public int StopLoss { get; set; }

        [Parameter("Take Profit", DefaultValue = 3)]
        public int TakeProfit { get; set; }

        private Random random = new Random();

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

            ExecuteOrder(InitialQuantity, GetRandomTradeType());
        }


        private void ExecuteOrder(double quantity, TradeType tradeType)
        {
            var volumeInUnits = Symbol.QuantityToVolumeInUnits(quantity);
            var result = ExecuteMarketOrder(tradeType, Symbol, volumeInUnits, "Martingale", StopLoss, TakeProfit);

            if (result.Error == ErrorCode.NoMoney)
                Stop();
        }

        private void OnPositionsClosed(PositionClosedEventArgs args)
        {
            Print("Closed");
            var position = args.Position;

            if (position.Label != "Martingale" || position.SymbolCode != Symbol.Code)
                return;

            if (position.GrossProfit > 0)
            {
                ExecuteOrder(InitialQuantity, position.TradeType);
            }
            else
            {
                ExecuteOrder(position.Quantity * 2, position.TradeType);
            }
        }

        private TradeType GetRandomTradeType()
        {
            return random.Next(2) == 0 ? TradeType.Buy : TradeType.Sell;
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 14:43

Hi pozhy,

I offered a solution to a similar problem here.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 14:35

Hi procumulative@gmail.com,

We have received your email, thanks.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 14:30

Hi Nasser, 

The information is not enough for somebody to help you. Please provide us with the following

1) The complete cBot code.

2) The parameters you use to run the code.

3) The parameters you use for the displayed indicators.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 14:08

Hi erikvb,

It seems we have different indicators and it crashes on parameter initialization.You need to change the initialization of the indicator to the following

_hmaSignal = Indicators.GetIndicator<HMASignals>(Periods,false,false,1,false,1);

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 13:02

Hi pozhy,

In principle it is unless it is blocked. Paul Hayes has written a nice article about this.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 12:58

Hi everythingbusiness10,

If you need professional assistance for developing your cBot, you can always post a Job or contact a Consultant.

Best Regards,

Panagiotis


@PanagiotisCharalampous