Logótipo de "E7 BBKG NumSharp Sample"
cBot
229 transferências
Versão 1.0, Feb 2025
Windows, Mac, Mobile, Web
Imagem carregada de "E7 BBKG NumSharp Sample"
Desde 18/12/2024
2
Vendas
4.1K
Instalações gratuitas

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;
                }
            }
        }
    }
}

Perfil de negociação
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!
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
AI
RSI
+4
Please Try and ENJOY !!! Try default setting before making any changes Please!!
cBot
ADX
ATR
+4
Trend-following bot using Ichimoku, ADX and ATR; trades strong trends with strict risk filters.
1.51
Fator de lucro
39.61%
Decréscimo máx.
cBot
Volume
Imbalance
+3
VOLUME IMBALANCE STRIP A focused multi-timeframe imbalance visualization tool for cTrader.
cBot
EURUSD
Bollinger
Turn $1,000 into $24,000+ 📈 This algorithmic cBot generated 2,300% ROI in under 2 years on EURUSD.
cBot
RSI
Aggressive
automates entries based on the RSX indicator — a smoothed, low-lag variant of the classic RSI.
1.67
Fator de lucro
10.25%
Decréscimo máx.
cBot
ATR
RSI
+6
Trend-following with deep pullbacks and advanced risk/position management.
cBot
Prop
'No Weekend Holding' makes sure that your trades are closed before the weekend and opens them again after the weekend.
cBot
AI
ATR
+8
A sophisticated cBot that implements a Fair Value Gap (FVG) trading strategy with comprehensive risk management
cBot
USDJPY
Scalping
ViperScalper by EA - no time limit, but limited to 0.50 net profit per position
cBot
AI
ATR
+5
Ai_ScalperPro Max is a sophisticated automated trading robot designed specifically for gold (XAUUSD) trading
100%
ROI
2.44
Fator de lucro
25.93%
Decréscimo máx.
cBot
ATR
RSI
+23
🚀 N.B.: Results with an initial invested capital of 100 euros.🚀 📌 Tested on US2000 with Accurate Prices
cBot
ATR
Simple and Effective Trading Panel with On-Screen Statistics and Trade Management Options.
cBot
XAUUSD
Breakout
+2
Fractal breakout bot for XAUUSD. Auto lot sizing, trailing stop & daily profit target. Built for gold trading.
30.4%
ROI
3.83
Fator de lucro
31.87%
Decréscimo máx.
cBot
XAU/USD SWING BOT
cBot
Key Levels
SL Manager
+4
RISK REWARD VISUALIZER Part of the MACRO ZERO Suite Visualize your active positions, pending orders, and cl
cBot
ATR
RSI
+5
Shift from “Price Chasing” to “Price Trapping” using Limit Orders and a Volatility-Based Calculation System
cBot
Prop Firm Fit
Stop Loss (SL) Manager
+1
HTS Strategy Tester - Advanced Multi-Timeframe Trend & Pullback Trading System H1/m1 & H4/m5 WWS 33/144 Start from 100$
90.1%
ROI
2.92
Fator de lucro
37%
Decréscimo máx.
cBot
Prop
Forex
+3
Trade XAUUSD at lightning speed using Stream Deck. One-tap execution for entries, partial closes, break-even, TP & SL.
100%
ROI
2
Fator de lucro
5%
Decréscimo máx.
Desde 18/12/2024
2
Vendas
4.1K
Instalações gratuitas