E7 BBKG NumSharp Sample
cBot
262 transferências
Versão 1.0, Feb 2025
Windows, Mac, Mobile, Web
Trading product for E7 BBKG NumSharp Sample cBot AI, image 2
Desde 18/12/2024
2
Vendas
4.26K
Instalações gratuitas

Descrição

Como solicitado por muitos de vocês, agora estamos trabalhando arduamente para fornecer exemplos de alguns de nossos códigos e pacotes de aprendizado de máquina.

TensorFlow, PyTorch, Keras, Numpy, Pandas e muitos outros pacotes .NET para começar dentro do cTrader.

Nossa missão é tornar o Aprendizado de Máquina dentro do cTrader mais fácil para todos.

Boa caça!

*** Este código não realiza nenhuma negociação (ele apenas imprime dados etc). É simplesmente um código de exemplo de como você pode começar a criar seus próprios modelos de IA usando nossos pacotes de Aprendizado de Máquina.

.......................................................

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;

using NumSharp;
using np = NumSharp.np;
using Shape = NumSharp.Shape;

using PandasNet;
using static PandasNet.PandasApi;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class E7BBKGNumSharpSample : Robot
    {
        [Parameter("Versão 1.01", DefaultValue = "Versão 1.01")]
        public string Version { get; set; }

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

        [Parameter("Barras Necessárias", DefaultValue = 50, MinValue = 1, MaxValue = 10000, Step = 1)]
        public int BarsRequired { get; set; }

        [Parameter("Nome do Método", DefaultValue = MethodName.DataSplitPrints)]
        public MethodName Mode { get; set; }
        public enum MethodName
        {
            DataSplitPrints,
            PandasPrints,
            NDArrayPrints
        }
        
        protected override void OnStart()
        {
            // Inicialize quaisquer indicadores
        }

        protected override void OnBar()
        {
            try
            {
                if (Mode == MethodName.DataSplitPrints)
                {
                    DataSplitPrints();
                }
                else if (Mode == MethodName.PandasPrints)
                {
                    PandasPrints();
                }
                else if (Mode == MethodName.NDArrayPrints)
                {
                    NDArrayPrints();
                }
            }
            catch (Exception ex)
            {
                Print($"Erro: {ex.Message}");
                if (ex.InnerException != null)
                {
                    Print($"Exceção Interna: {ex.InnerException.Message}");
                    throw;
                }
            }
        }

        private float[,] GetDataSet()
        {
            int startBar = Bars.ClosePrices.Count - BarsRequired;
            float[,] inputSignals = new float[BarsRequired, 5];

            for (int i = 0; i < BarsRequired; i++)
            {
                int barIndex = startBar + i;
                inputSignals[i, 0] = (float)Bars.OpenPrices[barIndex];
                inputSignals[i, 1] = (float)Bars.HighPrices[barIndex];
                inputSignals[i, 2] = (float)Bars.LowPrices[barIndex];
                inputSignals[i, 3] = (float)Bars.ClosePrices[barIndex];
                inputSignals[i, 4] = (float)Bars.TickVolumes[barIndex];
            }
            return inputSignals;
        }
        
        private float[,] GetTargetDataSet()
        {
            int startBar = Bars.ClosePrices.Count - BarsRequired;
            float[,] inputSignals = new float[BarsRequired, 5];

            for (int i = 0; i < BarsRequired; i++)
            {
                int barIndex = startBar + i;
                inputSignals[i, 0] = (float)Bars.OpenPrices[barIndex];
                inputSignals[i, 1] = (float)Bars.HighPrices[barIndex];
                inputSignals[i, 2] = (float)Bars.LowPrices[barIndex];
                inputSignals[i, 3] = (float)Bars.ClosePrices[barIndex];
                inputSignals[i, 4] = (float)Bars.TickVolumes[barIndex];
            }
            return inputSignals;
        }
        
        /// Impressões de Divisão de Dados do NumSharp
        public void DataSplitPrints()
        {
            // Reformate os dados de entrada para corresponder à forma esperada pelo modelo
            //var inputShape = new Shape(-1, BarsRequired, 5);
            NDArray inputData = np.array<float>(GetDataSet());
            Print("NDarray de Entrada: " + string.Join(", ", inputData));
            
            // Reformate os dados alvo para corresponder à forma alvo esperada pelo modelo
            //var targetShape = new Shape(-1, 5);
            NDArray targetData = np.array<float>(GetTargetDataSet());
            Print("NDarray Alvo: " + string.Join(", ", targetData));
            
            // Divida os dados em conjuntos de treinamento e teste
            int testSize = (int)(0.2 * inputData.shape[0]); // 20% para teste
            var (x_train, x_test) = (inputData[$":{inputData.shape[0] - testSize}"], inputData[$"{inputData.shape[0] - testSize}:"]);
            var (y_train, y_test) = (targetData[$":{targetData.shape[0] - testSize}"], targetData[$"{targetData.shape[0] - testSize}:"]);
            
            Print("Dados X_train: " + string.Join(", ", x_train));
            Print("Dados X_test: " + string.Join(", ", x_test));
            Print("Dados Y_train: " + string.Join(", ", y_train));
            Print("Dados Y_test: " + string.Join(", ", y_test));
        }
        
        /// Impressões do PandasNet
        public void PandasPrints()
        {
            // Converta float[,] para List<Series>
            var inputData = GetDataSet();
            var targetData = GetTargetDataSet();
            
            var inputSeriesList = new List<Series>();
            var targetSeriesList = new List<Series>();
            
            for (int col = 0; col < inputData.GetLength(1); col++)
            {
                List<float> columnData = new List<float>();
                for (int row = 0; row < inputData.GetLength(0); row++)
                {
                    columnData.Add(inputData[row, col]);
                }
                inputSeriesList.Add(new Series(columnData.ToArray()));
            }
            
            for (int col = 0; col < targetData.GetLength(1); col++)
            {
                List<float> columnData = new List<float>();
                for (int row = 0; row < targetData.GetLength(0); row++)
                {
                    columnData.Add(targetData[row, col]);
                }
                targetSeriesList.Add(new Series(columnData.ToArray()));
            }
            // Crie DataFrames
            DataFrame inputDataFrame = new DataFrame(inputSeriesList);
            DataFrame targetDataFrame = new DataFrame(targetSeriesList);
            
            Print("DataFrame de Entrada: " + inputDataFrame);
            Print("DataFrame Alvo: " + targetDataFrame);
            
            //Print("DataFrame de Entrada: " + string.Join(", ", inputDataFrame));
            //Print("DataFrame Alvo: " + string.Join(", ", targetDataFrame));
        }
        
        /// Impressões Simples de NDArrays do NumSharp
        public void NDArrayPrints()
        {
            if (Bars.ClosePrices.Count < BarsRequired)
                return;

            try
            {
                // Chamando seus dados de entrada float[,]
                float[,] inputData = GetDataSet();

                // Converta para NDArray e reformate para (BarsRequired, 5)
                NDArray inputNDArray = np.array(inputData);   // NumSharp
                Print("Dados NDarray NumSharp de Entrada : " + string.Join(", ", inputNDArray));
                Print("Forma do NDarray NumSharp de Entrada: " + string.Join(", ", inputNDArray.shape));
                
                int expectedLength = BarsRequired * 5;
                Print($"Comprimento Esperado do NDarray NumSharp: {expectedLength}");
                Print($"Tamanho do NDarray NumSharp de Entrada: {inputNDArray.size}");

                if (inputNDArray.size != expectedLength)
                {
                    Print($"Incompatibilidade de Comprimento: Comprimento Esperado {expectedLength}, mas obteve Tamanho {inputNDArray.size}");
                    return;
                }
            }
            catch (Exception ex)
            {
                Print("Exceção: " + ex.Message);
                Print("Rastreamento de Pilha: " + ex.StackTrace);

                Exception innerException = ex.InnerException;
                while (innerException != null)
                {
                    Print("Exceção Interna: " + innerException.Message);
                    Print("Rastreamento de Pilha da Exceção Interna: " + innerException.StackTrace);
                    innerException = innerException.InnerException;
                }
            }
        }
    }
}

Resumo

Resumo de IA
E7 BBKG NumSharp Sample is a cTrader robot providing sample code to demonstrate integration of machine learning libraries within the cTrader environment. It includes examples using .NET packages such as TensorFlow, PyTorch, Keras, NumSharp, and PandasNet. The robot does not execute trades but prints out processed data to illustrate how users can start building AI models for trading analysis.
Key functionalities include:
- Data extraction from market bars (open, high, low, close prices, and tick volumes) over a configurable number of bars.
- Conversion of this data into formats compatible with machine learning workflows, including NumSharp NDArrays and Pandas DataFrames.
- Methods to split data into training and testing sets, and to print these datasets for inspection.
- Three operational modes selectable via parameters: DataSplitPrints, PandasPrints, and NDArrayPrints, each demonstrating different data handling approaches.
This sample code aims to facilitate machine learning development inside cTrader by providing foundational examples of data preparation and manipulation using popular ML libraries in a .NET context.
Perfil de negociação

Avaliações de clientes

0.0
Avaliações: 0
Avaliações de clientes
Ainda não há avaliações para este produto. Já o experimentou? Seja o primeiro a contar a outras pessoas!

Conversa

Perguntas frequentes

AI
Os produtos disponíveis através da cTrader Store, incluindo bots de negociação, indicadores e plugins, são fornecidos por programadores terceiros e são disponibilizados apenas para fins informativos e de acesso técnico. A cTrader Store não é um corretor e não fornece aconselhamento em matéria de investimento, recomendações pessoais ou qualquer garantia de desempenho no futuro.

Mais deste autor

Indicador
E7 Volume Profile, more modern look and feel.
Indicador
Prop
E7 BBKG indicator with 80% plus accuracy used to show both, possible reversal and trend.
Indicador
Polynomial Regression Channel which also reflects the volatility of the underlying asset.
Indicador
E7 Harmonic Structures Basic.
Indicador
E7 Correlation Dashboard.
Indicador
Bollinger
Bollinger Band Cloud, Heiken Ashi, Trend Follower and Parabolic SAR.
Indicador
Indices
Option pricing using the BlackScholes model and the Math.Numerics packages
Indicador
Bollinger
ADXR, KDJ, SineWave, Bollinger Band Volatility and AEOscillator.

Também poderá gostar de

cBot
ATR
BTCUSD
+2
Adquiere su máximo potencial con la versión de paga / Get your full potential with the paid version.
cBot
ATR
Simple and Effective Trading Panel with On-Screen Statistics and Trade Management Options.
cBot
ATR
Aggressive
+5
FREE backtest-only. Reproduce Pegasus Gold's +156.13% in your own cTrader - no grid, no martingale. REAL EDGE.
2.33
Fator de lucro
cBot
AI
Scalp you rich!
cBot
AI
ATR
+5
Professional Gold Trading System - 1-Year Backtest Validation(2025-2026)
20.5%
ROI
1.8
Fator de lucro
cBot
Forex
Scalping
Special H1-Version of UltimateScalper for EUR/GBP ... win rate 100% ... ROI 830%
cBot
Grid Recovery
Ultra Velocity Grid is a professional c Bot for the c Trader platform
1003.9%
ROI
1.22
Fator de lucro
cBot
ATR
Forex
+2
Auto-Breakeven Bot w/ ATR & dual triggers. Works 100% with Risk Reward Guardian. Was Free for early users now -80%
cBot
AI
Forex
+2
Sophisticated GRADIENTE algorithm , performance 11% per day drawdown 4%
cBot
AI
ATR
+7
MR KRABS XAU 🦀🟡 — smart gold grid trading with ATR spacing, tight risk, and basket take-profit. 🎯
cBot
Forex
BTCUSD
Moving Average Target Profit cBot for BTCUSD (Demo & Back testing)
cBot
Forex
NAS100
+5
Session-based trading bot with intelligent trailing stops. Captures Asia range, trades London/NY breakouts
8.86
Fator de lucro
cBot
ATR
EMA
+5
Smart Trading Bot with Rich Management Tools for FOREX PAIRS, NASDAQ, GOLD, OIL
14.4%
ROI
1.38
Fator de lucro
cBot
Trading_stop Plus 🧾 General Description Trading_stop Plus is the complete, enhanced version of the original Trading_sto
cBot
AI
RSI
+5
H1 and L1 BOT — Pure Price Action Automation - NEW VERSION IN PROGRESS...
1.52
Fator de lucro
cBot
Forex
Crypto
+2
EMA Crossover Advanced Bot Smart Trend Trading Robot for cTrader with Daily Confirmation & USD Trailing Stop
cBot
Forex
Crypto
+4
Creates buy limit orders automatically when the market drops.
cBot
Grid Recovery
TheBestBotForXAUUSDSuperProfits DEMO
19.6%
ROI
50
Fator de lucro

Preço

Desde 18/12/2024
2
Vendas
4.26K
Instalações gratuitas