CTrader Automate: Does not start trading on the Pepperstone platform

Created at 16 Oct 2023, 07:38
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!
MU

mufasa6460

Joined 16.10.2023

CTrader Automate: Does not start trading on the Pepperstone platform
16 Oct 2023, 07:38


Hi everyone,

The CTrader automat bot does not start automatically on the Pepperstone platform. (It works perfectly on the IC Market platform.) I've been trying for two days without success. The bot has full access. I am attaching the coding and logs.

Can someone please tell me what I'm doing wrong?

     using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class AASampleRSIcBot : Robot
    {
        [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
        public double Quantity { get; set; }

        [Parameter("Source", Group = "RSI")]
        public DataSeries Source { get; set; }

        [Parameter("Periods", Group = "RSI", DefaultValue = 50)]
        public int Periods { get; set; }
        
        [Parameter("Stop Loss", DefaultValue = 0)]
        public int StopLoss { get; set; }
 
        [Parameter("Take Profit", DefaultValue = 0)]
        public int TakeProfit { get; set; }
        
        [Parameter(DefaultValue = 0)]
        public double NetProfit { get; set; }
        
        [Parameter(DefaultValue = 0)]
        public double GrossProfit { get; set; } 
        
        [Parameter(DefaultValue = 0)]
        public double Pips { get; set; }
                 
        public double balance;

        private RelativeStrengthIndex rsi;

        protected override void OnStart()
        {
            rsi = Indicators.RelativeStrengthIndex(Source, Periods);
           // Get the initial balance 

            balance = Account.Balance; 

            Print(balance);              
        }
        

        protected override void OnTick()
        {
        
        foreach (var position in Positions)
        
                if(position.GrossProfit >= position.NetProfit +1)
                {
                    ClosePosition(position);
                    return;
                } 

                balance = Account.Balance; 

                Print(balance);
        
        // Check if equity is in profit then shut down the grid cycle             
                        
        foreach (var position in Positions)
        
                if(Account.Equity >= balance + 1)
                {
                    ClosePosition(position);
                    Stop();
                } 

                balance = Account.Balance; 

                Print(balance);

        ///////////////////////////////////////////////////////////////////////////////////////
        
            if (rsi.Result.LastValue < 30)
            {
                Close(TradeType.Sell);
                Open(TradeType.Buy);
            }
            else if (rsi.Result.LastValue > 70)
            {
                Close(TradeType.Buy);
                Open(TradeType.Sell);
            }
        }

        private void Close(TradeType tradeType)
        {
            foreach (var position in Positions.FindAll("SampleRSI", SymbolName, tradeType))
                ClosePosition(position);
                return;
        }

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

            if (position == null)
                ExecuteMarketOrder(tradeType, SymbolName, volumeInUnits, "SampleRSI");
                ExecuteMarketOrder(tradeType, SymbolName, volumeInUnits, "SampleRSI");
        }
    }
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

 

 

 


@mufasa6460
Replies

PanagiotisChar
17 Oct 2023, 03:37 ( Updated at: 17 Oct 2023, 03:38 )

Hi there, 

As per the logs the cBot starts normally. Can you elaborate on what the issue is?


@PanagiotisChar