Error VOID

Created at 04 Aug 2020, 16:03
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!
SA

samuel.jus.cornelio

Joined 19.03.2020

Error VOID
04 Aug 2020, 16:03


Olá galera, eu tenho encontrado alguns problemas com meu codigo e nao acho resposta para resolver o problema. 

Estou recebendo um aviso de erro referente ao "VOID" ele anuncia o erro de " class delegate enum interface ou struct esperado"

como posso resolver esse problema?

muito obrigado pela atenção 

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.0)]
        public double Parameter { get; set; }

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

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

        [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 0.02, MinValue = 0.01, Step = 0.01)]
        public double Quantity { get; set; }

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

     }
    



}
        protected override void OnStart()
        {
            _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 3);
            _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 6);
            _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 12);
        }








        protected override void OnTick()
        {
            if (_rsi.Result.LastValue < 40)
                if (_rsi2.Result.LastValue < 40)
                    if (_rsi3.Result.LastValue < 40)
                        Close(TradeType.buy);
            Open(TradeType.sell);

            if (_rsi.Result.LastValue > 60)
                if (_rsi2.Result.LastValue > 60)
                    if (_rsi3.Result.LastValue > 60)
                        Close(TradeType.Sell);
            Open(TradeType.Buy);
       
}
        
        
        

        protected override void OnStop()
        {
            private void Close(TradeType tradeType)
        {
            foreach (var position in Positions.FindAll("SampleRSI", Symbol, tradeType))
                ClosePosition(position);
        }

  private void Open(TradeType tradeType)
        {
            var position = Positions.Find("SampleRSI", Symbol, tradeType);

            if (position == null)
                ExecuteMarketOrder(tradeType, Symbol, Volume, "SampleRSI");
        }
        }
    }
}
 


@samuel.jus.cornelio
Replies

PanagiotisCharalampous
04 Aug 2020, 16:49

Hi samuel.jus.cornelio,

Can you please write in English? It will be easier for us to help you. The code is a mess, did you just copy and paste stuff?

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

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

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

Can you please write in English? It will be easier for us to help you. The code is a mess, did you just copy and paste stuff?

Best Regards,

Panagiotis 

Join us on Telegram

 

sorry, here is the translation of my post, thanks for your attention

 

Hello guys, I have found some problems with my code and I can't find an answer to solve the problem.

I am receiving an error warning regarding "VOID" it announces the error of "class delegate enum interface or expected struct"

how can i solve this problem?

 

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.0)]
        public double Parameter { get; set; }

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

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

        [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 0.02, MinValue = 0.01, Step = 0.01)]
        public double Quantity { get; set; }

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

     }
    



}
        protected override void OnStart()
        {
            _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 3);
            _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 6);
            _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 12);
        }








        protected override void OnTick()
        {
            if (_rsi.Result.LastValue < 40)
                if (_rsi2.Result.LastValue < 40)
                    if (_rsi3.Result.LastValue < 40)
                        Close(TradeType.buy);
            Open(TradeType.sell);

            if (_rsi.Result.LastValue > 60)
                if (_rsi2.Result.LastValue > 60)
                    if (_rsi3.Result.LastValue > 60)
                        Close(TradeType.Sell);
            Open(TradeType.Buy);
       
}
        
        
        

        protected override void OnStop()
        {
            private void Close(TradeType tradeType)
        {
            foreach (var position in Positions.FindAll("SampleRSI", Symbol, tradeType))
                ClosePosition(position);
        }

  private void Open(TradeType tradeType)
        {
            var position = Positions.Find("SampleRSI", Symbol, tradeType);

            if (position == null)
                ExecuteMarketOrder(tradeType, Symbol, Volume, "SampleRSI");
        }
        }
    }
}
 

 

 


@samuel.jus.cornelio

samuel.jus.cornelio
04 Aug 2020, 18:45 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi samuel.jus.cornelio,

Can you please write in English? It will be easier for us to help you. The code is a mess, did you just copy and paste stuff?

Best Regards,

Panagiotis 

Join us on Telegram

 

 


@samuel.jus.cornelio