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

PanagiotisCharalampous
12 Jan 2024, 07:29

Hi there, 

Please explain what exact help to you need. Nobody will do the job for you but we are happy to help you do it yourself

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:27

Hi there,

Can you please advise your broker and share some screenshots?

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:26

Responded here

https://ctrader.com/forum/ctrader-support/42682#post-106805


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:25

Hi there,

Make sure that you use the .Net 6.0 compiler to build your cBots


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:23

Hi there,

Can you please advise your broker, the symbol you are using and share some screenshots as well?

Best regards,

 


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:20 ( Updated at: 12 Jan 2024, 07:21 )

Hi there,

Thanks for the information, we will investigate it

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:19

Hi there,

Can you please explain to us how we can reproduce this behavior? Screenshots and videos would be helpful.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:18

RE: RE: RE: RE: RE: Draw issue

razor_00 said: 

PanagiotisCharalampous said: 

razor_00 said: 

PanagiotisCharalampous said: 

GOLDEN.DRAGONS said: 

I got the same issue recently. When I would try to use any objects like Trend Line or Fibonacci Fan and etc. it will get out of mouse control when market is ticking but when a symbol stopped or disabled I can draw properly.
Using cTrader 4.8.28 on Errante

Hi there,

Could you please send us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.

Best regards,

I made a simple indicator that will cause this issue to occur 100% of the times. The line causing the issue is DrawText or drawing anything every tick, if I am drawing something or drawing on the chart window, the object will lose focus as soon as Calculate is invoked on the indicator.

Code below:

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{    [Indicator(AccessRights = AccessRights.None, IsOverlay = false)]    public class DrawingBug : Indicator    {        public override void Calculate(int index)        {            IndicatorArea.RemoveObject("test");            IndicatorArea.DrawText("test", "BUG!!!", Bars.Last().OpenTime, 0, Color.Red);        }    }}

Hi razor_00,

Thank you, I have forwarded this to the product team for resolution. In the meanwhile, the issue is caused by the RemoveObject method, which in this case is redundant, you don't need to remove an object in order to redraw it. If you remove that line of code, it should fix the problem.

Best regards,

Panagiotis

Thanks for your reply, I will modify my indicator, anyway the remove and draw calls should not call this behaviour, is that correct? Is that going to be fixed in future versions?

Yes that is correct, we will fix this in an upcoming version


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:17

Hi there,

The correct property to modify is GroupName

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:15

RE: RE: RE: RE: RE: RE: ChatGPT cBot Issues

danerius said: 

PanagiotisCharalampous said: 

It seems you missed my response.

Can you please advise what DoubleRenko is?

public DoubleRenko doubleRenko;

 

Apparently I did :)

DoubleRenko is a modified version of mRenkoLineBreak. Heres the code for DoubleRenko

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

namespace cAlgo
{    
   [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
   public class DoubleRenko : Indicator
   {
       [Parameter("ATR Periods (default 12)", DefaultValue = 12, MinValue = 2)]
       public int AtrPeriods { get; set; }

       [Parameter("ATR Exponent (default 1.0)", DefaultValue = 1.0, MinValue = 1.0, MaxValue = 2.0)]
       public double AtrExponent { get; set; }

       [Parameter("ATR Multiplier (default 1.0)", DefaultValue = 1.0)]
       public double AtrMultiplier { get; set; }

       [Parameter("Lookback Period (default 1000)", DefaultValue = 1000, MinValue = 1)]
       public int LookbackPeriod { get; set; }

       [Parameter("ATR Smoothing Type", DefaultValue = MovingAverageType.Exponential)]
       public MovingAverageType AtrSmoothingType { get; set; }

       [Output("Renko Top", LineColor = "Gray")]
       public IndicatorDataSeries RenkoTop { get; set; }

       [Output("Renko Bottom", LineColor = "Gray")]
       public IndicatorDataSeries RenkoBottom { get; set; }

       [Output("Current Brick", LineColor = "White", Thickness = 1)]
       public IndicatorDataSeries CurrentBrick { get; set; }

       public double _brickSize;
       public AverageTrueRange _atr;
       public bool _isAscending = true;
 

       protected override void Initialize()
       {
           _atr = Indicators.AverageTrueRange(AtrPeriods, AtrSmoothingType);
       }

       public override void Calculate(int index)
{
   if (index < LookbackPeriod)
   {
       RenkoTop[index] = double.NaN;
       RenkoBottom[index] = double.NaN;
       CurrentBrick[index] = double.NaN;
       return;
   }
   
   double atrValue = _atr.Result[index];
   _brickSize = AtrMultiplier * Math.Pow(atrValue, AtrExponent);

   if (index == LookbackPeriod)
   {
       RenkoTop[index] = Bars.ClosePrices[index];
       RenkoBottom[index] = Bars.ClosePrices[index] - _brickSize;
       _isAscending = Bars.ClosePrices[index] > Bars.ClosePrices[index - 1];
   }
   else
   {
       RenkoTop[index] = RenkoTop[index - 1];
       RenkoBottom[index] = RenkoBottom[index - 1];

       if (Bars.ClosePrices[index] >= RenkoTop[index] + _brickSize)
       {
           _isAscending = true;
           RenkoTop[index] = RenkoTop[index - 1] + _brickSize;
           RenkoBottom[index] = RenkoTop[index] - _brickSize;
       }
       else if (Bars.ClosePrices[index] <= RenkoBottom[index] - _brickSize)
       {
           _isAscending = false;
           RenkoBottom[index] = RenkoBottom[index - 1] - _brickSize;
           RenkoTop[index] = RenkoBottom[index] + _brickSize;
       }
   }

   CurrentBrick[index] = _isAscending ? RenkoTop[index] : RenkoBottom[index];
   }
}
}

Hi danerius,

Thanks. It works fine on my side

 Could you please send us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.

 


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:08

Also try to reset your backtesting cache and let us know if this helps. Delete this folder and restart cTrader

C:\Users\%username%\AppData\Roaming\Spotware\Cache


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:04

Hi Andrea,

You would need to provide a better explanation regarding how exactly you want to proceed. What exact information are you looking for?

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 07:00

Hi there,

Thank you for reporting this issue. Could you please send us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.

Best regards,

Panagiotis
 


@PanagiotisCharalampous

PanagiotisCharalampous
12 Jan 2024, 06:59

RE: RE: Open positions per Bar - OnTick

ryan.a.blake said: 

PanagiotisCharalampous said: 

Hi Ryan,

You can use a flag to achieve this e.g. bool CanTrade. Set it to false when a trade is taken and then set it back to true when a new bar is opened.

Best regards,

Panagiotis

 

Thanks Panagiotis,

I have attempted the code below, but believe I am missing something as it places multiple trades per bar, but trader per bar after bar is opened. I attempted to limit positions with Positions.Count, but that stops it being placed per bar. 

 

Have I missed something?

 

Thanks for your help.

 

private bool _canTrade;
private int barCountSinceLastPosition;
        protected override void OnStart()
        {
            _ema1 = Indicators.GetIndicator<SampleEMA>(Source1, Period1);
            _ema2 = Indicators.GetIndicator<SampleEMA>(Source2, Period2);
             _ema3 = Indicators.GetIndicator<SampleEMA>(Source3, Period3);
            _rsi = Indicators.RelativeStrengthIndex(Source3, Period3);
           
           Bars.BarOpened += Bar_Opened;
         }
        
           void Bar_Opened(BarOpenedEventArgs args)
                   {
                      _canTrade = false;
            
                   }
        
         protected override void OnTick()
        {   
           if (IncludeBreakEven == true)
                GoToBreakEven();
               
            var Ema1 = _ema1.Result.Last(0);
            var Ema2 = _ema2.Result.Last(0);
            var Ema1i = _ema1.Result.Last(2);
            var Ema2i = _ema2.Result.Last(2);
            var Ema3 = _ema3.Result.LastValue;
            var rising = _ema1.Result.IsRising();
            var falling = _ema2.Result.IsFalling();
            var rising2 = _ema2.Result.IsRising();
            var falling2 = _ema1.Result.IsFalling();
                          
             if (Ema1 > Ema2 && falling && falling2 && Symbol.Bid == Bars.OpenPrices.Last(0) - (pips * Symbol.PipSize))
            {
                
                   if (Positions.Count(x => x.TradeType == TradeType.Sell && x.Label == InstanceName) == 0)
                
                         {
                               double volume = Symbol.QuantityToVolumeInUnits(lotsize);
                               ExecuteMarketOrder(TradeType.Sell, SymbolName, volume, InstanceName, SL, TP);
                
                           }
                               {
                                  _canTrade = true;
                               }
                                    if(_canTrade)
                                    {
                                        if (Ema1 > Ema2 && falling && falling2 && Symbol.Bid == Bars.OpenPrices.Last(0) - (pips * Symbol.PipSize))
                                         {
                                             double volume = Symbol.QuantityToVolumeInUnits(lotsize);
                                             ExecuteMarketOrder(TradeType.Sell, SymbolName, volume, InstanceName, SL, TP);
                                         }
                                   }
                              }
                          {
                    CloseSell();
                     } 
                    
               }

Hi Ryan,

_canTrade needs to be set to false in OnTick() and to true in OnBar()

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
11 Jan 2024, 07:07

RE: RE: RE: Draw issue

razor_00 said: 

PanagiotisCharalampous said: 

GOLDEN.DRAGONS said: 

I got the same issue recently. When I would try to use any objects like Trend Line or Fibonacci Fan and etc. it will get out of mouse control when market is ticking but when a symbol stopped or disabled I can draw properly.
Using cTrader 4.8.28 on Errante

Hi there,

Could you please send us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.

Best regards,

I made a simple indicator that will cause this issue to occur 100% of the times. The line causing the issue is DrawText or drawing anything every tick, if I am drawing something or drawing on the chart window, the object will lose focus as soon as Calculate is invoked on the indicator.

Code below:

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{    [Indicator(AccessRights = AccessRights.None, IsOverlay = false)]    public class DrawingBug : Indicator    {        public override void Calculate(int index)        {            IndicatorArea.RemoveObject("test");            IndicatorArea.DrawText("test", "BUG!!!", Bars.Last().OpenTime, 0, Color.Red);        }    }}

Hi razor_00,

Thank you, I have forwarded this to the product team for resolution. In the meanwhile, the issue is caused by the RemoveObject method, which in this case is redundant, you don't need to remove an object in order to redraw it. If you remove that line of code, it should fix the problem.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
11 Jan 2024, 06:40

Hi there,

The service seems to be working now, can you check again?

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
11 Jan 2024, 06:40

Hi there,

The service seems to be working now, can you check again?

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
11 Jan 2024, 06:36

RE: Same problem

strausa said: 

Hi, I am facing with the same problem. Could you please help me. Is there any limit with the account authorizations and revokes?

 

Hi there,

It looks ok now

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
11 Jan 2024, 06:33

Hi Ryan,

You can use a flag to achieve this e.g. bool CanTrade. Set it to false when a trade is taken and then set it back to true when a new bar is opened.

Best regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
11 Jan 2024, 06:30

RE: RE: RE: RE: ChatGPT cBot Issues

danerius said: 

Hi danerius,

I still do not have the code in a readable format. Can you please fix the format so that we can copy/paste and build it?

Best regards,

Panagiotis

Hi. I posted the code earlier but hree it is again. Thanks /Bo


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

namespace cAlgo.Robots
{
   [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
   public class DanRobot : Robot
   {
       [Parameter("Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
       public double Quantity { get; set; }

       // Additional parameters for DoubleRenko

       public DoubleRenko doubleRenko;
       public const string label = "DoubleRenko Trend cBot";
       
       // Log method here
       private void Log(string message)
       {
           Print($"[{Time}] {message}");
       }

       protected override void OnStart()
        {
           // Initialize DoubleRenko
           Log($"Initializing DoubleRenko with parameters: 12, 1.0, 1.0, 1000, MovingAverageType.Exponential");
           doubleRenko = Indicators.GetIndicator<DoubleRenko>(12, 1.0, 1.0, 1000, MovingAverageType.Exponential);
           Log("DoubleRenko initialized.");
       }


protected override void OnBar()
{
   try
   {
       Log("OnBar started");

       if (doubleRenko.CurrentBrick.Count < 2)
       {
           Log("Not enough data for CurrentBrick");
           return;
       }

       double currentBrick = doubleRenko.CurrentBrick.Last(0);
       double previousBrick = doubleRenko.CurrentBrick.Last(1);

       Log($"CurrentBrick: {currentBrick}, PreviousBrick: {previousBrick}");

       if (double.IsNaN(currentBrick) || double.IsNaN(previousBrick))
       {
           Log("NaN value encountered in CurrentBrick");
           return;
       }

       // Check for existing positions
       var longPosition = Positions.Find(label, SymbolName, TradeType.Buy);
       var shortPosition = Positions.Find(label, SymbolName, TradeType.Sell);

       // Trend detection and trading logic
       if (currentBrick > previousBrick && longPosition == null)
       {
           if (shortPosition != null)
               ClosePosition(shortPosition);

           ExecuteMarketOrder(TradeType.Buy, SymbolName, VolumeInUnits, label);
       }
       else if (currentBrick < previousBrick && shortPosition == null)
       {
           if (longPosition != null)
               ClosePosition(longPosition);

           ExecuteMarketOrder(TradeType.Sell, SymbolName, VolumeInUnits, label);
       }

       Log("OnBar completed without errors");
   }
   catch (Exception ex)
   {
       Log($"Error in OnBar: {ex.Message}");
   }
}


       public double VolumeInUnits
       {
           get { return Symbol.QuantityToVolumeInUnits(Quantity); }
       }
   }
}
 

It seems you missed my response.

Can you please advise what DoubleRenko is?

public DoubleRenko doubleRenko;

 


@PanagiotisCharalampous