Replies

therealnakedtrader
09 Sep 2019, 12:57

RE:

Panagiotis Charalampous said:

Hi therealnakedtrader,

There is no such option at the moment.

Best Regards,

Panagiotis

No worries, Panagiotis. Thanks for letting me know. 

Cheers. 

 


@therealnakedtrader

therealnakedtrader
29 Aug 2019, 16:12

RE:

Panagiotis Charalampous said:

Hi therealnakedtrader,

I would suggest i. Point iii can help a bit but I din't know how much and eventually you will end up at the same situation.

Best Regards,

Panagiotis

Fair enough. I'll give it a go and hopefully that should put an end to the dramas I've been witnessing on my PC. :) 

Thanks for your help, Panagiotis. Have a nice day. 


@therealnakedtrader

therealnakedtrader
29 Aug 2019, 15:47

RE:

Panagiotis Charalampous said:

Hi therealnakedtrader,

After investigating your issue further, the performance degradation is caused by a huge number of objects being drawn on your charts (in some charts up to 1732 items). Please delete the excessive amount of objects and let us know if this resolves the problem.

Best Regards,

Panagiotis

Thanks for investigating, Panagiotis. I do have a huge number of objects in some of my charts. Looks like I have two or three options. 

i) Start with fresh charts and that takes care of housekeeping. It will require too much effort and time to clean up existing charts.

ii) Create an algo to clean up chart objects that I no longer need (lots of time and effort required to code algo). 

iii) Upgrade PC to replace my ageing PC. Current system has an i7-4770 processor with 16GB RAM. Will it help when I upgrade to a more powerful i9 9900K PC with 64GB RAM? 

Thanks again, Panagiotis. 


@therealnakedtrader

therealnakedtrader
28 Aug 2019, 15:35

RE:

Panagiotis Charalampous said:

Hi therealnakedtrader,

Try clicking on a chart and then press Ctrl+Alt+Shifh+T

Best Regards,

Panagiotis

OK... restarting seems to have fixed the issue partly. Now, I am connected to Sydney-2. Able to do the Ctrl+Alt+Shift+T combo and send info. Will email setting file shortly. 

Cheers. 


@therealnakedtrader

therealnakedtrader
28 Aug 2019, 15:27

RE:

Panagiotis Charalampous said:

Hi therealnakedtrader,

To investigate further please send us the following

1) Troubleshooting information. Press Ctrl+Alt+Shifh+T, paste the link to this discussion into the text box and press submit.

2) Your settings file. You can find it in C:\Users\User\AppData\Roaming\Broker cTrader\Settings. You can send it at community@spotware.com

Best Regards,

Panagiotis

Thanks, Panagiotis. I am able to locate the Settings file. However, pressing Ctrl+Alt+Shift+T produced no link. I made sure cTrader was the active window when I hit they keypad combo. No luck. Any other method to get troubleshooting info? 

 

Note: I tried that combo with my laptop and it works just fine. But then, the issue is relegated to my PC only. 

 


@therealnakedtrader

therealnakedtrader
20 Aug 2019, 17:50

RE:

FireMyst said:

I don't know if there's an API call for it, but you could always try writing the stop loss in an encoded string within the "comment" when the order is placed.

Then parse it from the historical trade info.

For instance, make your encoded string %SL:xx.x% where xx.x is the pips SL.

Then all you need do is parse the string to find it. :-)

Hey FireMyst,

That's indeed a good idea. I do use it when triggering an order. However, Comment field cannot be updated after a trade is in progress and typically, I move the SL depending on the price action after the trade has been placed. So, yeah... I was hoping for some way to access that elusive Stoploss value. Thanks for your help, mate. Very much appreciated. :) 

Cheers!


@therealnakedtrader

therealnakedtrader
30 Jul 2019, 17:08

RE:

Panagiotis Charalampous said:

Hi therealnakedtrader,

Then you can consider this

using System;
using System.Collections.Generic;
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
    {
        Dictionary<Position, double> _positions;

        protected override void OnStart()
        {
            _positions = new Dictionary<Position, double>();
            Positions.Opened += Positions_Opened;
            foreach (var position in Positions)
                _positions.Add(position, 0);
        }

        private void Positions_Opened(PositionOpenedEventArgs obj)
        {
            _positions.Add(obj.Position, 0);
        }

        protected override void OnTick()
        {
            foreach (var position in Positions)
            {
                _positions[position] = Math.Max(_positions[position], position.Pips);
            }            
        }

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

Best Regards,

Panagiotis

Yep! This one worked just right. Thanks heaps, Panagiotis. 


@therealnakedtrader

therealnakedtrader
30 Jul 2019, 16:42

RE:

Panagiotis Charalampous said:

Hi therealnakedtrader,

Try the 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
    {

        double _maxPips;
        protected override void OnStart()
        {
            // Put your initialization logic here
        }

        protected override void OnTick()
        {
            if (Positions.Count > 0)
            {
                _maxPips = Math.Max(_maxPips, Positions.Max(x => x.Pips));
            }
            Print("Max Pips: " + _maxPips);
        }

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

Best Regards,

Panagiotis

Thanks, Panagiotis. This seems to work for all positions as a whole. I am trying to determine the max pips gained by each position. But, I think I can find a way to make this work now. Thanks again. 


@therealnakedtrader

therealnakedtrader
25 Jul 2019, 03:25

BTW, found a solution to this issue. I just separated the print statement from the calculations and it worked just fine. :) Thanks for pointing the issue out, Panagiotis. 

 


@therealnakedtrader

therealnakedtrader
23 Jul 2019, 14:25

RE:

Panagiotis Charalampous said:

Hi therealnakedtrader,

Thanks for posting in our forum. Can you please post the complete cBot code including the statement used to print? It seems that your print function is just concatenating the two values as strings

Best Regards,

Panagiotis

Thank for offering to help out, Panagiotis. 

I am afraid the code is very basic and full of gobbledygook.. but here it is: 

=================================================================================================================

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 StandardTrailing : Robot
    {
        // This bot executes standard trailing with a default 2RR trailing; triggers after pips gained is greater than 2 times Stoploss.
        [Parameter(DefaultValue = "Enter PID")]
        public string sPID { get; set; }
        [Parameter(DefaultValue = 2)]
        public int Reward { get; set; }
        [Parameter(DefaultValue = 10)]
        public int TrailByPercent { get; set; }
        public int[] intPID;
        public string stringPositionList;
        protected override void OnStart()
        {
            string[] tempPID = sPID.Split(',');
            intPID = Array.ConvertAll<string, int>(tempPID, int.Parse);
            foreach (var position in Positions)
            {
                if (position.SymbolName == Chart.SymbolName)
                {
                    stringPositionList = stringPositionList + position.Id + ", ";
                }
            }
            Print("Positions: " + stringPositionList);
        }
        protected override void OnTick()
        {
            foreach (var position in Positions)
            {
                bool exists = intPID.Contains(position.Id);
                //if position ID is not in exclusion list, then trail standard
                // for shorts
                if (!exists && position.TradeType == TradeType.Sell && (position.SymbolName == Chart.SymbolName))
                {
                    double distance = (position.EntryPrice - Symbol.Ask);

                    if (distance >= ((position.StopLoss - position.EntryPrice) * Reward))
                    {
                        var newStopLossPrice = Symbol.Ask + ((double)10 / 100 * distance));
                        Print("newStopLossPrice = Symbol.Ask + ((double)10 / 100 * distance));
                        if (position.StopLoss == null || newStopLossPrice < position.StopLoss)
                        {
                             ModifyPosition(position, newStopLossPrice, position.TakeProfit);
                        }
                    }
                }
                //else if ( /* else if PID matches and position is a long */position.Id == cPID && position.TradeType == TradeType.Buy)
                else if (!exists && position.TradeType == TradeType.Buy)       

/// please ignore code for this 'else if'  -- not 
                {
                    var distance = (Symbol.Bid - position.EntryPrice);
                    //   Print("Distance for " + position.Id + " is: " + distance * Symbol.PipSize);
                    // not coded yet 
                }
            }
        }
        protected override void OnStop()
        {
        }
    }
}

==================================================================================================================


@therealnakedtrader