A cod with API guide

Created at 05 Aug 2020, 21:48
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

A cod with API guide
05 Aug 2020, 21:48


 

Hello guys, I built a code based on the platform's API guide. however I found a problem that I don't know how to solve Could someone tell me how to solve this problem ?? Thank you very much for your attention 

 

PS Mr Panagiotis  Thank you for your very helpful service, as soon as my bot is finished I will send you a bottle of champagne ;)

 

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 agoravai : Robot
    {
    
       
     
    



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


}



        protected override void OnTick()
        {
            if (_rsi.Result.LastValue <80 )
                if (_rsi2.Result.LastValue < 80)
                    if (_rsi3.Result.LastValue < 80)
                        
   
            var result = ExecuteMarketOrder(TradeType.Sell, Symbol, 1);

            if (result.IsSuccessful)
            {
                var position = result.Position;
                Print("Position entry price is {0}", position.EntryPrice);  if (result.IsSuccessful)
        
            }
        }
    
       

         {
            var position = Positions.Find("myLabel");
            if (position != null && position.GrossProfit > 75)
            {
                ClosePosition(Sell);
                Stop();
            }
        }
    

            if (_rsi.Result.LastValue > 20)
                if (_rsi2.Result.LastValue > 20)
                    if (_rsi3.Result.LastValue > 20)   
        {
            var result = ExecuteMarketOrder(TradeType.Buy, Symbol, 1);
          

            if (result.IsSuccessful)
            {
                var position = result.Position;
                Print("Position entry price is {0}", position.EntryPrice);
            }
        }
    
       

         {
            var position = Positions.Find("myLabel");
            if (position != null && position.GrossProfit > 75)
            {
                ClosePosition(Buy);
                Stop();
            }}}   


@samuel.jus.cornelio
Replies

PanagiotisCharalampous
06 Aug 2020, 08:23

Hi samuel.jus.cornelio,

You need to fix your brackets. Do you have any experience in C# programming? It seems that you are just copying and pasting code in the wrong places.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous