Topics
Replies

firemyst
03 May 2023, 09:12

RE: RE:

acrigney said:

Awesome thanks heaps mate, you have really saved my bacon!! What kind of bots do you build? I build ML ones.

 

 

I'm not sure what you mean by "ML" ones?

I write bots and a few custom indicators that do my trading for me. "Hybrid ones" where I have a basic strategy programmed up with position management, but watch the trades for divergences (and other signs) to manage them myself.

I used to focus on trading the daily time frame, but now stick more to Renko charts (with my own Renko Wicks indicator) to avoid all the noise distracting me or stimulating my emotions.

:-)

 

 


@firemyst

firemyst
03 May 2023, 06:15

> So sorry gus yes it worked with FullAccess using the launch debugger but it does not work with trying to attach, that is the normal way I try and do it with my bots.

> It says symbols have not been loaded. Looks like you have to specify the location of the symbols but I have never had to do that before.

 

Because everything now runs under its own process, you could have literally hundreds of calgo processes running, and wouldn't know which one to attach to.

The new way of debugging automatically handles that for you. When prompted, select the VS instance you're currently working in (as per the instructions on the web page) making sure you're running it in "debug" mode, and you'll be able to step through the code as per usual.


@firemyst

firemyst
03 May 2023, 05:08

RE: RE:

acrigney said:

Thanks mate, the debugger is not launched but the code says it was.

Also when I try and attach it says that no symbols have been loaded for the current document. 

As I said I have been doing this for years but ever since the upgrade to support .net 6 it has never worked.

Here is some sample code.

 

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

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class DummyBot6 : Robot
    {
        [Parameter(DefaultValue = "Hello world!")]
        public string Message { get; set; }

        [Parameter(DefaultValue = "Hello world!")]
        public string Message2 { get; set; }

        protected override void OnStart()
        {
            var result = System.Diagnostics.Debugger.Launch();

            if (result is false)
            {
                Print("Debugger launch failed");
            }
            else if (result is true)
            {
                Print("Debugger launched");
            }

            // To learn more about cTrader Automate visit our Help Center:
            // https://help.ctrader.com/ctrader-automate

            Print(Message);
            Print("onstart");
        }

        protected override void OnTick()
        {
            // Handle price updates here
        }
        
        protected override void OnBar()
        {
            double x = 0, y = 0, z = 0,p =0;
            Print("AddClose");
            for (int j = 0; j < 3; j++)
            {
                x = (float)Bars.ClosePrices.Last(j + 1);
                y = (float)Bars.OpenPrices.Last(j + 1);
                z = (float)Bars.HighPrices.Last(j + 1);
                p = (float)Bars.LowPrices.Last(j + 1);
            }
            Print(String.Format("lengths {0} {1} {2} {3}", x, y, z, p));


           

        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}

PanagiotisChar said:

 

Hi there,

There are clear instructions here

Which step does not work for you?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

 

 

You need to follow the instructions. Your code clearly shows you haven't:

 


@firemyst

firemyst
02 May 2023, 04:12

I like a lot of your suggestions. However, given the limited screen size of phones, I suppose to what end are the majority of traders using mobile vs a laptop/desktop for their primary trading operations?

For instance, I'm curious why you think it's "high priority" to manage cbots through the mobile app itself? Since cBots run on the specific computer they are installed on, your mobile device would have to connect back to that computer (through cTrader) and be able to take control of the cbot on that computer. And there would be a lag doing so. Basically, it would be just as efficient right now to install Microsoft's "remote desktop" application on your mobile device, "remote desktop" back to your computer with the cBot installed, and control it remotely that way. That's what I do anyway -- to connect to my VPS where I have cBots running.

 


@firemyst

firemyst
01 May 2023, 02:38

So have you looked in the "logging" tab to see what errors (if any) are displayed?


@firemyst

firemyst
30 Apr 2023, 11:33

Are you using Visual Studio?

If so, are these NuGet packages that can be updated?

Are they DLLs that come from elsewhere that you do not have the source code to?

 

You need to provide more information


@firemyst

firemyst
28 Apr 2023, 17:26

RE: RE:

acrigney said:

Yes mate my boss have FullAccess but still no luck with any of the recent versions including the latest my broker TopDx has which is 4.6.6

Can you post a video showing creating and debugging a bot please?

 

Ever try doing a Google or YouTube search?

 


@firemyst

firemyst
28 Apr 2023, 15:36

And vote this thread too:

 


@firemyst

firemyst
28 Apr 2023, 15:35

RE:

ctid6027093 said:

Implement Renko wicks or if possible the full Renko range. I know there is an indicator that draw the wicks, but its using a lot of recources.

Having a full Renko implementation would give the platform a leap forward.

Regards

Would have been nice if you looked through the suggestions first instead of creating another thread to divide up the votes:

 

 

Vote in the above thread as well.


@firemyst

firemyst
27 Apr 2023, 16:10

RE:

jane.ttabloomquist said:

Hi, 

Many of the developers are waiting for encryption possibilities of code in cAlgo. This will open a broad marketplace for developers to monitize on their hard work. It will also bring new coders interesting in the platform. My question is, is this in progress? If so, when do you think it might be available.

cAlgo files are supposedly already encrypted - I doubt we'd get different types of "encryption" options though.

If you mean you want the code obfuscated, you can do that outside of cTrader before compiling.


@firemyst

firemyst
27 Apr 2023, 04:56

One thing to try that's happened to me in the past, is:

  1. put some indicators on the chart (a moving average, bollinger bands, etc) Just use the default settings
  2. try putting a horizontal and/or vertical line drawing on your chart as well
  3. scroll your chart. Change timeframe and scroll the chart again.

if you scroll your chart and the indicators  / lines do not move, then it's a bug with the Intel GPU drivers. This is known and has happened to me in the past. Update the Intel GPU drivers, restart cTrader, and hopefully it'll go away (as it did for me).

 

The other time something similar happened to me is when Windows automatically updated my computer in the background, and it was waiting for a pending restart. Once I restarted, it worked fine. So maybe check that as well.

 

If neither of these suit you, hopefully @Spotware can lend some insight. Great that you posted the video.

 


@firemyst

firemyst
27 Apr 2023, 04:49

Sample code snippets to get the size of the previous candle:

private Bars bars;

// In your OnStart or Initialize method depending on whether cBot or indicator
bars = MarketData.GetBars(Chart.TimeFrame);


//In the Calculate, OnTick, or OnBar method depending on whether indicator or cBot and when you want to know the difference
//If you want the body size
double differenceInPips = Math.Abs(bars.OpenPrices.Last(1) - bars.ClosePrices.Last(1)) / Symbol.PipSize;

//If you want the entire candle. No Math.Abs function needed
double differenceInPips = (bars.HighPrices.Last(1) - bars.LowPrices.Last(1)) / Symbol.PipSize;

 

 

Check out code samples to see how to place the order you want:
https://help.ctrader.com/ctrader-automate/cbot-code-samples/

 


@firemyst

firemyst
26 Apr 2023, 03:41 ( Updated at: 21 Dec 2023, 09:23 )

I'm not sure why you think this is an issue?

If you look on topfx website, they don't have USDHKD listed as a currency pair they allow users to trade, so that error is expected:

 

 

If you want to trade USDHKD, it looks like you'll have to change brokers, or ask them if they can enable it for you.

Good luck.


@firemyst

firemyst
25 Apr 2023, 15:16

You may need to check if the SL or TP value is null along with changing the order of comparisons in the "if" statements.

 

if (distance >= BETrigger * Symbol.PipSize)
                {
                    if (position.TradeType == TradeType.Buy)
                    {
                        //you need to check if StopLoss is null first because if it is null, the position.Stoploss <= ... 
			//will fail because it can't compare a null against an actual value
                        if (position.StopLoss == null || position.StopLoss <= position.EntryPrice + (Symbol.PipSize * BEExtraPips))
                        {
                          //I personally would also change this call to the following 
                          //so you're covered with the TakeProfit as well                           
                          ModifyPosition(position, position.EntryPrice + (Symbol.PipSize * BEExtraPips), (position.TakeProfit == null ? null : position.TakeProfit.GetValueOrDefault()));
                        }
                    }
                    else
                    {
                        if (position.StopLoss == null || position.StopLoss >= position.EntryPrice - (Symbol.PipSize * BEExtraPips))
                        {  
                          ModifyPosition(position, entryPrice - (Symbol.PipSize * BEExtraPips), (position.TakeProfit == null ? null : position.TakeProfit.GetValueOrDefault()));
                        }
                    }
                }
            }
        }
        
    }
}

 


@firemyst

firemyst
25 Apr 2023, 09:30

Try cleaning cTrader's cache.

 

See the last post in this thread on how to do it:

 


@firemyst

firemyst
25 Apr 2023, 09:28

Why should they keep running?

 

cTrader is the 'host' running your bots.

 

If you shut down Microsoft Windows, does cTrader keep running?

If you shut down Microsoft Windows, do any of your open Windows applications (Microsoft Word, Google Chrome, etc) keep running?

No. Because Windows is the 'host' that's running them.

 

 

 

 

 


@firemyst

firemyst
25 Apr 2023, 09:22

RE:

alfonsojjg said:

Hi,

I want to calculate the number of positios opened in both directions, longs and shorts, anyone khows how to code it?

Thanks.

 

 


@firemyst

firemyst
25 Apr 2023, 09:20

When you do this:

valor = sma.Result.Last(0);

it calls the Calculate method in the indicator.

You have a print statement in that method in your indicator.


@firemyst

firemyst
23 Apr 2023, 06:56

The error message is what's wrong.

You need to add a reference to System.Management.dll to your Indicator project.

https://ctrader.com/api/guides/referencing_dll#:~:text=In%20order%20to%20add%20a,your%20cBot%20or%20Custom%20Indicator.

 

 

 

 

 


@firemyst

firemyst
22 Apr 2023, 09:50 ( Updated at: 21 Dec 2023, 09:23 )

Step 1 - Search forums:

 

Step 2, click result:

 

Step 3: implement solution as appropriate for what you want to do

 

:-)

 


@firemyst