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

PanagiotisCharalampous
26 Sep 2017, 16:42

Hi George,

Spotware has given an answer to the original post. Please let me know what points of the discussion are not covered and which questions remain unanswered so I can elaborate.

Best Regards

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Sep 2017, 16:37

Hi Alex,

Thanks for the additional info. We do not control the entire order routing, therefore we cannot provide a comprehensive explanation for the execution time. After orders leave cTrader, they go to a liquidity aggregator, then to a bank and back. That part is out of our control and might cause delay depending on the LPs location. So it would be good to advice with your broker as well on this subject.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Sep 2017, 15:31

Hi Stokes Bay Trading,

Thanks for posting in the forum. Why don't you use the OnBar function instead of OnTick? It is executed whenever a bar is closed and a new one starts.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Sep 2017, 15:16

Hi hungtonydang,

The last example of this post demonstrated how to get the values for a specific time. If this is not what you need please elaborate a little bit more on what you are trying to do.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Sep 2017, 09:32

Hi hungtonydang,

My opinion is that if it happened once, it will definitely happen again. And you don't want this to happen while trading on a live account. It is better to share the code with the build error so that we can fix it.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Sep 2017, 09:28

Hi obaum1@gmail.com,

You can use ProtoOAAmendPositionStopLossTakeProfitReq in Trading API. See here

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Sep 2017, 09:24

Hi irmscher9,

We tried to reproduce this issue but we couldn't. We would appreciate if you could send troubleshooting information to the support team for further investigation. In order to this you need to press Ctrl+Alt+Shift+T when in cTrader/cAlgo. Please send the discussion thread link inside the message.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Sep 2017, 09:16

Hi tasr1r1,

Which version of VS do you use? Currently, the official support is for VS2013. If you want to use VS2015 or VS2017, you need to follow the workaround described above and open the solution files manually from the cBot's folder. Support for VS2015 and VS2017 will be added in an upcoming version of cTrader.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Sep 2017, 09:10

Hi Ahmad,

Did you try uninstalling the application and installing it again?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
25 Sep 2017, 11:26

Hi MaVe,

The below should be working

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

namespace cAlgo
{
    [Indicator("Text", IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Text : Indicator
    {
        [Parameter("Test TimeFrame", DefaultValue = "Hour12")]
        public TimeFrame TestTimeFrame { get; set; }
        private MarketSeries T;
// -----        
        Colors Tc = Colors.White;
// ------------------------------------------------------        
        protected override void Initialize()
        {
            T = MarketData.GetSeries(Symbol, TestTimeFrame);
        }
// ------------------------------------------------------ 
        public override void Calculate(int index)
        {
            var Text = GetTimeFrameText();
            ChartObjects.DrawText("Text", "Text " + Text, index + 1, T.Close.Last(1), VerticalAlignment.Top, HorizontalAlignment.Right, Tc);
        }

        private string GetTimeFrameText()
        {
            if (TestTimeFrame == TimeFrame.Hour12)
            {
                return "H12";
            }
            return TestTimeFrame.ToString();
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
25 Sep 2017, 10:16

Hi irmscher9,

The issue will be investigated by our product team. We will update you regarding this as soon as we have some conclusions.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
25 Sep 2017, 10:10

Hi Trader4ever,

I tried your indicator but I didn't experience any performance degradation. Can you please share a screenshot of your chart. It could be that something else causes the slow down.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
25 Sep 2017, 09:51

Hi MaVe,

There is no build in way to do that. You can try implementing your own function as below

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

namespace cAlgo
{
    [Indicator("Text", IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Text : Indicator
    {
        [Parameter("Test TimeFrame", DefaultValue = "Hour12")]
        public TimeFrame TestTimeFrame { get; set; }
        private MarketSeries T;
// -----        
        Colors Tc = Colors.White;
// ------------------------------------------------------        
        protected override void Initialize()
        {
            T = MarketData.GetSeries(Symbol, TestTimeFrame);
        }
// ------------------------------------------------------ 
        public override void Calculate(int index)
        {
            var Text = GetTimeFrameText();
            ChartObjects.DrawText("Text", "Text " + Text, index + 1, T.Close.Last(1), VerticalAlignment.Top, HorizontalAlignment.Right, Tc);
        }

        private string GetTimeFrameText()
        {
            if (TestTimeFrame == TimeFrame.Hour12)
            {
                return "H12";
            }
            return TestTimeFrame;
        }
    }
}

You can add more conditions and put the text you need for each timeframe. Let me know if this helps.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
25 Sep 2017, 09:12

Hi Ryan,

Did you try clean installation? See here at the bottom of the page.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
25 Sep 2017, 09:06

Hi Alex,

It would be useful to have some additional information like the broker and your location, so that we can try this ourselves and see if it happens and if the delay is justifiable.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
22 Sep 2017, 17:50

Hi hungtonydang,

I made the calculations as well and the results seem correct. Can you please check again your calculations?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
22 Sep 2017, 17:44

Hi hungtonydang,

I suspect that the issue is related the section where you are modifying the position. Both sections where 

foreach (var position in Positions)
{
.
.
.
.
}

In this case both cBots access the same collection of Positions therefore it is possible that both cBots are modifying the same position at the same time resulting to an exception. But this is just a guess.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
22 Sep 2017, 15:52

Hi cfuorvito@gmail.com,

It is because anotherSeries and AnotherTimeFrame are "dummy" variable names. Since you posted them in your code, I was with the impression that you will replace them yourself with whatever suits you. See below an example that builds using a daily timeframe and the Close values

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

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

        [Parameter("Volume", DefaultValue = 1000)]
        public int volume { get; set; }

        [Parameter(DefaultValue = 50, MinValue = 1)]
        public int StopLoss { get; set; }

        [Parameter(DefaultValue = 50, MinValue = 1)]
        public int TakeProfit { get; set; }


        [Parameter("MACD LongCycle", DefaultValue = 26, MinValue = 1)]
        public int LongCycle { get; set; }

        [Parameter("MACD ShortCycle", DefaultValue = 12, MinValue = 1)]
        public int ShortCycle { get; set; }

        [Parameter("MACD Period", DefaultValue = 9, MinValue = 1)]
        public int MACDPeriod { get; set; }

        private MacdCrossOver _MACD;

        protected override void OnBar()
        {
            var dailySeries = MarketData.GetSeries(TimeFrame.Daily);
            _MACD = Indicators.MacdCrossOver(anotherSeries.Close, LongCycle, ShortCycle, MACDPeriod);
            if (_MACD.MACD.Last(1) < _MACD.Signal.Last(1) && _MACD.MACD.Last(0) > _MACD.Signal.Last(0) && _MACD.Signal.Last(0) < 0)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, volume, "korakodmy", StopLoss, TakeProfit, 5);
            }

            if (_MACD.MACD.Last(1) > _MACD.Signal.Last(1) && _MACD.MACD.Last(0) < _MACD.Signal.Last(0) && _MACD.Signal.Last(0) > 0)
            {
                ExecuteMarketOrder(TradeType.Sell, Symbol, volume, "korakodmy", StopLoss, TakeProfit, 5);
            }
        }

    }

}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
22 Sep 2017, 15:32

Hi,

Apologies the code had a small mistake. The anotherSeries was not passed into the MacdCrossOver() function. Can you try the below and let me know?

        protected override void OnBar()
        {
            var anotherSeries = MarketData.GetSeries(AnotherTimeFrame);
            _MACD = Indicators.MacdCrossOver(anotherSeries, LongCycle, ShortCycle, MACDPeriod);
            if (_MACD.MACD.Last(1) < _MACD.Signal.Last(1) && _MACD.MACD.Last(0) > _MACD.Signal.Last(0) && _MACD.Signal.Last(0) < 0)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, volume, "korakodmy", StopLoss, TakeProfit, 5);
            }

            if (_MACD.MACD.Last(1) > _MACD.Signal.Last(1) && _MACD.MACD.Last(0) < _MACD.Signal.Last(0) && _MACD.Signal.Last(0) > 0)
            {
                ExecuteMarketOrder(TradeType.Sell, Symbol, volume, "korakodmy", StopLoss, TakeProfit, 5);
            }

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
22 Sep 2017, 15:00

Hi cfuorvito@gmail.com

You need to pass the series returned into anotherSeries variable into the MacdCrossOver() function. See example below

protected override void OnBar()
        {
            var anotherSeries = MarketData.GetSeries(AnotherTimeFrame);
            _MACD = Indicators.MacdCrossOver(LongCycle, ShortCycle, MACDPeriod);
            if (_MACD.MACD.Last(1) < _MACD.Signal.Last(1) && _MACD.MACD.Last(0) > _MACD.Signal.Last(0) && _MACD.Signal.Last(0) < 0)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, volume, "korakodmy", StopLoss, TakeProfit, 5);
            }

            if (_MACD.MACD.Last(1) > _MACD.Signal.Last(1) && _MACD.MACD.Last(0) < _MACD.Signal.Last(0) && _MACD.Signal.Last(0) > 0)
            {
                ExecuteMarketOrder(TradeType.Sell, Symbol, volume, "korakodmy", StopLoss, TakeProfit, 5);
            }
        }

Let me know if the above helps,

Best Regards,

Panagiotis


@PanagiotisCharalampous