PanagiotisCharalampous's avatar
PanagiotisCharalampous
26 follower(s) 0 following 1006 subscription(s)
Replies

PanagiotisCharalampous
26 Jun 2024, 06:48 ( Updated at: 26 Jun 2024, 06:50 )

RE: RE: RE: RE: Non -executing the OnDestroy() function

AlgoCreators said: 

Spotware said: 

AlgoCreators said: 

PanagiotisCharalampous said: 

Hi there,

I don't think this was ever working. When the indicator is unloaded and destroyed, all references created by the indicator will do as well, same for the indicator's log. If you want to check this, write in an external file.

Best regards,

Panagiotis

Ok, now there is no way for the indicator to clear the interactive objects it created when it is deleted.

I am not sure what you mean, can you elaborate?

When my indicator is on the chart. Adds objects to the chart, such as rectangles and trend lines
These objects are interactive.
"IsInteractive = true;"
When I remove the indicator from the chart, those objects remain in the chart! If their interactive feature is false, they will be deleted automatically, but as I said, I will turn on their interactive feature.
I want to delete all the objects added to the chart when the indicator is deleted

Hi there,

Can you share the code you are using to delete the objects so that we can check?

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Jun 2024, 06:44

RE: RE: RE: Custom indicator in cBot different results visual mode compared to silent mode

bernhardCM said: 

No that is not what I said. Indicators referenced in a strategy will use the source set in the backtesting settings. Indicators applied on the chart will be rendered at the moment they are applied, so all past bars will be considered historical

first of all, Panagiotis thanks for your great replies to actually all threads I found in this forum already, as well to this one.

Just to make it sure in my own (not native English speaking … poorer) words ;-)

  1. with “strategy” I guess you mean a cBot.
  2. backtesting settings & optimization settings (e.g. ticks instead of chart timeframe data) will be correct processed, in the backend of backtesting & optimization
  3. point 2. is also applicable for indicators on the chart shown on backtesting in visual mode
  4. all other indicators (chart in trade section or chart in backtesting in NON visual mode) will show historically only chart timeframe data, for “IsLastBar” it will be also consider ticks

That's what I extracted as summary and it's no open question, except I wrote something wrong.

Thanks for all and have a nice weekend!

Hi there,

Yes correct.


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 10:43

Hi there,

There is no built in feature for this. Try the tool below

https://ctrader.com/algos/indicators/show/3015

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 10:36

RE: RE: RE: RE: RE: History tab not showing previous trades

Rx1ooo said: 

Spotware said: 

Rx1ooo said: 

herve.limousy said: 

 

I have the same issue with cTrader Desktop 5.0.25. There's only been one trade in the history for the past few days. It seems to be showing current day's trades correctly. However, I have the entire history on cTrader for Android.  Demo account with FxPro: 10580044.

PanagiotisCharalampous said: 

Hi there,

Can you take full screenshots so that we can see the account number, broker and cTrader version?

Best regards,

Panagiotis

Evening,

The cTrader desktop version 4.8.34 and the broker is Pepperstone Aus, I am not willing to share my account number. I do appreciate any help you can give.

The history is appearing today it has done this before and disappearing the next day, I am wondering if a clean install would help. today's history shot

Many thanks :)

Hi there,

Does this happen in cTrader v5.0?

Best regards,

Many thanks,

I have not tried V5.0 version only version 4.8.34.

If you recommend I will give it a try and upgrade to V5.

The history came back yesterday is is also ok today, I restart the platform once a day.

One question where is the history stored local machine or broker ?

Appreciate your support.

:)

 

The history is on the server, let us know if this still happens on v5.0


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 10:35

RE: RE: RE: My ctrader freeze when i'm using my cbot

karldawson99 said: 

PanagiotisCharalampous said: 

scottylace said: 

Freezing issue still remains 😢

Hi there,

The issue has not been resolved yet.

Best regards,

Panagiotis

I am experiencing the same issue. CTrader freezes within a couple of minutes of commencing a backtest, every time. It is currently unusable for me until this is resolved. Using version 5.0.25. Can we roll back to a previous version?

Your broker should have an older version of cTrader


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 10:34

RE: Custom indicator in cBot different results visual mode compared to silent mode

bernhardCM said: 

thanks for your prompt reply.

hmmm, so for backtesting in non visual mode, the setting “tick-data” (instead of m1 data) will not be used, that was not clear to me and looks frankly spoken … wrong ;-) 

but now I know how it works. Thank you for clarification!

By the way, how about Optimization, there we can also select "tick-data accurate”. Are the indicators there also only calculated once per bar? Because there is no visual mode available.

Thank you.

 

No that is not what I said. Indicators referenced in a strategy will use the source set in the backtesting settings. Indicators applied on the chart will be rendered at the moment they are applied, so all past bars will be considered historical


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 08:54

Hi there,

Thank you, we have managed to reproduce the problem and we will fix it in an upcoming update.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 05:53

Hi there,

If this was not a temporary issue, let's arrange a TeamViewer session to inspect this further.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 05:52

Hi there,

Please share the actual code so that we can reproduce what you are looking at.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 05:50

Hi there,

I am not sure what the problem is but if you subscribe to market data using 35=V, then you will receive 35=W and 35=X responses, which are real market data.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 05:43

Hi there,

Can you be more specific regarding your issue? What exactly is not working?

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 05:40

RE: c bot sample advanced take profit

hanselkate said: 

hello can I get the script for sample advanced take profit

 

I dont know what I did it just stop playing thank you hanselkate@outlook.com

Hi there,

Here it is

// -------------------------------------------------------------------------------------------------
//
//    This code is a cTrader Automate API example.
//
//    This cBot is intended to be used as a sample and does not guarantee any particular outcome or
//    profit of any kind. Use it at your own risk.
//    
//    All changes to this file might be lost on the next application update.
//    If you are going to modify this file please make a copy using the "Duplicate" command.
//
// -------------------------------------------------------------------------------------------------

using System;
using System.Linq;
using cAlgo.API;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SampleAdvancedTakeProfit : Robot
    {
        private const string DefaultPositionIdParameterValue = "PID";

        [Parameter("Position Id", Group = "Position", DefaultValue = DefaultPositionIdParameterValue)]
        public string PositionId { get; set; }

        [Parameter("Enabled", Group = "Take Profit 1", DefaultValue = false)]
        public bool TakeProfit1Enabled { get; set; }

        [Parameter("Pips", Group = "Take Profit 1", DefaultValue = 10)]
        public double TakeProfit1Pips { get; set; }

        [Parameter("Volume", Group = "Take Profit 1", DefaultValue = 1000)]
        public int TakeProfit1Volume { get; set; }

        [Parameter("Enabled", Group = "Take Profit 2", DefaultValue = false)]
        public bool TakeProfit2Enabled { get; set; }

        [Parameter("Pips", Group = "Take Profit 2", DefaultValue = 20)]
        public double TakeProfit2Pips { get; set; }

        [Parameter("Volume", Group = "Take Profit 2", DefaultValue = 2000)]
        public int TakeProfit2Volume { get; set; }

        [Parameter("Enabled", Group = "Take Profit 3", DefaultValue = false)]
        public bool TakeProfit3Enabled { get; set; }

        [Parameter("Pips", Group = "Take Profit 3", DefaultValue = 10)]
        public double TakeProfit3Pips { get; set; }

        [Parameter("Volume", Group = "Take Profit 3", DefaultValue = 3000)]
        public int TakeProfit3Volume { get; set; }

        private TakeProfitLevel[] _levels;

        private SymbolInfo _symbolInfo;

        protected override void OnStart()
        {
            if (PositionId == DefaultPositionIdParameterValue)
                PrintErrorAndStop("You have to specify \"Position Id\" in cBot Parameters");

            var position = FindPositionOrStop();
            _symbolInfo = Symbols.GetSymbolInfo(position.SymbolName);
            _levels = GetTakeProfitLevels();

            ValidateLevels(position);
        }

        private void ValidateLevels(Position position)
        {
            MakeSureAnyLevelEnabled();
            ValidateTotalVolume(position);
            ValidateReachedLevels(position);
            ValidateVolumes();
        }

        private void ValidateVolumes()
        {
            var enabledLevels = _levels.Where(level => level.IsEnabled);
            foreach (var level in enabledLevels)
            {
                if (level.Volume < _symbolInfo.VolumeInUnitsMin)
                    PrintErrorAndStop("Volume for " + _symbolInfo.Name + " cannot be less than " + _symbolInfo.VolumeInUnitsMin);
                if (level.Volume > _symbolInfo.VolumeInUnitsMax)
                    PrintErrorAndStop("Volume for " + _symbolInfo.Name + " cannot be greater than " + _symbolInfo.VolumeInUnitsMax);
                if (level.Volume % _symbolInfo.VolumeInUnitsMin != 0)
                    PrintErrorAndStop("Volume " + level.Volume + " is invalid");
            }
        }

        private void ValidateReachedLevels(Position position)
        {
            var reachedLevel = _levels.FirstOrDefault(l => l.Pips <= position.Pips);
            if (reachedLevel != null)
                PrintErrorAndStop("Level " + reachedLevel.Name + " is already reached. The amount of Pips must be more than the amount of Pips that the Position is already gaining");
        }

        private void MakeSureAnyLevelEnabled()
        {
            if (_levels.All(level => !level.IsEnabled))
                PrintErrorAndStop("You have to enable at least one \"Take Profit\" in cBot Parameters");
        }

        private void ValidateTotalVolume(Position position)
        {
            var totalVolume = _levels.Where(level => level.IsEnabled).Sum(level => level.Volume);

            if (totalVolume > position.VolumeInUnits)
                PrintErrorAndStop("The sum of all Take Profit respective volumes cannot be larger than the Position's volume");
        }

        private TakeProfitLevel[] GetTakeProfitLevels()
        {
            return new[] 
            {
                new TakeProfitLevel("Take Profit 1", TakeProfit1Enabled, TakeProfit1Pips, TakeProfit1Volume),
                new TakeProfitLevel("Take Profit 2", TakeProfit2Enabled, TakeProfit2Pips, TakeProfit2Volume),
                new TakeProfitLevel("Take Profit 3", TakeProfit3Enabled, TakeProfit3Pips, TakeProfit3Volume)
            };
        }

        private Position FindPositionOrStop()
        {
            var position = Positions.FirstOrDefault(p => "PID" + p.Id == PositionId || p.Id.ToString() == PositionId);
            if (position == null)
                PrintErrorAndStop("Position with Id = " + PositionId + " doesn't exist");

            return position;
        }

        private void PrintErrorAndStop(string errorMessage)
        {
            Print(errorMessage);
            Stop();

            throw new Exception(errorMessage);
        }

        protected override void OnTick()
        {
            var position = FindPositionOrStop();
            var reachedLevels = _levels.Where(level => level.IsEnabled && !level.IsTriggered && level.Pips <= position.Pips);

            foreach (var reachedLevel in reachedLevels)
            {
                reachedLevel.MarkAsTriggered();

                Print("Level \"" + reachedLevel.Name + "\" is reached. Level.Pips: " + reachedLevel.Pips + ", Position.Pips: " + position.Pips + ", Position.Id: " + position.Id);
                var volumeToClose = Math.Min(reachedLevel.Volume, position.VolumeInUnits);
                ClosePosition(position, volumeToClose);

                if (!LastResult.IsSuccessful)
                    Print("Cannot close position, Id: " + position.Id + ", Error: " + LastResult.Error);

                var remainingLevels = _levels.Where(level => level.IsEnabled && !level.IsTriggered);
                if (!remainingLevels.Any())
                {
                    Print("All levels were reached. cBot is stopping...");
                    Stop();
                    return;
                }
            }
        }
    }

    internal class TakeProfitLevel
    {
        public TakeProfitLevel(string name, bool isEnabled, double pips, int volume)
        {
            Name = name;
            IsEnabled = isEnabled;
            Pips = pips;
            Volume = volume;
        }

        public string Name { get; private set; }

        public bool IsEnabled { get; private set; }

        public double Pips { get; private set; }

        public int Volume { get; private set; }

        public bool IsTriggered { get; private set; }

        public void MarkAsTriggered()
        {
            IsTriggered = true;
        }
    }
}

@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 05:38

Hi there,

Please contact your broker for instructions on how to access your account.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 05:35

Hi there,

The bug is in your code. The difference between visual and non visual is that in visual mode, the indicator is calculated on every tick, while in non visual mode, the indicator is calculated once at the end of the backtesting. So in visual mode, your condition will become true at some tick while in non visual mode, it will never become true, since the calculate method is only called once per bar, considering only the closed prices.

I would suggest you use High/Low values instead of Close values to resolve the problem.

Best regards, 

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 05:29

Hi there,

Please provide a better explanation of your problem.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 05:28

Hi there,

This is a graphics card issue. Please update your graphics card drivers.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
21 Jun 2024, 05:27

RE: RE: Load more History on Backtest

eynt said: 

PanagiotisCharalampous said: 

Hi all,

This has been implemented in v5.0.

Best regards,

Panagiotis

Hello

I'm using version 5.0.25.27693 and is does not seem like the issue is implemented.

While using Backtest I called the Bars.LoadMoreHistory method, however the values of Bars.Count and Bars.OpenTimes[0] are not changed

Thanks

Can you provide exact steps to reproduce i.e. code, broker, cBot parameters and dates?

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
20 Jun 2024, 06:59

Hi there,

I don't think this was ever working. When the indicator is unloaded and destroyed, all references created by the indicator will do as well, same for the indicator's log. If you want to check this, write in an external file.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
20 Jun 2024, 06:54

Hi there,

Yes you need to restart the instances.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
20 Jun 2024, 06:42

Hi there,

You can find an example on how to exchange FIX API messages in the link below

https://github.com/spotware/FIX-API-Sample

Best regards,

Panagiotis


@PanagiotisCharalampous