Replies

bachapk
28 Mar 2017, 10:42

RE: RE: RE:

Any updates regarding manually drawn trend line or any object reading issue so far? 

Cheers

Spotware said:

Dear Trader,

Currently you are able to access a value of an Object only if this object is created by ChartObjects methods within the same cBot/indicator. It's in our plans to provide users with the ability to also access Objects on the chart that weren't created by the cBot/indicator in the future. However, we cannot provide you with an ETA. Stay tuned.

Additionally, you can post your ideas/suggestions to http://vote.spotware.com/

cre8iveq said:

I know this is an old thread, but in it someone mentioned that there was a plan to implement this. Did this ever happen?

All I want to be able to do is draw a horizontal line on the chart, and access the value of that line in a bot. Is this possible?

 

 


@bachapk

bachapk
01 Jun 2016, 11:40

RE:

Spotware said:

Dear Trader,

We kindly ask you to follow the steps described above again, precisely and in the exact order.

Thank you. My issue resolved. I uploaded files to Google Drive to shift to another computer. When I downloaded files from google drive, the files were downloaded in a ZIP file and the .cs files were converted into text files in the process. So it was like MyBot.cs.txt. Due to Hide extension property, I was not able to see .txt and hence cAlgo was not able to generate any .algo file as these were practically text files and Not .cs files. I renamed all files by removing .txt from all. And when restarted cAlgo, I was able to see the source code of every cBot.

 

Thanks 


@bachapk

bachapk
31 May 2016, 18:25 ( Updated at: 21 Dec 2023, 09:20 )

Further I deleted all .algo files and only leave .cs files in the Robots folder. Now I can see No ROBOTS!!


@bachapk

bachapk
31 May 2016, 18:20 ( Updated at: 21 Dec 2023, 09:20 )

Nothing is helping. I have done exactly the same procedure:

1. Renamed Robots folder to Robots1

2. Created a new folder with Robots name.

3. Copied all .cs files and .algo files to Robots folder.

4. Restarted cAlgo but still I am getting "Source code not available" message.

5. I can open all .cs files in notepad and the code is correct as shown in this picture.


@bachapk

bachapk
31 May 2016, 17:56 ( Updated at: 21 Dec 2023, 09:20 )

RE:

Spotware said:

Dear Trader,

The old .cs file has to be in the robots folder and not in any subfolder.

C:\Users\%USERNAME%\Documents\cAlgo\sources\robots

 

Thank you. But it didn't work. I copied Alligator_Williams_cBot.cs to main Robots folder. Deleted Alligator_Williams_cBot folder. Restart cAlgo 4 times but still I see the same issue.

 


@bachapk

bachapk
09 Sep 2015, 21:00

RE: RE: RE:

Spotware said:

bachapk said:

Same problem here .. I have a currency strength index indicator which was working good till 26th August 2015. But don't know what went wrong that with 500 history bars calculations the indicator do not loading. As the code is not changed therefore, I am sure something wrong have been done on the cAlgo/cTrader platform side.

Dear bachapk,

We apologize for our late response. We would like to ask you if you still have this issue.

Hi,

With initializing all series for currency pairs involved (around 36 pairs) on OnInit() function and reducing the first time calculations to 200 bars, the problem is solved. But The original version which was working with 500 History bars is still not loading any data. Although it was working perfectly before 25th August 2015. Before 25th Aug it was taking around 40 seconds to first load and calculate data for last 500 history bars but after it the indicator was not loading even after 5 minutes.


@bachapk

bachapk
26 Aug 2015, 23:33

RE:

Paul_Hayes said:

ok, thanks, but could Spotware confirm that custom threading is not safe with indicators or cBots, i will need to know this for future reference as well as calling GetSeries asynchronously.

Many Thanks,

Paul.

Paul : /forum/calgo-support/2347#2


@bachapk

bachapk
26 Aug 2015, 23:21 ( Updated at: 21 Dec 2023, 09:20 )

RE:

Paul_Hayes said:

Hi Guys,

I may be missing something, but why can you not run each GetSeries asynchronous using the Task Parallel Library (TPL)? the entire operation should take no longer than the longest call to get the data series.

But I am sure it is not that simple.

Paul.

 

Thank you. But I don't think GetSeries can be called asynchronously. Also cTrader is not safe for custom threading and can end up with crash. For 200 history bars it is taking around 24 seconds for first time loading and I guess it is acceptable. But the mystery remains as why it stopped working since yesterday with 500 history bars calculations. I am using cAlgo v 1.30.58489


@bachapk

bachapk
26 Aug 2015, 22:30

RE:

Same problem here .. I have a currency strength index indicator which was working good till 26th August 2015. But don't know what went wrong that with 500 history bars calculations the indicator do not loading. As the code is not changed therefore, I am sure something wrong have been done on the cAlgo/cTrader platform side.


@bachapk

bachapk
04 Feb 2015, 20:45

RE:

Any Updates about adding Double Position via cAlgo? as it is now 2015. I guess it can be done easily with re-configuring ModifyPosition function by adding Volume parameters.

Spotware said:

No it is not possible to double the volume right now. We will let you know when it will be implemented.

 


@bachapk

bachapk
01 Jan 2015, 04:00

RE:

bachapk said:

 

 

Change

[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]

to

[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]

 


@bachapk

bachapk
01 Jan 2015, 03:56

Change

[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]

to

[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, , AccessRights = AccessRights.FullAccess)]


@bachapk

bachapk
25 Dec 2014, 04:26

Thank you . I also support this request to add functionality of reading trend line value of a specific bar. For a reference it is already implemented in mt4 (http://docs.mql4.com/objects/objectgetvaluebyshift)


@bachapk

bachapk
25 Dec 2014, 04:07

RE:

Spotware said:

No, but we plan to implement such functionality in the future.

In mt4 there is a function of ObjectGetValueByShift which can get the value of object by the bar shift value. It will be highly appreciated if such functionality been provided in cAlgo please.

Bacha


@bachapk

bachapk
25 Dec 2014, 03:17

RE:

Hi

Can we get index-10th bar value of Upper line in this example? If yes then how? As I didn't see any example of how to retrieve value from a line specially trend line.

Looking forward

Regards

Bacha

cAlgo_Development said:

Indicator drawing trend-lines automatically using specified period (minimum distance between high and low extremums):

 

Source code:

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true)]
    public class TrendLines : Indicator
    {
    	[Parameter(DefaultValue = 30, MinValue = 1)]
        public int Period { get; set; }	
    
        protected override void Initialize()
        {
            RedrawLines();
        }
    
        public override void Calculate(int index)
        {
            if (IsRealTime)
                RedrawLines();
        }
        
        private void RedrawLines()
        {
            int count = MarketSeries.Close.Count;
        
            int maxIndex1 = FindNextLocalExtremum(MarketSeries.High, count - 1, true);
            int maxIndex2 = FindNextLocalExtremum(MarketSeries.High, maxIndex1 - Period, true);
        	
            int minIndex1 = FindNextLocalExtremum(MarketSeries.Low, count - 1, false);
            int minIndex2 = FindNextLocalExtremum(MarketSeries.Low, minIndex1 - Period, false);
            
            int startIndex = Math.Min(maxIndex2, minIndex2) - 100;
            int endIndex = count + 100;
            
            DrawTrendLine("high", startIndex, endIndex, maxIndex1, MarketSeries.High[maxIndex1], 
                maxIndex2, MarketSeries.High[maxIndex2]);

            DrawTrendLine("low", startIndex, endIndex, minIndex1, MarketSeries.Low[minIndex1], 
                minIndex2, MarketSeries.Low[minIndex2]);
        }
        
        private void DrawTrendLine(string lineName, int startIndex, 
            int endIndex, int index1, double value1, int index2, double value2)
        {
            double gradient = (value2 - value1) / (index2 - index1);
            
            double startValue = value1 + (startIndex - index1) * gradient;
            double endValue = value1 + (endIndex - index1) * gradient;
            
            ChartObjects.DrawLine(lineName, startIndex, startValue, endIndex, endValue, Colors.Gray);
            ChartObjects.DrawLine(lineName+"_red", index1, value1, index2, value2, Colors.Red);
        }
        
        private int FindNextLocalExtremum(DataSeries series, int maxIndex, bool findMax)
        {
            for (int index = maxIndex; index >= 0; index --)
            {
                if (IsLocalExtremum(series, index, findMax))
                {
                    return index;
                }
            }
            return 0;
        }
        
        private bool IsLocalExtremum(DataSeries series, int index, bool findMax)
        {	
        	int end = Math.Min(index + Period, series.Count - 1);
        	int start = Math.Max(index - Period, 0);
        	
        	double value = series[index];
        
        	for (int i = start; i < end; i++)
        	{
        		if (findMax && value < series[i])
        			return false;
        			
    			if (!findMax && value > series[i])
        			return false;
        	}
        	return true;
        }
    }
}

 


@bachapk

bachapk
05 Aug 2014, 15:40 ( Updated at: 21 Dec 2023, 09:20 )

Execution Delay examples

Here are couple of examples:

And

Also please note that my other account trade was sent on exactly the same time and executed within 200 ms.


@bachapk

bachapk
05 Aug 2014, 15:25

RE:

Spotware said:

Execution time depends on liquidity providers connected to the broker.
In order to get information on execution delays on the LP side, you need to contact your broker.

I am sorry but this is not the solution. People are moving towards cTrader (including me and my team) with the fact that broker will not be able to play with us like they did/does using mt4, since you are hosting cTrader servers yourself. I can give you following example:

I have 2 accounts with a broker. Both of them installed on same type of vps (4gb ram) in LD5 with latency to proxy = 1.2 and server=2 ms. Trades executed on both account. One was with slippage and delay (3 seconds). The other one was with no delay (250 ms). I still believe that broker can still play with you even in cTrader environment. If you have any doubts then I will send you both journals and trade history via email.

Please try to make changes in your architecture so that broker cannot play with trader on the LP side as I believe they can still install some crap stuff on LP side for different traders. Please take notice of it .. I have proofs and I can provide it


@bachapk

bachapk
24 Jun 2014, 17:30 ( Updated at: 21 Dec 2023, 09:20 )

Ping

Below is ping latency from VPS to Proxy server and Server:


@bachapk

bachapk
24 Jun 2014, 16:12

RE:

Spotware said:

Regarding to our logs execution time of that order was 277 ms. Probably 15 seconds was random network or VPS delay. Can you reproduce this issue?

Thank you for your prompt response.

1:

2014.06.24 08:48:57.170 | Request to Buy 302k EURGBP is sent to server
2014.06.24 08:48:57.592 | → Request to Buy 302k EURGBP is ACCEPTED, order OID905749 created (24/06/2014 08:48:57.182 UTC+0)
2014.06.24 08:48:59.420 | → Order OID905749 is FILLED at 0.80117, position PID615359 (24/06/2014 08:48:57.489 UTC+0)

2:

2014.06.24 08:57:01.984 | Request to Buy 310k GBPUSD is sent to server
2014.06.24 08:57:03.622 | → Request to Buy 310k GBPUSD is ACCEPTED, order OID906817 created (24/06/2014 08:57:02.524 UTC+0)
2014.06.24 08:57:03.662 | → Order OID906817 is REJECTED with error "INVALID_REQUEST"

3:

2014.06.24 08:57:23.959 | Request to Buy 316k GBPUSD is sent to server
2014.06.24 08:57:29.037 | → Request to Buy 316k GBPUSD is ACCEPTED, order OID906868 created (24/06/2014 08:57:24.503 UTC+0)
2014.06.24 08:57:29.101 | → Order OID906868 is FILLED at 1.69857, position PID616471 (24/06/2014 08:57:24.712 UTC+0)

 

Apart from this I am getting number of errors mainly "technical errors" and "disconnected errors". OnError() function is void so there can be any mechanism to protect robot not try to modify, place or close any position? As there are many options in MT4 like (IsConnected(), IsTradeContextBusy(), IsTradeAllowed() etc) which protect robot to try for taking any trading action.

I tried such in cTrader which is as below:

       int RobotError;
        //+------------------------------------------------------------------+
        //| OnTick: function run on every new Tick                           |
        //+------------------------------------------------------------------+
        protected override void OnTick()
        {
            if (HandleErrors())
                return;
            else {
            // do bla bla bla
            }
         }

        //+------------------------------------------------------------------+
        //|                                                                  |
        //+------------------------------------------------------------------+
        private bool HandleErrors()
        {
            if (RobotError > 0)
            {
                RobotError = 0;
                return (true);
            }
            return (false);
        }
        //+------------------------------------------------------------------+
        //|                                                                  |
        //+------------------------------------------------------------------+
        protected override void OnError(Error error)
        {
            //  Print the error to the log
            switch (error.Code)
            {
                case ErrorCode.BadVolume:
                    RobotError = 1;
                    break;
                case ErrorCode.TechnicalError:
                    RobotError = 2;
                    break;
                case ErrorCode.NoMoney:
                    RobotError = 3;
                    break;
                case ErrorCode.Disconnected:
                    RobotError = 4;
                    break;
                case ErrorCode.MarketClosed:
                    RobotError = 5;
                    break;
            }
        }

Also I am applying HandleErrors() check on every trading function. But want to know if this can be more polished so that our robot don't try for any trading action in case of error? Also I am still concern about the execution speed difference between cAlgo and cTrader via Robot. If I try same robot in cAlgo then it can work better?

Thank you


@bachapk

bachapk
24 Jun 2014, 13:09

I am wondering how it is even possible. I am using pepperstone demo cTrader and here is my log files for execution a trade:

24/06/2014 08:46:35.462 | Request to Sell 300k GBPUSD is sent to server
24/06/2014 08:46:44.290 | → Request to Sell 300k GBPUSD is ACCEPTED, order OID905415 created (24/06/2014 08:46:35.808 UTC+0)
24/06/2014 08:46:50.399 | → Order OID905415 is FILLED at 1.70085, position PID615032 (24/06/2014 08:46:36.080 UTC+0)


Here is the Bot Log:

24/06/2014 08:46:35.071 | Swabi_1, GBPUSD, m1 | Executing Market Order to Sell 300k GBPUSD
24/06/2014 08:46:50.649 | Swabi_1, GBPUSD, m1 | ? Executing Market Order to Sell 300k GBPUSD SUCCEEDED, Position PID615032
 

15 seconds execution time? This is crazy!!

Please note that my VPS is in London. And here what is written on spotware website:

"If the VPS is located in London it will have low latency. If you are not using cAlgo to execute high-frequency strategies, and as long as you have chosen a provider from the list below, the location of your VPS data-center will not affect your trades."

 

Also can you please guide robot runs well in cAlgo or cTrader? .. or both have same performance?

Cheeers

Bacha


@bachapk