Topics
30 Aug 2024, 11:09
 0
 345
 0
15 Aug 2024, 13:12
 0
 348
 0
23 Jul 2024, 17:30
 0
 434
 0
02 Jun 2024, 00:49
 2
 598
 3
14 Apr 2024, 00:05
 604
 4
Replies

AlgoCorner
11 Aug 2020, 02:55

RE: RE:

GridSurfer said:

Hi Waxy,

you just need to repeat the LoadMoreHistory() until you have enough history data.

API.Ticks symbolTicks;
DateTime firstDt = new DateTime(2020, 8, 1);

symbolTicks = MarketData.GetTicks();
while (symbolTicks[0].Time.CompareTo(firstDt) > 0)
{
     symbolTicks.LoadMoreHistory();
}

Maybe Panagiotis will post the snipplet in the API-Reference. I was looking for it before as well.

Cheers
GridSurfer

Thank you,

This works!

 


@AlgoCorner

AlgoCorner
05 Dec 2019, 18:19

RE:

What I mean is that it takes me 10-15 seconds to load these symbols, not almost instantly, I'm using 30mbps.

Only after the first load, any refresh of the bot/indicator and the bars load instantly afterward (which again, it's great news).

Also, I think a good option would be to have an overload where we can specify how many bars to load, because many times a thousand daily bars is not really needed, is it possible?

And I'm since this is part of the update I thought it would be correct to ask about it in this thread, I'll leave it here and if needed I'll open a new thread, sorry about that.

Thanks for your support


@AlgoCorner

AlgoCorner
05 Dec 2019, 16:39

RE: RE: RE:

Hello Panagiotis,

I'm trying out the following code,

using System.Collections.Generic;
using cAlgo.API;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {
        private readonly List<Bars> _bars = new List<Bars>();
        private readonly string[] _mySymbols = {"EURUSD","GBPUSD","EURJPY","USDJPY","AUDUSD","USDCHF","GBPJPY","USDCAD","EURGBP","EURCHF"};

        protected override void Initialize()
        {
            Print("Initializing");

            foreach (var symbol in _mySymbols)
            {
                Print(string.Format("Loading Symbol {0}", symbol));
                MarketData.GetBarsAsync(TimeFrame.Hour, symbol, bar =>
                {
                    _bars.Add(bar);
                    Print(string.Format("{0} Loaded, Bars: {1}", bar.SymbolName, bar.Count));
                });
            }

            Print("End Initializing");
        }

        public override void Calculate(int index) { }
    }
}

I get the responses in the log in this order, doesn't seem to work properly to me, is this correct, or I'm I doing something wrong, is this the best way to do it? It takes about 16 seconds to load them all (don't get me wrong it's a big improvement), could it load faster?

05/12/2019 14:20:04.782 | Initializing
05/12/2019 14:20:04.782 | Loading Symbol EURUSD
05/12/2019 14:20:04.797 | Loading Symbol GBPUSD
05/12/2019 14:20:04.797 | Loading Symbol EURJPY
05/12/2019 14:20:05.219 | Loading Symbol USDJPY
05/12/2019 14:20:05.235 | Loading Symbol AUDUSD
05/12/2019 14:20:05.657 | Loading Symbol USDCHF
05/12/2019 14:20:06.641 | Loading Symbol GBPJPY
05/12/2019 14:20:07.078 | Loading Symbol USDCAD
05/12/2019 14:20:07.110 | Loading Symbol EURGBP
05/12/2019 14:20:07.485 | Loading Symbol EURCHF
05/12/2019 14:20:07.953 | Loading Symbol AUDJPY
05/12/2019 14:20:08.344 | Loading Symbol NZDUSD
05/12/2019 14:20:08.391 | Loading Symbol CHFJPY
05/12/2019 14:20:08.813 | Loading Symbol EURAUD
05/12/2019 14:20:09.344 | Loading Symbol CADJPY
05/12/2019 14:20:09.782 | Loading Symbol GBPAUD
05/12/2019 14:20:10.250 | Loading Symbol EURCAD
05/12/2019 14:20:10.657 | Loading Symbol AUDCAD
05/12/2019 14:20:11.203 | Loading Symbol GBPCAD
05/12/2019 14:20:11.813 | Loading Symbol USDNOK
05/12/2019 14:20:13.063 | Loading Symbol AUDCHF
05/12/2019 14:20:13.672 | Loading Symbol USDMXN
05/12/2019 14:20:15.094 | Loading Symbol GBPNZD
05/12/2019 14:20:15.110 | Loading Symbol CADCHF
05/12/2019 14:20:15.719 | Loading Symbol USDSEK
05/12/2019 14:20:16.969 | Loading Symbol GBPCHF
05/12/2019 14:20:17.578 | Loading Symbol EURRUB
05/12/2019 14:20:19.453 | Loading Symbol NZDCHF
05/12/2019 14:20:20.078 | Loading Symbol NZDCAD
05/12/2019 14:20:20.703 | Loading Symbol AUDNZD
05/12/2019 14:20:20.735 | End Initializing
05/12/2019 14:20:20.735 | EURUSD Loaded, Bars: 2323
05/12/2019 14:20:20.735 | GBPUSD Loaded, Bars: 2013
05/12/2019 14:20:20.735 | EURJPY Loaded, Bars: 2013
05/12/2019 14:20:20.735 | USDJPY Loaded, Bars: 1650
05/12/2019 14:20:20.750 | AUDUSD Loaded, Bars: 2013
05/12/2019 14:20:20.750 | USDCHF Loaded, Bars: 2013
05/12/2019 14:20:20.750 | GBPJPY Loaded, Bars: 2013
05/12/2019 14:20:20.750 | USDCAD Loaded, Bars: 2013
05/12/2019 14:20:20.750 | EURGBP Loaded, Bars: 2013
05/12/2019 14:20:20.750 | EURCHF Loaded, Bars: 2013
05/12/2019 14:20:20.750 | AUDJPY Loaded, Bars: 2013
05/12/2019 14:20:20.750 | NZDUSD Loaded, Bars: 2013
05/12/2019 14:20:20.750 | CHFJPY Loaded, Bars: 2013
05/12/2019 14:20:20.750 | EURAUD Loaded, Bars: 2013
05/12/2019 14:20:20.750 | CADJPY Loaded, Bars: 2013
05/12/2019 14:20:20.750 | GBPAUD Loaded, Bars: 2013
05/12/2019 14:20:20.750 | EURCAD Loaded, Bars: 2013
05/12/2019 14:20:20.750 | AUDCAD Loaded, Bars: 2013
05/12/2019 14:20:20.750 | GBPCAD Loaded, Bars: 2013
05/12/2019 14:20:20.750 | USDNOK Loaded, Bars: 1170
05/12/2019 14:20:20.750 | AUDCHF Loaded, Bars: 2013
05/12/2019 14:20:20.750 | USDMXN Loaded, Bars: 1170
05/12/2019 14:20:20.750 | GBPNZD Loaded, Bars: 2013
05/12/2019 14:20:20.750 | CADCHF Loaded, Bars: 2013
05/12/2019 14:20:20.750 | USDSEK Loaded, Bars: 1170
05/12/2019 14:20:20.750 | GBPCHF Loaded, Bars: 2013
05/12/2019 14:20:20.750 | EURRUB Loaded, Bars: 1167
05/12/2019 14:20:20.750 | NZDCHF Loaded, Bars: 2013
05/12/2019 14:20:20.985 | NZDCAD Loaded, Bars: 2012
05/12/2019 14:20:21.203 | AUDNZD Loaded, Bars: 2013
 

PanagiotisCharalampous said:

Waxy said:

Hello Spotware,

These are indeed great additions,

I see now that when I load an indicator that uses multiple MarketSeries (or now Bars) it takes much less than before, and this is great news, but at the start, it takes the same as before, so, I'd like to know if it's possible to improve or what's the best way now to load multiple series loading for indicators/bots during initialization, let's say I want to load 10 symbol bars, can I load these in parallel now?

 

Hi Xavier,

You can use MarketData.GetBarsAsync() and MarketData.GetTicksAsync() to get data asynchronously.

Best Regards,

Panagiotis 

Join us on Telegram

 

 


@AlgoCorner

AlgoCorner
05 Dec 2019, 05:05

RE:

Hello Spotware,

These are indeed great additions,

I see now that when I load an indicator that uses multiple MarketSeries (or now Bars) it takes much less than before, and this is great news, but at the start, it takes the same as before, so, I'd like to know if it's possible to improve or what's the best way now to load multiple series loading for indicators/bots during initialization, let's say I want to load 10 symbol bars, can I load these in parallel now?

 


@AlgoCorner

AlgoCorner
27 Nov 2019, 00:23

I think I have sorted this out, by building inside Visual Studio without clicking build again in cTrader the Debug mode will not be overridden.


@AlgoCorner

AlgoCorner
27 Sep 2019, 19:16 ( Updated at: 21 Dec 2023, 09:21 )

I'm not sure if this is a bug or a feature, the text is shown above the price axis, how can I edit or fix this? Chart.Width should not consider this axis area.

Thanks for your support.


@AlgoCorner

AlgoCorner
18 Sep 2019, 08:49

Thanks for replying,

I'm sorry, what I was actually trying to suggest by improving RemoveChild() is that it should have an overload to just remove by index [Column,Row], or know by these if a "cell" has any child in it, we can make workarounds for it, but it would be nice to have it.

Thanks for the font tips as well.
Best Regards,
Xavier R.


@AlgoCorner

AlgoCorner
17 Sep 2019, 07:45

Hello Panagiotis, thanks for your support.

Can you tell me which FamilyFont types are supported? it seems I have to guess, enums for this would be nice.

Another suggestion, the grid should be improved to access and edit objects by index [row, colum], I don't see options to do this, there are only options to remove entire rows or columns.

The .AddChild() property includes row, column parameters, but the .RemoveChild() does not.

I hope this or something similar gets added before 3.6 is released.

Thanks

 


@AlgoCorner

AlgoCorner
16 Aug 2019, 02:25

Hello Spotware, thanks for these additions, they are really helpful.

I have two questions:

What is the "IsHitTestVisible" property for? can we get an example?

My second question might be a request also, it seems we can't modify the grid lines inside a Grid, it would be nice to change the style, width, and color, I can use BorderPanel to circumvent this issue for the moment.


Best Regards,


@AlgoCorner

AlgoCorner
15 May 2019, 20:04

Add the namespace System.
 

using System;

 


@AlgoCorner

AlgoCorner
28 Apr 2019, 19:44

Hello Panagiotis,

I will send it, thanks for your support.


@AlgoCorner

AlgoCorner
18 Apr 2019, 23:08 ( Updated at: 21 Dec 2023, 09:21 )

Hello Panagiotis,

I apologize, let me explain:

It is supposed that this event is fired every time you scroll through the chart, right?, however, it's being fired constantly without any interaction with the chart whatsoever, it's a bit erratic, I'm not sure what triggers it.


@AlgoCorner

AlgoCorner
17 Apr 2019, 18:09

My bad tho, I tried it and it doesn't work outside forms, the one built in cTrader is enough for most tasks I think.


@AlgoCorner

AlgoCorner
15 Apr 2019, 21:52

You can do:
 

         protected override void OnStart()
        {
            Timer.Start(TimeSpan.FromMilliseconds(100));
        }
        
        protected override void OnTimer()
        {
            Print("Test");
        }

 

If you need more timers you could use the Timer inside System.Windows.Forms, I read that is also single threaded, read the documentation here:
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.timer?view=netframework-4.7.2

The timers inside System.Timers are not single threaded and I think they're not safe.


@AlgoCorner

AlgoCorner
12 Apr 2019, 22:35

Hello,

I'm the one who made this code long ago, I will update it, see the code below.
 

using cAlgo.API;
 
namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class OCO : Robot
    {
        //---ORDER 1

        [Parameter("Order #1 Type")]
        public string InputOrderType1 { get; set; }

        [Parameter("Order #1 Price", DefaultValue = 1.0)]
        public double InputOrderPrice1 { get; set; }

        [Parameter("Order #1 Size", DefaultValue = 10000)]
        public double InputOrderSize1 { get; set; }

        [Parameter("Order #1 SL", DefaultValue = 20)]
        public double InputStopLoss1 { get; set; }

        [Parameter("Order #1 TP", DefaultValue = 40)]
        public double InputTakeProfit1 { get; set; }
 
        //---ORDER 2
 
        [Parameter("Order #2 Type")]
        public string InputOrderType2 { get; set; }

        [Parameter("Order #2 Price", DefaultValue = 1.0)]
        public double InputOrderPrice2 { get; set; }

        [Parameter("Order #2 Size", DefaultValue = 10000)]
        public double InputOrderSize2 { get; set; }

        [Parameter("Order #2 SL", DefaultValue = 20)]
        public double InputStopLoss2 { get; set; }

        [Parameter("Order #1 TP", DefaultValue = 40)]
        public double InputTakeProfit2 { get; set; }
 
        private string _label;
 
        protected override void OnStart()
        {
            _label = string.Format("{0}{1}{2}", Symbol.Code, TimeFrame, Server.Time.Ticks);
            PendingOrders.Filled += PendingOrders_Filled;

            if (InputOrderType1.ToLower() == "sell")
            {
                if (InputOrderPrice1 > MarketSeries.Close.LastValue)
                    PlaceLimitOrder(TradeType.Sell, Symbol, InputOrderSize1, InputOrderPrice1, _label, InputStopLoss1, InputTakeProfit1);
                else
                    PlaceStopOrder(TradeType.Sell, Symbol, InputOrderSize1, InputOrderPrice1, _label, InputStopLoss1, InputTakeProfit1);
            }
            else if (InputOrderType1.ToLower() == "buy")
            {
                if (InputOrderPrice1 > MarketSeries.Close.LastValue)
                    PlaceStopOrder(TradeType.Buy, Symbol, InputOrderSize1, InputOrderPrice1, _label, InputStopLoss1, InputTakeProfit1);
                else
                    PlaceLimitOrder(TradeType.Buy, Symbol, InputOrderSize1, InputOrderPrice1, _label, InputStopLoss1, InputTakeProfit1);
            }
            else
            {
                Print("Parameter not recognized, bot will stop");
                Stop();
            }
 
            if (InputOrderType2.ToLower() == "sell")
            {
                if (InputOrderPrice2 > MarketSeries.Close.LastValue)
                    PlaceLimitOrder(TradeType.Sell, Symbol, InputOrderSize2, InputOrderPrice2, _label, InputStopLoss2, InputTakeProfit2);
                else
                    PlaceStopOrder(TradeType.Sell, Symbol, InputOrderSize2, InputOrderPrice2, _label, InputStopLoss2, InputTakeProfit2);
            }
            else if (InputOrderType2.ToLower() == "buy")
            {
                if (InputOrderPrice2 > MarketSeries.Close.LastValue)
                    PlaceStopOrder(TradeType.Buy, Symbol, InputOrderSize2, InputOrderPrice2, _label, InputStopLoss2, InputTakeProfit2);
                else
                    PlaceLimitOrder(TradeType.Buy, Symbol, InputOrderSize2, InputOrderPrice2, _label, InputStopLoss2, InputTakeProfit2);
            }
            else
            {
                Print("Parameter not recognized, bot will stop");
                Stop();
            }
        }

        private void PendingOrders_Filled(PendingOrderFilledEventArgs obj)
        {
            if (obj.PendingOrder.Label != _label)
                return;

            foreach (PendingOrder order in PendingOrders)
            {
                if (order.Label == _label)
                {
                    CancelPendingOrder(order);
                }
            }
        }

        protected override void OnTick()
        {

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

 


@AlgoCorner

AlgoCorner
02 Apr 2019, 00:17

cTrader 3.5 is currently in Beta

The official version is 3.3 and doesn't support it yet.


@AlgoCorner

AlgoCorner
26 Mar 2019, 19:46

Sorry the right answer is the last one, forum doesn't allow to edit post.


@AlgoCorner

AlgoCorner
26 Mar 2019, 19:45

private bool isNearTargetSignal()

{
    if (pos == null) return false;
 

    if (pos.TradeType == TradeType.Buy)

    {

        if (sym.Bid > pos.TakeProfit - (sym.PipSize * TriggerPips))

            return true;

    }

    else if (pos.TradeType == TradeType.Sell)

    {

        if (sym.Ask < pos.TakeProfit + (sym.PipSize * TriggerPips))

            return true;

    }

    return false;

}


@AlgoCorner

AlgoCorner
26 Mar 2019, 19:45

private bool isNearTargetSignal()
{
    if (pos == null)
    

    if (pos.TradeType == TradeType.Buy)
    {
        if (sym.Bid > pos.TakeProfit - (sym.PipSize * TriggerPips))
            return true;
    }
    else if (pos.TradeType == TradeType.Sell)
    {
        if (sym.Ask < pos.TakeProfit + (sym.PipSize * TriggerPips))
            return true;
    }
    return false;
}

 


@AlgoCorner

AlgoCorner
20 Mar 2019, 19:36

Hello!

Please allow the use of Description Attribute to enums so they could be easily readable, i.e:
 

using System.ComponentModel; 

public enum MyEnum 
{ 
    [Description("value 1")] 
    Value_1, 
    [Description("value 2")]
    Value_2, 
    [Description("value 3")]
    Value_3
}


Thanks for your hard work.


@AlgoCorner