declaration incorrect

Created at 11 May 2020, 00:58
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
EL

eliezer_barros

Joined 21.12.2018

declaration incorrect
11 May 2020, 00:58


The index information to calculation is wrong and I need to help to solve.

Please, can you check to me?

tks

 

 

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using System.IO;
using System.Text;
namespace cAlgo.Robots
{


    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Rotinacomcorrecaodecurvas : Robot
    {
        [Parameter(DefaultValue = 1)]
        public double VolumeToOpenOrders { get; set; }

        [Parameter(DefaultValue = 40)]
        public int TakeProfitInPips { get; set; }

        [Parameter("Stop Loss", DefaultValue = 40)]
        public int StopLoss { get; set; }

        [Parameter("Hora Abertura", DefaultValue = 12)]
        public int LastValue { get; set; }

        [Parameter("Indice da Curva", DefaultValue = 15.0)]
        public int Period { get; set; }

        [Parameter("Tamanho da reta", DefaultValue = 18.0)]
        public int Parameter { get; set; }

        protected override void OnBar()
        {

            if (Bars.OpenTimes.LastValue.Hour == LastValue)
            {

               //   public override void Calculate(int index)


                var wad = Indicators.WilliamsAccumulationDistribution();
                var lrs = Indicators.LinearRegressionSlope(wad.Result, Period);
                var res = Bars.ClosePrices[index] + lrs.Result[index];

                {
                    if (res.Result.LastValue > res.Result.Last(Parameter))
                        ExecuteMarketOrder(TradeType.Buy, Symbol.Name, VolumeToOpenOrders, "", StopLoss, TakeProfitInPips);
                }
                {
                    if (res.Result.LastValue < res.Result.Last(Parameter))
                        ExecuteMarketOrder(TradeType.Sell, Symbol.Name, VolumeToOpenOrders, "", StopLoss, TakeProfitInPips);
                    {
                    }
                }

            }
        }
    }
}


@eliezer_barros
Replies

PanagiotisCharalampous
11 May 2020, 08:49

Hi Eliezer,

It is not clear what your problem is. You need to provide a better explanation.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

eliezer_barros
11 May 2020, 15:56

RE:

PanagiotisCharalampous said:

Hi Eliezer,

It is not clear what your problem is. You need to provide a better explanation.

Best Regards,

Panagiotis 

Join us on Telegram

 

Hi,

The information is "the name index does not exist in the current context".

  var res = Bars.ClosePrices[index] + lrs.Result[index];

 

I am trying to use this routine that was to create graphics to calculate and reproduce the same information that graphics.

thank for your help


@eliezer_barros

PanagiotisCharalampous
11 May 2020, 16:04

Hi Eliezer,

As the message suggests, there is no variable named index declared. It seems you are just copying and pasting code. You need to understand what you are doing. What is the index supposed to do?

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

eliezer_barros
11 May 2020, 16:10

RE:

PanagiotisCharalampous said:

Hi Eliezer,

As the message suggests, there is no variable named index declared. It seems you are just copying and pasting code. You need to understand what you are doing. What is the index supposed to do?

Best Regards,

Panagiotis 

Join us on Telegram

As you can see in the routine, I left the declaration of the variable in stand by (//) because when I put it to use, other messages appear and as I don't master this language, msn doesn't make sense to me.

tks


@eliezer_barros

PanagiotisCharalampous
11 May 2020, 16:40

Hi Eliezer,

There is no declaration of the index variable anywhere, the commented code seems to be a function declaration probably copied from an indicator. It it obvious that you lack basic programming skills and that you tried to copy and paste code without really understanding what you are doing. I would suggest you contact a professional to help you with your project instead of trying yourself.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous