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

samuel.jus.cornelio
19 Feb 2021, 18:37

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

Please provide the complete source code and steps to reproduce the problem.

Best Regards,

Panagiotis 

Join us on Telegram 

 

Ok, 

 

 

 

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

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

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

        [Parameter("Stop Loss (pips)", DefaultValue = 35, MinValue = 10)]
        public double StopLoss { get; set; }

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

        [Parameter("Start Hour", DefaultValue = 6.0)]
        public double StartTime { get; set; }

        [Parameter("Stop Hour", DefaultValue = 14.0)]
        public double StopTime { get; set; }


        private bool _todaysOrderExecuted;
        DateTime _lastTrade;

        private DateTime _startTime;
        private DateTime _stopTime;

  private VolumeOscillator _vol1;
        private VolumeOscillator _vol2;
        private UltimateOscillator _ult1;





        protected override void OnStart()
        {
            _startTime = Server.Time.Date.AddHours(StartTime);


            _stopTime = Server.Time.Date.AddHours(StopTime);


            _lastTrade = Server.Time.AddDays(-1);

            var currentHours = Server.Time.TimeOfDay.TotalHours;
            bool tradeTime = StartTime < StopTime ? currentHours > StartTime && currentHours < StopTime : currentHours < StopTime || currentHours > StartTime;


            if (!tradeTime && _todaysOrderExecuted)
            {
                _todaysOrderExecuted = false;
            }
        }




        protected override void OnTick()
        {

            var hour1 = MarketData.GetBars(TimeFrame.Hour);
            var day = Server.Time.DayOfWeek;

   _vol1 = Indicators.VolumeOscillator(hour1, 6, 6);
            _vol2 = Indicators.VolumeOscillator(hour1, 3, 15);
            _ult1 = Indicators.UltimateOscillator(hour1, 3, 3, 5);




            if (Trade.IsExecuting)
                return;

            var currentHours = Server.Time.TimeOfDay.TotalHours;
            bool tradeTime = StartTime < StopTime ? currentHours > StartTime && currentHours < StopTime : currentHours < StopTime || currentHours > StartTime;

            if (!tradeTime)
                return;

   if (_vol1.Result.LastValue > 200)
                        if (_vol2.Result.LastValue > 200)
                            if (_ult1.Result.LastValue > 60)

 

     _lastTrade = Server.Time;

            if (_lastTrade.DayOfYear != Server.Time.DayOfYear)
                if (day == DayOfWeek.Monday || day == DayOfWeek.Tuesday || day == DayOfWeek.Wednesday || day == DayOfWeek.Thursday)
                    if (Positions.Count == 0)


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

 

if (_vol1.Result.LastValue < -200)
                            if (_vol2.Result.LastValue < -200)

  if (_ult1.Result.LastValue < 40)

  _lastTrade = Server.Time;
                if (day == DayOfWeek.Monday || day == DayOfWeek.Tuesday || day == DayOfWeek.Wednesday || day == DayOfWeek.Thursday)
                    if (Positions.Count == 0)

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


@samuel.jus.cornelio

samuel.jus.cornelio
19 Feb 2021, 13:29

RE: RE:

Shares4us said:

do not know  the indicator but the parametercount does not match!!!!

 

   _hstoch1 = Indicators.StochasticOscillator(hour1, 24, 3, 24, MovingAverageType.Simple);    // not enough or
   _hstoch2 = Indicators.StochasticOscillator(hour1,  3, 3,  3, 3, MovingAverageType.Simple); // one to many
        

just fix it and you'll be OK

THANK YOU SO MUCH.
now it's working perfectly

@samuel.jus.cornelio

samuel.jus.cornelio
20 Jan 2021, 11:39

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

It's not one line of code :) You need to record the datetime at which the trade took place and then check if your current Server.Time day has changed before placing another one.

Best Regards,

Panagiotis 

Join us on Telegram

 

Hi Pani

could you please give me a practical example of how to do this?


@samuel.jus.cornelio

samuel.jus.cornelio
20 Nov 2020, 04:31

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

The indicator has a sign output.

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

You should be checking if the last value of the sign output is above or below the bid price and place the trade accordingly

Best Regards,

Panagiotis 

Join us 

Pani, I tried several ways to create the code, but I couldn't, I'm still waiting for an example of how to program the condition

 

thank you very much for your attention

 


@samuel.jus.cornelio

samuel.jus.cornelio
16 Nov 2020, 15:00

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

The indicator has a sign output.

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

You should be checking if the last value of the sign output is above or below the bid price and place the trade accordingly

Best Regards,

Panagiotis 

Join us on Telegram

Hi Pani, thank you so much for your tips

However I did not understand how to program the condition.
Could you kindly give me an example of how to do what you said?

Thank you so much Pani, you are the best

@samuel.jus.cornelio

samuel.jus.cornelio
13 Nov 2020, 16:06 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

The code you posted doesn't make much sense to me. I am not sure I can help you with this.

Best Regards,

Panagiotis 

Join us on Telegram

As we can see in the image, the price is below the high line of the indicator. Soon after the price goes up.

My question is: how can I place a condition in my bot, so that as soon as the price is below the high 
trend line of the indicator, the Bot makes a buy trade?

@samuel.jus.cornelio

samuel.jus.cornelio
13 Nov 2020, 15:56

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

The code you posted doesn't make much sense to me. I am not sure I can help you with this.

Best Regards,

Panagiotis 

Join us on Telegram

 

Hi Pani. My question is: How can I place a condition for the trade based on the customized indicator? More specifically,

when the price is below the uptrend line, the bot makes a buy trade

 

could you kindly give me an example of how this can be done?


@samuel.jus.cornelio

samuel.jus.cornelio
11 Nov 2020, 18:46

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

Here is an example

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

        NewIndicator _indicator;

        protected override void OnStart()
        {
            _indicator = Indicators.GetIndicator<NewIndicator>(Deviation, per);
        }

        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

Thank you very much, Pani
I managed to reference the indicator because of your tips
You are the man!

 

now i'm trying to put a business condition using this indicator
Please how can I do this efficiently? see how I'm trying
the idea is whenever the price is below the indicator's retraction line that he makes a trade

 

 

   if (_1hstoch2.PercentK.LastValue > 80)

 if ( Symbol.Ask <  (NewIndicator, per, 38,2))

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


@samuel.jus.cornelio

samuel.jus.cornelio
11 Nov 2020, 14:55

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

Here is how to reference a custom indicator.

Best Regards,

Panagiotis 

Join us on Telegram

I tried in many ways to make this reference, but I just wasn't successful.
Pani, could you please give me a concrete example of how to do this?
Below is the indicator in question

 

 


@samuel.jus.cornelio

samuel.jus.cornelio
10 Nov 2020, 17:23

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

The message clearly describes the problem

Error CS0029: It is not possible to implicitly convert the type 'System.TimeSpan' to 'double'

Your variable should be of type TimeSpan and not double.

Best Regards,

Panagiotis 

Join us on Telegram

 

Pani, could you please give me an example of how this can be done? Thank you very much for all the help you have given me, you are the guy


@samuel.jus.cornelio

samuel.jus.cornelio
09 Nov 2020, 18:53

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

You can try something like the below

                tradingStarts = TimeSpan.ParseExact("17:00", "hh\\:mm", null);
                tradingStops = TimeSpan.ParseExact("18:00", "hh\\:mm", null);

                if (Server.Time.TimeOfDay >= tradingStarts && Server.Time.TimeOfDay < tradingStops)
                {
                    // trade
                }

Best Regards,

Panagiotis 

Join us on Telegram

Pani, I tried exactly what you said and I still haven't been successful 

I received 4 error messages in the code :
Error CS0029: It is not possible to implicitly convert the type 'System.TimeSpan' to 'double'

Error CS0029: It is not possible to implicitly convert the type 'System.TimeSpan' to 'double'

Error CS0019: It is not possible to apply the operator '> =' to operands of type 'System.TimeSpan' and 'double'

Error CS0019: It is not possible to apply the operator '<' to operands of type 'System.TimeSpan' and 'double'

the code is 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.ESouthAmericaStandardTime, 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("Volume", DefaultValue = 10000, MinValue = 1000)]
        public int Volume { get; set; }


        [Parameter("Stop Loss (pips)", DefaultValue = 50, MinValue = 10)]
        public double StopLoss { get; set; }

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


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

        [Parameter(" tradingStops", DefaultValue = 18.0)]
        public double tradingStops { get; set; }




        private StochasticOscillator _1hstoch2;

        protected override void OnStart()
        {



        }



        protected override void OnTick()
        {



            {


            }







            var day = Server.Time.DayOfWeek;

            var hour1 = MarketData.GetBars(TimeFrame.Hour);



            tradingStarts = TimeSpan.ParseExact("17:00", "hh\\:mm", null);
            tradingStops = TimeSpan.ParseExact("18:00", "hh\\:mm", null);








            _1hstoch2 = Indicators.StochasticOscillator(hour1, 12, 3, 12, MovingAverageType.Simple);



            if (_1hstoch2.PercentK.LastValue > 80)

                if (day == DayOfWeek.Monday || day == DayOfWeek.Tuesday || day == DayOfWeek.Wednesday || day == DayOfWeek.Thursday)
                    if (Positions.Count == 0)

                        if (Server.Time.TimeOfDay >= tradingStarts && Server.Time.TimeOfDay < tradingStops)

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











        }
    }
}


@samuel.jus.cornelio

samuel.jus.cornelio
09 Nov 2020, 15:10

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

Here is how to reference a custom indicator.

Best Regards,

Panagiotis 

Join us on Telegram

 

Thanks Pani, I will work with this


@samuel.jus.cornelio

samuel.jus.cornelio
09 Nov 2020, 15:00

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

You need to provide the complete cBot code and steps to reproduce this behavior.

Best Regards,

Panagiotis 

Join us on Telegram

 

Pani, the code is up there. Please, how can I write a line of code that makes my bot execute trades only from 5 am until 6 pm? Thanks man, you are the best


@samuel.jus.cornelio

samuel.jus.cornelio
24 Sep 2020, 09:40

RE:

PanagiotisCharalampous said:

Hi sam,

There are a lot of mistakes in your code. What is the actual information you are missing?

Best Regards,

Panagiotis 

Join us on Telegram

Hi Pani, you are the best! And I'm sure you have the answer
I looked for a series of examples of how to put a multitimeframe condition in my code, and I couldn't find any examples.
Could you please. give me an example of how to put a daily condition on an hourly chart.

Setting a practical example
When an RSI on the daily chart is above 60%
and another rsi on the hourly chart is over 60%
the boat executes an order

 

Thanks bro, your help has motivated me a lot on this platform, and I'm sure you have been very helpful to the people of this community.
 Thank you very much

@samuel.jus.cornelio

samuel.jus.cornelio
23 Sep 2020, 17:13

RE:

samuel.jus.cornelio said:

Hello, I am trying to put conditions of multiple graphical times in my bot but I am not having success, someone could help me with this.

My idea is to place various business conditions on the indicators at various graphical times. the business being executed only when all these conditions are met at the same time.
Below is an example of an attempt to operate on an hour and a day chart at the same time

 

 

 

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.ESouthAmericaStandardTime, 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 = 35, MinValue = 10)]
        public double StopLoss { get; set; }

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


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







        public RelativeStrengthIndex _rsi;
        public RelativeStrengthIndex _rsi2;
        public RelativeStrengthIndex _rsi3;
        public RelativeStrengthIndex _rsi4;
        public RelativeStrengthIndex _rsi1d;
        public RelativeStrengthIndex _rsi2d;
        public RelativeStrengthIndex _rsi3d;



        private SimpleMovingAverage _sma;
        private SimpleMovingAverage _sma2;









        protected override void OnStart()
        {









        }



        protected override void OnTick()
        {















            MarketData.GetSeries(Symbol, TimeFrame.Daily);
            _rsi1d = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 10);
            _rsi2d = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 5);
            _rsi3d = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 2);




            var day = Server.Time.DayOfWeek;



            _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 50);
            _rsi2 = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 24);
            _rsi3 = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 12);
            _rsi4 = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 6);


            _sma = Indicators.SimpleMovingAverage(Bars.ClosePrices, 1);
            _sma2 = Indicators.SimpleMovingAverage(Bars.ClosePrices, 4);




            {



                if (_rsi1d.Result.LastValue < 40)
                    if (_rsi2d.Result.LastValue < 40)
                        if (_rsi3d.Result.LastValue < 40)
                            if (_rsi.Result.LastValue < 49)
                                if (_rsi2.Result.LastValue < 49)
                                    if (_rsi3.Result.LastValue < 49)
                                        if (_rsi4.Result.LastValue < 40)




                                            if (Symbol.Ask > _sma2.Result.LastValue)






                                                if (day == DayOfWeek.Monday || day == DayOfWeek.Tuesday || day == DayOfWeek.Wednesday || day == DayOfWeek.Thursday)

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

            }


            if (_rsi1d.Result.LastValue > 60)
                if (_rsi2d.Result.LastValue > 60)
                    if (_rsi3d.Result.LastValue > 60)


                        if (_rsi.Result.LastValue < 51)
                            if (_rsi.Result.LastValue > 51)

                                if (_rsi2.Result.LastValue > 51)
                                    if (_rsi3.Result.LastValue > 51)
                                        if (_rsi4.Result.LastValue > 60)

                                            if (Symbol.Ask < _sma2.Result.LastValue)



                                                if (day == DayOfWeek.Monday || day == DayOfWeek.Tuesday || day == DayOfWeek.Wednesday || day == DayOfWeek.Thursday)



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










        }
    }
}
 

 

 

I tried this command to put the conditions of the daily chart in the 1 hour bot, but I was not successful

 

            var _rsi1dseries = MarketData.GetSeries(Symbol, TimeFrame.Daily);
            var _rsi2dseries = MarketData.GetSeries(Symbol, TimeFrame.Daily);
            var _rsi3dseries = MarketData.GetSeries(Symbol, TimeFrame.Daily);

            _rsi1d = Indicators.RelativeStrengthIndex(_rsi1dseries.ClosePrices, 10);
            _rsi2d = Indicators.RelativeStrengthIndex(_rsi2dseries.ClosePrices, 5);
            _rsi3d = Indicators.RelativeStrengthIndex(_rsi3dseries.ClosePrices, 2);


@samuel.jus.cornelio

samuel.jus.cornelio
23 Sep 2020, 16:06

RE:

PanagiotisCharalampous said:

Hi Sam,

Here is the correct condition

            if (Positions.Count == 0)
            {
                // Do something
            }

Best Regards,

Panagiotis 

Join us on Telegram

thanks brow 


@samuel.jus.cornelio

samuel.jus.cornelio
23 Sep 2020, 15:50

RE:

PanagiotisCharalampous said:

Hi Sam,

You can check if Positions.Count == 0 before placing a trade.

Best Regards,

Panagiotis 

Join us on Telegram

Hi Pani,

 

I tried that way and was unsuccessful. 

 

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.ESouthAmericaStandardTime, 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 = 35, MinValue = 10)]
        public double StopLoss { get; set; }

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


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


        public RelativeStrengthIndex _rsi;
        public RelativeStrengthIndex _rsi2;
        public RelativeStrengthIndex _rsi3;
        public RelativeStrengthIndex _rsi4;
        public RelativeStrengthIndex _rsi1d;
        public RelativeStrengthIndex _rsi2d;
        public RelativeStrengthIndex _rsi3d;
        private SimpleMovingAverage _sma;
        private SimpleMovingAverage _sma2;


        protected override void OnStart()
        {

        }



        protected override void OnTick()
        {

            MarketData.GetSeries(Symbol, TimeFrame.Daily);
            _rsi1d = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 10);
            _rsi2d = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 5);
            _rsi3d = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 2);


            var day = Server.Time.DayOfWeek;

            _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 50);
            _rsi2 = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 24);
            _rsi3 = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 12);
            _rsi4 = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 6);


            _sma = Indicators.SimpleMovingAverage(Bars.ClosePrices, 1);
            _sma2 = Indicators.SimpleMovingAverage(Bars.ClosePrices, 4);

            {

                if (_rsi1d.Result.LastValue < 40)
                    if (_rsi2d.Result.LastValue < 40)
                        if (_rsi3d.Result.LastValue < 40)
                            if (_rsi.Result.LastValue < 49)
                                if (_rsi2.Result.LastValue < 49)
                                    if (_rsi3.Result.LastValue < 49)
                                        if (_rsi4.Result.LastValue < 40)

                                            if (Symbol.Ask > _sma2.Result.LastValue)
                                                                  if (Trade.IsExecuting || position == 0)
                                                                                                         return;


                                                if (day == DayOfWeek.Monday || day == DayOfWeek.Tuesday || day == DayOfWeek.Wednesday || day == DayOfWeek.Thursday)

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

            }


            if (_rsi1d.Result.LastValue > 60)
                if (_rsi2d.Result.LastValue > 60)
                    if (_rsi3d.Result.LastValue > 60)


                        if (_rsi.Result.LastValue < 51)
                            if (_rsi.Result.LastValue > 51)

                                if (_rsi2.Result.LastValue > 51)
                                    if (_rsi3.Result.LastValue > 51)
                                        if (_rsi4.Result.LastValue > 60)

                                            if (Symbol.Ask < _sma2.Result.LastValue)

                                                if (Trade.IsExecuting || position == 0)
                                                    return;



            if (day == DayOfWeek.Monday || day == DayOfWeek.Tuesday || day == DayOfWeek.Wednesday || day == DayOfWeek.Thursday)



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




        }
    }
}


@samuel.jus.cornelio

samuel.jus.cornelio
27 Aug 2020, 16:21

RE:

PanagiotisCharalampous said:

Hi Sam,

How about your indicator's Class name? It's named NewIndicator and not 61.8retracement.

Best Regards,

Panagiotis 

Join us on Telegram

 

sorry, man. I couldn't understand / implement your idea. Could you please give me a concrete example? 


@samuel.jus.cornelio

samuel.jus.cornelio
26 Aug 2020, 19:38

RE:

PanagiotisCharalampous said:

Hi Sam,

In general your code does not make much sense. 

You are declaring this 

private 61.retracement _retra;

But then you are calling an indicator of another type

_retra = Indicators.GetIndicator<Sample61.retracement>(Source);

Finally the class for the indicator you posted is something else

public class NewIndicator : Indicator

Best Regards,

Panagiotis 

Join us on Telegram

 

now I tried it that way. and still not working       :(((

 

 

 

 

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.ESouthAmericaStandardTime, 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 = 40, MinValue = 10)]
        public double StopLoss { get; set; }

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


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

        [Output("Referenced  61.8retracement Output")]
        public IndicatorDataSeries ref61.8retracement { get; set; }

 

   private 61.8retracement _retra;

   protected override void OnTick()

{

  _retra = Indicators.GetIndicator<61.8retracement>(0.5, 30);

 

 

...


@samuel.jus.cornelio

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

RE:

PanagiotisCharalampous said:

Hi Sam,

But you already do this above

_retra = Indicators.GetIndicator<Sample61.retracement>(Source);

Best Regards,

Panagiotis 

Join us on Telegram

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.ESouthAmericaStandardTime, 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 = 40, MinValue = 10)]
        public double StopLoss { get; set; }

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


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

        [Output("Referenced  61.8retracement Output")]
        public IndicatorDataSeries refretracement { get; set; }





        private 61.retracement _retra;

  protected override void OnTick()
        {




_retra = Indicators.GetIndicator<Sample61.retracement>(Source);
 

 

...

 

error messages : 

Error CS1519: Token '61' invalid in class, struct or interface member declaration

 

 

Error CS1031: Expected type

 

:(


@samuel.jus.cornelio