Replies

Obiriec
20 May 2024, 09:41

RE: Problems with NEW cTrader version 5.0.21

PanagiotisCharalampous said: 

Hi there,

Why don't I find the "Invite" section when I open "Public Settings"?

This will be available only in broker cTrader applications.

Thanks for the reply.

One doubt remains, I use these brokers:
TopFx, ICMarkets
They have not integrated this function into their cTrader and are stuck at version 4.x.xx
I deduce that I am forced to wait for them to also update the platform to version 5.x.xx

Alternatively, could you suggest a Broker that already supports this functionality and, above all, that manages Futures (such as DAX, FTSE MIB, DOW JONES, NASDAQ, etc)

I am very grateful for your reply

 


@Obiriec

Obiriec
25 Mar 2024, 13:59

RE: Add a "Label" and a "Comment" in the Trading Panel code

PanagiotisCharalampous said: 

Hi there,

This happens because you do not acquire the text box value anywhere. See below

            var stopLossPips = GetValueFromInput(StopLossInputKey, 0);            var takeProfitPips = GetValueFromInput(TakeProfitInputKey, 0);            string label = LabelImputKey;            string comment = CommentImputKey;

You acquire the sl and tp from the text boxes but you use the default label and comment.

Best regards,

Panagiotis

Good morning, I certainly misunderstood.

How should I correct the code so that the text that is written in the on-screen panel box is then used to be written in the label or comment when a position is opened?

Now it only works well if the text is written in the parameters window.

I need the insertion to become interactive even when the panel is on the screen, that is, when the cBot is in the start state.

Thank you and I hope I have been able to explain myself better.

Best regard,

Armando


@Obiriec

Obiriec
25 Mar 2024, 13:59

RE: Add a "Label" and a "Comment" in the Trading Panel code

PanagiotisCharalampous said: 

Hi there,

This happens because you do not acquire the text box value anywhere. See below

            var stopLossPips = GetValueFromInput(StopLossInputKey, 0);            var takeProfitPips = GetValueFromInput(TakeProfitInputKey, 0);            string label = LabelImputKey;            string comment = CommentImputKey;

You acquire the sl and tp from the text boxes but you use the default label and comment.

Best regards,

Panagiotis

Good morning, I certainly misunderstood.

How should I correct the code so that the text that is written in the on-screen panel box is then used to be written in the label or comment when a position is opened?

Now it only works well if the text is written in the parameters window.

I need the insertion to become interactive even when the panel is on the screen, that is, when the cBot is in the start state.

Thank you and I hope I have been able to explain myself better.

Best regard,

Armando


@Obiriec

Obiriec
29 Jul 2023, 07:59

Help for use Timer

RE: use multiple timers and events OnTimer ()

PanagiotisCharalampous said: 

Hi tradermatrix,

It depends on what are you trying to achieve. In principle, you can set your timer to a fast interval e.g. one second, and then implement time checks on custom intervals. See an example below

using System;using System.Linq;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;using cAlgo.Indicators;namespace cAlgo.Robots{    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]    public class NewcBot : Robot    {        [Parameter(DefaultValue = 30)]        public int Interval1 { get; set; }        [Parameter(DefaultValue = 50)]        public int Interval2 { get; set; }        DateTime _interval1;        DateTime _interval2;        protected override void OnStart()        {            _interval1 = Server.Time;            _interval2 = Server.Time;            Timer.TimerTick += Timer_TimerTick;            Timer.Start(1);        }        private void Timer_TimerTick()        {            if (_interval1.AddSeconds(Interval1) < Server.Time)            {                Print("Interval 1 Triggered");                _interval1 = Server.Time;            }            if (_interval2.AddSeconds(Interval2) < Server.Time)            {                Print("Interval 2 Triggered");                _interval2 = Server.Time;            }        }        protected override void OnTick()        {            // Put your core logic here        }        protected override void OnStop()        {            // Put your deinitialization logic here        }    }}

Best Regards,

Panagiotis 

Join us on Telegram

Good evening, I have a request similar to this user's post:
I programmed a cBot that works on a single instance of cTrader simultaneously on all 28 Forex pairs.
The cBot is able to recognize if there are "correlated" pairs to avoid having to open multiple operations, for example: if a EURUSD operation is already open, it will no longer open operations on all pairs that contain EUR or USD.
This logic works well but only if there is already an open trade.
When there is no operation open, it happens that, if the opening conditions occur simultaneously, the various instances of the cBot open the first operation and very often the presence of pairs that should not have been opened is seen.
I tried inserting a timer inside the code that sets the seconds of delay depending on the pair it's running on taking the value from a list but unfortunately I can't get the result I want because the timer doesn't make the requested pause but it loops in just one tick.
This must be done "OnBar" every time.
I may have some suggestions or correction of the code that I report in the attachment.

This is a part of code:

…..
 var Loop = 0;

           string AUDCAD = "AUDCAD";
           string AUDCHF = "AUDCHF";
           string AUDJPY = "AUDJPY";
           string AUDNZD = "AUDNZD";
           string AUDUSD = "AUDUSD";
           string CADCHF = "CADCHF";
           string CADJPY = "CADJPY";
           string CHFJPY = "CHFJPY";
           string EURAUD = "EURAUD";
           string EURCAD = "EURCAD";
           string EURCHF = "EURCHF";
           string EURGBP = "EURGBP";
           string EURJPY = "EURJPY";
           string EURNZD = "EURNZD";
           string EURUSD = "EURUSD";
           string GBPAUD = "GBPAUD";
           string GBPCAD = "GBPCAD";
           string GBPCHF = "GBPCHF";
           string GBPJPY = "GBPJPY";
           string GBPNZD = "GBPNZD";
           string GBPUSD = "GBPUSD";
           string NZDCAD = "NZDCAD";
           string NZDCHF = "NZDCHF";
           string NZDJPY = "NZDJPY";
           string NZDUSD = "NZDUSD";
           string USDCAD = "USDCAD";
           string USDCHF = "USDCHF";
           string USDJPY = "USDJPY";

           if (Symbol.Name.Contains(AUDCAD))
           {
               Loop = 7;
           }
           if (Symbol.Name.Contains(AUDCHF))
           {
               Loop = 11;
           }
           if (Symbol.Name.Contains(AUDJPY))
           {
               Loop = 13;
           }
           if (Symbol.Name.Contains(AUDNZD))
           {
               Loop = 17;
           }
           if (Symbol.Name.Contains(AUDUSD))
           {
               Loop = 19;
           }
           if (Symbol.Name.Contains(CADCHF))
           {
               Loop = 23;
           }
           if (Symbol.Name.Contains(CADJPY))
           {
               Loop = 29;
           }
           if (Symbol.Name.Contains(CHFJPY))
           {
               Loop = 31;
           }
           if (Symbol.Name.Contains(EURAUD))
           {
               Loop = 37;
           }
           if (Symbol.Name.Contains(EURCAD))
           {
               Loop = 41;
           }
           if (Symbol.Name.Contains(EURCHF))
           {
               Loop = 43;
           }
           if (Symbol.Name.Contains(EURGBP))
           {
               Loop = 47;
           }
           if (Symbol.Name.Contains(EURJPY))
           {
               Loop = 53;
           }
           if (Symbol.Name.Contains(EURNZD))
           {
               Loop = 59;
           }
           if (Symbol.Name.Contains(EURUSD))
           {
               Loop = 61;
           }
           if (Symbol.Name.Contains(GBPAUD))
           {
               Loop = 67;
           }
           if (Symbol.Name.Contains(GBPCAD))
           {
               Loop = 71;
           }
           if (Symbol.Name.Contains(GBPCHF))
           {
               Loop = 73;
           }
           if (Symbol.Name.Contains(GBPJPY))
           {
               Loop = 79;
           }
           if (Symbol.Name.Contains(GBPNZD))
           {
               Loop = 83;
           }
           if (Symbol.Name.Contains(GBPUSD))
           {
               Loop = 89;
           }
           if (Symbol.Name.Contains(NZDCAD))
           {
               Loop = 97;
           }
           if (Symbol.Name.Contains(NZDCHF))
           {
               Loop = 101;
           }
           if (Symbol.Name.Contains(NZDJPY))
           {
               Loop = 103;
           }
           if (Symbol.Name.Contains(NZDUSD))
           {
               Loop = 107;
           }
           if (Symbol.Name.Contains(USDCAD))
           {
               Loop = 109;
           }
           if (Symbol.Name.Contains(USDCHF))
           {
               Loop = 113;
           }
           if (Symbol.Name.Contains(USDJPY))
           {
               Loop = 127;
           }

           var Account_Positions = Positions.Count;

           Timer.Start(Loop);

           for (int i = 0; i < Loop; i++)
           {
               Print("Loop n.: " + Loop + " >> " + i + "");
           }
           Timer.Stop();

…….

 

Once the cBot has "entered" the Loop, it should remain still for the set time but instead immediately exits and executes the rest of the code.

Surely I made a mistake in setting this part of the code but despite trying to write it in another way, I still can't find the solution!


@Obiriec

Obiriec
28 Jul 2023, 16:00 ( Updated at: 28 Jul 2023, 16:06 )

RE: use multiple timers and events OnTimer ()

PanagiotisCharalampous said: 

Hi tradermatrix,

It depends on what are you trying to achieve. In principle, you can set your timer to a fast interval e.g. one second, and then implement time checks on custom intervals. See an example below

using System;using System.Linq;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;using cAlgo.Indicators;namespace cAlgo.Robots{    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]    public class NewcBot : Robot    {        [Parameter(DefaultValue = 30)]        public int Interval1 { get; set; }        [Parameter(DefaultValue = 50)]        public int Interval2 { get; set; }        DateTime _interval1;        DateTime _interval2;        protected override void OnStart()        {            _interval1 = Server.Time;            _interval2 = Server.Time;            Timer.TimerTick += Timer_TimerTick;            Timer.Start(1);        }        private void Timer_TimerTick()        {            if (_interval1.AddSeconds(Interval1) < Server.Time)            {                Print("Interval 1 Triggered");                _interval1 = Server.Time;            }            if (_interval2.AddSeconds(Interval2) < Server.Time)            {                Print("Interval 2 Triggered");                _interval2 = Server.Time;            }        }        protected override void OnTick()        {            // Put your core logic here        }        protected override void OnStop()        {            // Put your deinitialization logic here        }    }}

Best Regards,

Panagiotis 

Join us on Telegram

Good evening, I have a request similar to this user's post:
I programmed a cBot that works on a single instance of cTrader simultaneously on all 28 Forex pairs.
The cBot is able to recognize if there are "correlated" pairs to avoid having to open multiple operations, for example: if a EURUSD operation is already open, it will no longer open operations on all pairs that contain EUR or USD.
This logic works well but only if there is already an open trade.
When there is no operation open, it happens that, if the opening conditions occur simultaneously, the various instances of the cBot open the first operation and very often the presence of pairs that should not have been opened is seen.
I tried inserting a timer inside the code that sets the seconds of delay depending on the pair it's running on taking the value from a list but unfortunately I can't get the result I want because the timer doesn't make the requested pause but it loops in just one tick.
This must be done "OnBar" every time.
I may have some suggestions or correction of the code that I report in the attachment.

This is a part of code:

…..
 var Loop = 0;

           string AUDCAD = "AUDCAD";
           string AUDCHF = "AUDCHF";
           string AUDJPY = "AUDJPY";
           string AUDNZD = "AUDNZD";
           string AUDUSD = "AUDUSD";
           string CADCHF = "CADCHF";
           string CADJPY = "CADJPY";
           string CHFJPY = "CHFJPY";
           string EURAUD = "EURAUD";
           string EURCAD = "EURCAD";
           string EURCHF = "EURCHF";
           string EURGBP = "EURGBP";
           string EURJPY = "EURJPY";
           string EURNZD = "EURNZD";
           string EURUSD = "EURUSD";
           string GBPAUD = "GBPAUD";
           string GBPCAD = "GBPCAD";
           string GBPCHF = "GBPCHF";
           string GBPJPY = "GBPJPY";
           string GBPNZD = "GBPNZD";
           string GBPUSD = "GBPUSD";
           string NZDCAD = "NZDCAD";
           string NZDCHF = "NZDCHF";
           string NZDJPY = "NZDJPY";
           string NZDUSD = "NZDUSD";
           string USDCAD = "USDCAD";
           string USDCHF = "USDCHF";
           string USDJPY = "USDJPY";

           if (Symbol.Name.Contains(AUDCAD))
           {
               Loop = 7;
           }
           if (Symbol.Name.Contains(AUDCHF))
           {
               Loop = 11;
           }
           if (Symbol.Name.Contains(AUDJPY))
           {
               Loop = 13;
           }
           if (Symbol.Name.Contains(AUDNZD))
           {
               Loop = 17;
           }
           if (Symbol.Name.Contains(AUDUSD))
           {
               Loop = 19;
           }
           if (Symbol.Name.Contains(CADCHF))
           {
               Loop = 23;
           }
           if (Symbol.Name.Contains(CADJPY))
           {
               Loop = 29;
           }
           if (Symbol.Name.Contains(CHFJPY))
           {
               Loop = 31;
           }
           if (Symbol.Name.Contains(EURAUD))
           {
               Loop = 37;
           }
           if (Symbol.Name.Contains(EURCAD))
           {
               Loop = 41;
           }
           if (Symbol.Name.Contains(EURCHF))
           {
               Loop = 43;
           }
           if (Symbol.Name.Contains(EURGBP))
           {
               Loop = 47;
           }
           if (Symbol.Name.Contains(EURJPY))
           {
               Loop = 53;
           }
           if (Symbol.Name.Contains(EURNZD))
           {
               Loop = 59;
           }
           if (Symbol.Name.Contains(EURUSD))
           {
               Loop = 61;
           }
           if (Symbol.Name.Contains(GBPAUD))
           {
               Loop = 67;
           }
           if (Symbol.Name.Contains(GBPCAD))
           {
               Loop = 71;
           }
           if (Symbol.Name.Contains(GBPCHF))
           {
               Loop = 73;
           }
           if (Symbol.Name.Contains(GBPJPY))
           {
               Loop = 79;
           }
           if (Symbol.Name.Contains(GBPNZD))
           {
               Loop = 83;
           }
           if (Symbol.Name.Contains(GBPUSD))
           {
               Loop = 89;
           }
           if (Symbol.Name.Contains(NZDCAD))
           {
               Loop = 97;
           }
           if (Symbol.Name.Contains(NZDCHF))
           {
               Loop = 101;
           }
           if (Symbol.Name.Contains(NZDJPY))
           {
               Loop = 103;
           }
           if (Symbol.Name.Contains(NZDUSD))
           {
               Loop = 107;
           }
           if (Symbol.Name.Contains(USDCAD))
           {
               Loop = 109;
           }
           if (Symbol.Name.Contains(USDCHF))
           {
               Loop = 113;
           }
           if (Symbol.Name.Contains(USDJPY))
           {
               Loop = 127;
           }

           var Account_Positions = Positions.Count;

           Timer.Start(Loop);

           for (int i = 0; i < Loop; i++)
           {
               Print("Loop n.: " + Loop + " >> " + i + "");
           }
           Timer.Stop();

…….

 

Once the cBot has "entered" the Loop, it should remain still for the set time but instead immediately exits and executes the rest of the code.

Surely I made a mistake in setting this part of the code but despite trying to write it in another way, I still can't find the solution!


@Obiriec

Obiriec
13 Jul 2021, 17:52

Great

Good idea!


@Obiriec

Obiriec
13 Feb 2020, 16:26

RE:

ClickAlgo said:

This should not be a problem.

If you would like to use our development service to do this for you just send an email to development@clickalgo.com together with your existing projects source code and a full description of what help you need.

Paul Hayes
Sales & Marketing
Emailcontact@clickalgo.com
Phone: (44) 203 289 6573
Websitehttps://clickalgo.com

Twitter | Facebook | YouTube | Pinterest | LinkedIn

PS: Why not join our instant chat group on Telegram.

Ok, thanks!


@Obiriec

Obiriec
12 Feb 2020, 20:12

RE: Break even with trailing

ClickAlgo said:

You may be over complicating it a bit, try to keep your code simple and not overuse LINQ, you just need:

var positions = this.Positions.FindAll(Label);
double netProfit = positions.Sum(x => x.NetProfit);

if(netProfit >= ProfitTarget)
{
   foreach (var position in positions)
   {
      ClosePosition(position);
   }
}

I have not tested this, but it should work.

Paul Hayes
Sales & Marketing
Emailcontact@clickalgo.com
Phone: (44) 203 289 6573
Websitehttps://clickalgo.com

Good morning, congratulations on your work here on this forum.
I apologize for my poor English, I am using google translator !!

I would like to know if it is possible to modify an existing cBot, which is used to close all positions of a specific currency pair (eg EURUSD) when these have reached a certain "break even" value and make sure that - - if the profit of all the open positions reaches the trigger and goes back, of course they close to reach the break even value --- but --- it would be very convenient if you could make sure that --- if once the trigger is reached, the profit continues to increase, you could move the trigger itself with a trail value, so everything follows the profit and when it comes back, the trail remains still.
A sort of Trailing Stop Loss for Break Even !!

The parameters that must be managed by the user, in addition to those used for managing the values, it should also be possible to enter the "label" (magic number) and the name of the currency pair in question.

I don't know if I'm asking for an impossible thing but I think I asked the right person the question.

Looking forward to your reply,
Yours sincerely.


@Obiriec

Obiriec
12 Feb 2020, 16:56

RE:

admin said:

This is a sample of how to close all profitable position in your account, from a cBot (cAlgo Robot)

 

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

namespace cAlgo.Robots
{
    [Robot]
    public class CloseProfitablePositions : Robot
    {
        protected override void OnStart()
        {
            foreach (var position in Positions)
            {
                if (position.GrossProfit > 0)
                {
                    ClosePosition(position);
                }
            }
        }
    }
}


 

Good morning Panagiotis, congratulations on your work here on this forum.
I apologize for my poor English, I am using google translator !!

I would like to know if it is possible to modify an existing cBot, which is used to close all positions of a specific currency pair (eg EURUSD) when these have reached a certain "break even" value and make sure that - - if the profit of all the open positions reaches the trigger and goes back, of course they close to reach the break even value --- but --- it would be very convenient if you could make sure that --- if once the trigger is reached, the profit continues to increase, you could move the trigger itself with a trail value, so everything follows the profit and when it comes back, the trail remains still.
A sort of Trailing Stop Loss for Break Even !!

The parameters that must be managed by the user, in addition to those used for managing the values, it should also be possible to enter the "label" (magic number) and the name of the currency pair in question.

I don't know if I'm asking for an impossible thing but I think I asked the right person the question.

Looking forward to your reply,
Yours sincerely.
Armando Brecciaroli


@Obiriec