Topics
16 Nov 2023, 07:42
 1104
 1
15 Nov 2023, 10:36
 1979
 16
Replies

Spotware
17 Jul 2014, 10:03

Do you still observe the issue?


@Spotware

Spotware
17 Jul 2014, 09:32

We cannot provide a time estimate for the release of tick data backtesting. 


@Spotware

Spotware
16 Jul 2014, 12:33

Please avoid accessing API objects and functions from separate threads. cAlgo.API is not thread safe.


@Spotware

Spotware
16 Jul 2014, 11:33

If you refer to the quality of generated ticks we have great news for you. We are preparing tick data backtesting to be released. By using tick data backtesting you will be able to test your cBots with historical spreads. Furthermore, in tick data backtesting Bid and Ask prices come asynchronously with millisecond precision.

 

 


@Spotware

Spotware
15 Jul 2014, 10:02

Thank you for your suggestion. We will consider it. Additionally you can post your idea to vote.spotware.com.


@Spotware

Spotware
15 Jul 2014, 09:39

You can try to put such Print statements to WPOrderBook4MA indicator and compare indexes.


@Spotware

Spotware
15 Jul 2014, 09:35

I think I already know the answer but is it possible to create a cBot or indicator that would modify a manually placed trade before it is sent to the trade server for execution ? 

No, it is not possible. However your cBot can modify positions created manually.


@Spotware

Spotware
15 Jul 2014, 09:35

RE:

jobenb said:

Hi cTrader Team

 

I have a suggestion which will help the trader community immensely. Could you please add functionality that you can set the risk $ amount instead of the volume when placing an order and by dragging the stop loss from the order entry point you then adjust the volume so that you always risk the amount set as the available risk capital? If precise values are not possible then maybe using a Min Risk and Max Risk range and then a matching volume that match the closest within that range...

This will help a lot with setting Risk and Reward when placing an order.

Thank you!!!

Thanks for your suggestion, it will be taken under consideration. 


@Spotware

Spotware
15 Jul 2014, 09:31

Thank you for your suggestion, we will consider it.


@Spotware

Spotware
14 Jul 2014, 15:09

Please contact your broker. We cannot provide more information.


@Spotware

Spotware
14 Jul 2014, 14:50

Dear Trader,

Please contact your broker for such information.


@Spotware

Spotware
14 Jul 2014, 13:00

RE: RE:

It would be great if BeginInvokeOnMainThread() passes execution instantly to the main thread instead of waiting for the next Timer tick to occur.

BeginInvokeOnMainThread method will execute action instantly if there is no any handler executing by main thread and there is no handlers in the queue. Otherwise it will be put in the queue.


@Spotware

Spotware
14 Jul 2014, 10:31

RE: Avatar uploads

breakermind said:

Hi,
what is wrong with the display and uploads avatars in profil page after login to forum ?

Regards

Do you observe any issue?


@Spotware

Spotware
14 Jul 2014, 10:29

We plan to implement this feature in the future. You can vote for it on vote.spotware.com:

http://vote.spotware.com/forums/229166-ideas-and-suggestions-for-ctrader-and-calgo/suggestions/5502949-custom-parameters


@Spotware

Spotware
14 Jul 2014, 10:24

cAlgo API doesn't contain such methods. We plan to add them in the future.


@Spotware

Spotware
14 Jul 2014, 10:21 ( Updated at: 21 Dec 2023, 09:20 )

Next OnTimer invocation will be scheduled after current OnTimer invocation will be finished. Please have a look at the following example:

Are there any solution to pass "work objects" (Open/Close/Modify position) from arbitrary thread to "main" thread?

You can put code that works with API objects to actions queue and invoke actions from it in OnTimer handler. In such case actions will be invoked in main thread. Example:

using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading;
using cAlgo.API;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MultiThreadexample : Robot
    {
        private readonly ConcurrentQueue<Action> _actionsQueue = new ConcurrentQueue<Action>();

        protected override void OnStart()
        {
            Timer.Start(new TimeSpan(1));//start timer with minimal interval

            var thread = new Thread(SeparateThreadHandler);
            thread.Start();
        }
        
        private void SeparateThreadHandler()
        {
            try
            {
                //perform some actions in separate thread:
                Thread.Sleep(10000);

                //scedule action to be invoked in main thread:
                _actionsQueue.Enqueue(() =>
                    {
                        //the following code will be invoked in main thread:
                        
                        var position = Positions.FirstOrDefault(p => p.TradeType == TradeType.Buy);
                        if (position != null)
                            ModifyPosition(position, Symbol.Bid - 10 * Symbol.PipSize, position.TakeProfit);
                    });
            }
            catch (Exception) 
            {
                //you must always catch exceptions from separate thread
            }
        }

        protected override void OnTimer()
        {
            Action action;
            while (_actionsQueue.TryDequeue(out action))
            {
                action();
            }
        }
    }
}

We plan to add method BeginInvokeOnMainThread in the future. It will simplify the above example.


@Spotware

Spotware
11 Jul 2014, 16:45

RE:

Hi AlexanderRC

1) can I call Timer.Start() from non-main cBot thread?

No, it's not thread safe

2) Can I call Timer.Start with some "zero" value for the Timer to be invoked as soon as possible?

No, it will stop timer instead, otherwise it would mean smth like infinite calls of OnTimer method. In case you want to call OnTimer as soon as possible pass interval equal to one millisecond

        private void ExecuteOnTimerASAP()
        {
            Timer.Start(TimeSpan.FromMilliseconds(1));
        }

        protected override void OnTimer()
        {
            Timer.Stop();
            //your code
        }

 

3) Can I call safely call Timer.Stop() from within OnTimer()?

Yes, you can safely call Stop() in OnTimer()

 

 


@Spotware

Spotware
11 Jul 2014, 11:55

You can shift the index:

        protected override void OnTick()
        {
            var index = MarketSeries.Close.Count - 1;
            var shift = 2;
            var shiftedValue = atr.Result[index - shift];
        }

 


@Spotware

Spotware
11 Jul 2014, 09:21

Please make sure that WP indicator writes data to the corresponding indexes. In order to do that you can add Print statements to WP indicator. Output similar to the following could help you:

...
Result[8543] = 1.2345
Result[8544] = 1.2567

Then you can change Print statement in your top level indicator:

Print("WP[{0}]: {1}", lastIndex, WP.Result[lastIndex]);

 


@Spotware

Spotware
10 Jul 2014, 17:35

No, ChartObjects are not supported on the backtesting chart.


@Spotware