Topics
24 Sep 2020, 03:44
 1043
 5
19 Aug 2020, 02:31
 827
 2
18 Aug 2020, 20:57
 802
 2
12 Aug 2020, 04:50
 1095
 2
10 Aug 2020, 22:08
 1355
 3
Replies

samuel.jus.cornelio
26 Aug 2020, 15:01

RE:

PanagiotisCharalampous said:

Hi Sam,

I am not sure what kind of an example do you need. Can you please explain?

Best Regards,

Panagiotis 

Join us on Telegram

 

I need an example of how to put this Indicator (61.8 retracement) in my Cbot


@samuel.jus.cornelio

samuel.jus.cornelio
26 Aug 2020, 14:44

RE:

PanagiotisCharalampous said:

Hi Sam,

It seems this indicator is using another indicator (ZigZagAndFiboLevels). Did you download this indicator? 

Best Regards,

Panagiotis 

Join us on Telegram

 

now the indicator is being built normally :))

is there any example of making the reference? Thanks man


@samuel.jus.cornelio

samuel.jus.cornelio
26 Aug 2020, 14:22 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi Sam,

Thanks but you did not reply to my question :) Did you try to build the indicator? Does it compile without problems?

Best Regards,

Panagiotis 

Join us on Telegram

 

And we have an answer. No it doesn't build normally, I get this error message

Error : Project C:\Users\Samuel\Documents\cAlgo\Sources\Indicators\ZigZag\ZigZag\ZigZag.csproj doesn't exist.

 

 

follow the indicator code below 

 

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 NewIndicator : Indicator
    {
        [Parameter(DefaultValue = 0.5)]
        public double Deviation { get; set; }
        [Parameter("% Retracement", DefaultValue = 38.2)]
        public double per { get; set; }

        [Output("_forIndicators", Color = Colors.Gray, PlotType = PlotType.DiscontinuousLine)]
        public IndicatorDataSeries sign { get; set; }
        [Output("UpTrend", PlotType = PlotType.DiscontinuousLine)]
        public IndicatorDataSeries up { get; set; }
        [Output("DownTrend", Color = Colors.Red, PlotType = PlotType.DiscontinuousLine)]
        public IndicatorDataSeries down { get; set; }

        private ZigZagAndFiboLevels zz;


        protected override void Initialize()
        {
            zz = Indicators.GetIndicator<ZigZagAndFiboLevels>(Deviation, false, false, false);
        }

        public override void Calculate(int index)
        {
            int i = index;
            while (double.IsNaN(zz.Value[i]) && i > 0)
            {
                i--;
            }
            double A = zz.Value[i];
            i--;
            while (double.IsNaN(zz.Value[i]) && i > 0)
            {
                i--;
            }
            double B = zz.Value[i];
            sign[index] = A < B ? B - (1 - per / 100) * (B - A) : A > B ? A - per / 100 * (A - B) : double.NaN;
            down[index] = A < B ? B - (1 - per / 100) * (B - A) : double.NaN;
            up[index] = A > B ? A - per / 100 * (A - B) : double.NaN;

        }
    }
}


@samuel.jus.cornelio

samuel.jus.cornelio
26 Aug 2020, 14:17 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi Sam,

Thanks but you did not reply to my question :) Did you try to build the indicator? Does it compile without problems?

Best Regards,

Panagiotis 

Join us on Telegram

 

Sorry man, I will try this method right now. Thank you


@samuel.jus.cornelio

samuel.jus.cornelio
26 Aug 2020, 14:10

RE:

PanagiotisCharalampous said:

Hi Sam,

Did you build the indicator before referencing it? Does it build without problems?

Best Regards,

Panagiotis 

Join us on Telegram

 

The indicator has been used normally in live trades.

In case the indicator was downloaded from the Ctrader website

@samuel.jus.cornelio

samuel.jus.cornelio
21 Aug 2020, 17:00

RE:

PanagiotisCharalampous said:

Hi Sam,

Your code will stop the cBot completely on the specific days. Try something like this instead

            var day = Server.Time.DayOfWeek;
            if (day == DayOfWeek.Monday || day == DayOfWeek.Tuesday || day == DayOfWeek.Wednesday || day == DayOfWeek.Thursday)
            {
                // Trade
            }

Best Regards,

Panagiotis 

Join us on Telegram

 

man, you are the best. now it's working perfectly.

THAAANKS


@samuel.jus.cornelio

samuel.jus.cornelio
20 Aug 2020, 22:45

RE:

PanagiotisCharalampous said:

Hi Sam,

It does not work because you expect a day to a Friday and a Saturday and a Sunday at the same time. Try an OR condition instead.

Best Regards,

Panagiotis 

Join us on Telegram

 

 

Hello Panagiotis, don't forget about me. brother


@samuel.jus.cornelio

samuel.jus.cornelio
20 Aug 2020, 12:25

RE:

PanagiotisCharalampous said:

Hi Sam,

It does not work because you expect a day to a Friday and a Saturday and a Sunday at the same time. Try an OR condition instead.

Best Regards,

Panagiotis 

Join us on Telegram

 

 

I tried it that way and it didn't work either.

I am using this code to test a strategy in Backtesting. It needs to work from Monday to Thursday. stopping on Friday and returning only on Monday Could you please give me an example of how to create these command lines?  

 

 

 

 

 

   protected override void OnTick()
        {






            {

                if (Server.Time.DayOfWeek == DayOfWeek.Friday)
                {
                    Stop();
                }
                if (Server.Time.DayOfWeek == DayOfWeek.Sunday)
                {
                    Stop();
                }
                if (Server.Time.DayOfWeek == DayOfWeek.Saturday)
                {
                    Stop();
                }
            }


@samuel.jus.cornelio

samuel.jus.cornelio
20 Aug 2020, 12:18

RE:

PanagiotisCharalampous said:

Hi Sam,

It does not work because you expect a day to a Friday and a Saturday and a Sunday at the same time. Try an OR condition instead.

Best Regards,

Panagiotis 

Join us on Telegram

 

 


@samuel.jus.cornelio

samuel.jus.cornelio
19 Aug 2020, 02:28

RE:

samuel.jus.cornelio said:

Hello, I'm trying to create a code to start trading at a specific time. But I'm not succeeding

follow 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 bot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

  [Parameter("Begin Trading Hour", DefaultValue = 6)]
        public int Begin { get; set; }

        [Parameter("Ending Trading Hour", DefaultValue = 18)]
        public int Ending { get; set; }

   private DateTime startTime;
        private DateTime endTime;

    protected override void OnTick()
        {
 

 startTime = Server.Time.Date.AddHours(Begin);
                endTime = Server.Time.Date.AddHours(Ending);

                if (Trade.IsExecuting)
                    return;

                bool tradeTime = false;
                if (Begin < Ending)
                    tradeTime = Server.Time.Hour >= Begin && Server.Time.Hour < Ending;
                if (Ending < Begin)
                    tradeTime = Server.Time.Hour >= Begin || Server.Time.Hour <= Ending;

                if (!tradeTime)
                    return;

 

I already managed to solve the problem


@samuel.jus.cornelio

samuel.jus.cornelio
17 Aug 2020, 17:05

RE:

PanagiotisCharalampous said:

Hi Sam,

Can you explain what is the problem?

Best Regards,

Panagiotis 

Join us on Telegram

 

Hey bro
the code simply does not work, no error message appears, but the code continues making trades outside the specified time  

@samuel.jus.cornelio

samuel.jus.cornelio
12 Aug 2020, 22:07

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

Your code is wrong. Try the below

_Ema1.Result.HasCrossedBelow(_Ema2.Result, 0)

Best Regards,

Panagiotis 

Join us on Telegram

 

THANK YOU SO MUCH THAT I NEEDED. My bot is working perfectly


@samuel.jus.cornelio

samuel.jus.cornelio
11 Aug 2020, 17:44

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

There are examples in the links above.

Best Regards,

Panagiotis 

Join us on Telegram

 

Dear Sir Panagiotis I tried the example cited but was unsuccessful. Could you please give me a concrete example of a code where an Ema crosses another EMA. Thank you so much

 

 

 

Below is the code I tried if (_Ema1.Result.HasCrossedBelow (MarketSeries.Close, 0) _Ema2.Result.LastValue)


@samuel.jus.cornelio

samuel.jus.cornelio
11 Aug 2020, 16:01

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

You can use the HasCrossedAbove and HasCrossedBelow methods.

Best Regards,

Panagiotis 

Join us on Telegram

 

This Way??

 

 if (_rsi.Result.LastValue < 45)
                    if (_Ema1.Result.LastValue. HasCrossedBelow  _Ema2.ResultLastValue)



                        ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, "bot", StopLoss, TakeProfit);


@samuel.jus.cornelio

samuel.jus.cornelio
10 Aug 2020, 17:29

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

So you need to check if the price is above or below the EMA accordingly and not if it is equal.

Best Regards,

Panagiotis 

Join us on Telegram

 

Exactly my friend. thanks for the correction. Please, how can I code this?


@samuel.jus.cornelio

samuel.jus.cornelio
10 Aug 2020, 17:15 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

It is very rare the EMA to become equal to the price. You need to rethink your logic. Maybe your intentions are different to what you have written.

Best Regards,

Panagiotis 

Join us on Telegram

here is a picture of what i have in mind.
as I put in the code, the deal would start when the price touched or broke the EMA

 

 


@samuel.jus.cornelio

samuel.jus.cornelio
10 Aug 2020, 16:54 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

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
    {
        ExponentialMovingAverage _ema;
        protected override void OnStart()
        {
            _ema = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 14);
        }


        protected override void OnTick()
        {

            if (_ema.Result.LastValue == Symbol.Bid)
            {
                // Execute trade
            }
        }

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

Best Regards,

Panagiotis 

Join us on Telegram

I tried to apply the example, but when backtesting nothing happened. Below is the code and a photo of my screen

 

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 bot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        [Parameter("Source")]
        public DataSeries Source { get; set; }

        [Parameter("Periods", DefaultValue = 14)]
        public int Periods { get; set; }

        [Parameter("Stop Loss (pips)", DefaultValue = 20, MinValue = 1)]
        public int StopLoss { get; set; }

        [Parameter("Volume", DefaultValue = 10000, MinValue = 1000)]
        public int Volume { get; set; }


        [Parameter("Take_Profit", DefaultValue = 45, MinValue = 10)]
        public int TakeProfit { get; set; }

        [Parameter("Begin Trading Hour", DefaultValue = 5.0)]
        public double Begin { get; set; }

        [Parameter("Ending Trading Hour", DefaultValue = 19.0)]
        public double Ending { get; set; }

        private DateTime startTime;
        private DateTime endTime;






        public RelativeStrengthIndex _rsi;
        private ExponentialMovingAverage _Ema1;




        protected override void OnStart()
        {


        }


        protected override void OnTick()
        {

            {
                startTime = Server.Time.Date.AddHours(Begin);
                endTime = Server.Time.Date.AddHours(Ending);

                if (Trade.IsExecuting)
                    return;

                bool tradeTime = false;
                if (Begin < Ending)
                    tradeTime = Server.Time.Hour >= Begin && Server.Time.Hour < Ending;
                if (Ending < Begin)
                    tradeTime = Server.Time.Hour >= Begin || Server.Time.Hour <= Ending;

                if (!tradeTime)
                    return;
            }








            _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 48);
            _Ema1 = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 6);



            {
                if (_rsi.Result.LastValue < 45)
                    if (_Ema1.Result.LastValue == Symbol.Bid)



                        ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, "bot", StopLoss, TakeProfit);


            }


            {
                if (_rsi.Result.LastValue > 55)
                    if (_Ema1.Result.LastValue == Symbol.Bid)





                        ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, "bot", StopLoss, TakeProfit);






            }
        }


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

 

 

 

 


@samuel.jus.cornelio

samuel.jus.cornelio
10 Aug 2020, 15:04

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

Can you define what "touch" means? Do you mean the close price to be the same with the EMA or the EMA price to be between the open and close prices? In any case, both comparisons seem pretty straight forward. Let us know what is the difficulty for you.

Best Regards,

Panagiotis 

Join us on Telegram

 

I need to create an entry trigger.
This is when the current price is equal to the MME price.
But I don't know how to code this.

@samuel.jus.cornelio

samuel.jus.cornelio
07 Aug 2020, 03:25 ( Updated at: 07 Aug 2020, 08:21 )

I get this mansion when I try to create my robot (VERAQUI) it was the name of a robot I had previously created 

how can i solve this problem? THANK YOU

 

 

Error CS0111: The type 'cAlgo.Robots.VERAQUI' already defines a member named 'OnStart' with the same types of parameters


@samuel.jus.cornelio

samuel.jus.cornelio
07 Aug 2020, 01:05 ( Updated at: 07 Aug 2020, 08:21 )

Hi guys, please. what is the correct way to place overbought and oversold parameters of the RSI? thank you for the kindness

 

 

 [Parameter("Source")]

        public DataSeries Source { get; set; }



        [Parameter("Periods", DefaultValue = 14)]
        public int Periods { get; set; }


        [Parameter("overbought", DefaultValue < 60)]
        public double overbought { get; set; }
       

        [Parameter("oversold", DefaultValue > 40)]
        public double oversold { get; set; }


@samuel.jus.cornelio