E7 BBKG NumSharp Sample
cBot
262 téléchargements
Version 1.0, Feb 2025
Windows, Mac, Mobile, Web
Trading product for E7 BBKG NumSharp Sample cBot AI, image 2
Depuis le 18/12/2024
2
Ventes
4.26K
Installations gratuites

Description

Comme beaucoup d'entre vous l'ont demandé, nous travaillons maintenant dur pour fournir des exemples de certains de nos codes et packages d'apprentissage automatique.

TensorFlow, PyTorch, Keras, Numpy, Pandas et bien d'autres packages .NET pour démarrer dans cTrader.

Notre mission est de rendre l'apprentissage automatique dans cTrader plus facile pour tout le monde.

Bonne chasse !

*** Ce code ne réalise aucun trade (il affiche seulement des données, etc.). C'est simplement un exemple de code montrant comment vous pouvez commencer à créer vos propres modèles d'IA en utilisant nos packages d'apprentissage automatique.

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

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("Version 1.01", DefaultValue = "Version 1.01")]
        public string Version { get; set; }

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

        [Parameter("Bars Required", DefaultValue = 50, MinValue = 1, MaxValue = 10000, Step = 1)]
        public int BarsRequired { get; set; }

        [Parameter("Method Name", DefaultValue = MethodName.DataSplitPrints)]
        public MethodName Mode { get; set; }
        public enum MethodName
        {
            DataSplitPrints,
            PandasPrints,
            NDArrayPrints
        }
        
        protected override void OnStart()
        {
            // Initialiser les indicateurs
        }

        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($"Erreur : {ex.Message}");
                if (ex.InnerException != null)
                {
                    Print($"Exception interne : {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;
        }
        
        /// Impressions de la séparation des données NumSharp
        public void DataSplitPrints()
        {
            // Remodeler les données d'entrée pour correspondre à la forme attendue par le modèle
            //var inputShape = new Shape(-1, BarsRequired, 5);
            NDArray inputData = np.array<float>(GetDataSet());
            Print("NDarray d'entrée : " + string.Join(", ", inputData));
            
            // Remodeler les données cibles pour correspondre à la forme cible attendue par le modèle
            //var targetShape = new Shape(-1, 5);
            NDArray targetData = np.array<float>(GetTargetDataSet());
            Print("NDarray cible : " + string.Join(", ", targetData));
            
            // Diviser les données en ensembles d'entraînement et de test
            int testSize = (int)(0.2 * inputData.shape[0]); // 20 % pour les tests
            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("Données X_train : " + string.Join(", ", x_train));
            Print("Données X_test : " + string.Join(", ", x_test));
            Print("Données Y_train : " + string.Join(", ", y_train));
            Print("Données Y_test : " + string.Join(", ", y_test));
        }
        
        /// Impressions PandasNet
        public void PandasPrints()
        {
            // Convertir float[,] en 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()));
            }
            
            // Créer des DataFrames
            DataFrame inputDataFrame = new DataFrame(inputSeriesList);
            DataFrame targetDataFrame = new DataFrame(targetSeriesList);
            
            Print("DataFrame d'entrée : " + inputDataFrame);
            Print("DataFrame cible : " + targetDataFrame);
            
            //Print("Input DataFrame: " + string.Join(", ", inputDataFrame));
            //Print("Target DataFrame: " + string.Join(", ", targetDataFrame));
        }
        
        /// Impressions simples des NDArrays NumSharp
        public void NDArrayPrints()
        {
            if (Bars.ClosePrices.Count < BarsRequired)
                return;

            try
            {
                // Appel de vos données d'entrée float[,]
                float[,] inputData = GetDataSet();

                // Convertir en NDArray et remodeler en (BarsRequired, 5)
                NDArray inputNDArray = np.array(inputData);   // NumSharp
                Print("Données NDarray NumSharp d'entrée : " + string.Join(", ", inputNDArray));
                Print("Forme NDarray NumSharp d'entrée : " + string.Join(", ", inputNDArray.shape));
                
                int expectedLength = BarsRequired * 5;
                Print($"Longueur NDarray NumSharp attendue : {expectedLength}");
                Print($"Taille NDarray NumSharp d'entrée : {inputNDArray.size}");

                if (inputNDArray.size != expectedLength)
                {
                    Print($"Incohérence de longueur : longueur attendue {expectedLength}, mais taille obtenue {inputNDArray.size}");
                    return;
                }
            }
            catch (Exception ex)
            {
                Print("Exception : " + ex.Message);
                Print("Trace de la pile : " + ex.StackTrace);

                Exception innerException = ex.InnerException;
                while (innerException != null)
                {
                    Print("Exception interne : " + innerException.Message);
                    Print("Trace de la pile de l'exception interne : " + innerException.StackTrace);
                    innerException = innerException.InnerException;
                }
            }
        }
    }
}

Résumé

Résumé 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.
Profil de trading

Avis clients

0.0
Avis : 0
Avis clients
Il n'y a pas encore d'avis sur ce produit. Vous l'avez déjà essayé ? Soyez le premier à en parler aux autres !

Discussion

Questions fréquentes

AI
Les produits disponibles sur cTrader Store, notamment les bots de trading, les indicateurs et les plug-ins, sont fournis par des développeurs tiers et mis à disposition à titre informatif et à des fins d'accès technique uniquement. cTrader Store n'est pas un courtier et ne fournit aucun conseil en investissement, aucune recommandation personnelle ni aucune garantie quant aux performances futures.

Plus de cet auteur

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

Vous pourriez aussi aimer

cBot
Fibonacci
Fixed Lot
+5
Trading dashboard for fast order execution, position management, risk controls and automatic Fibonacci levels.
1.52
Facteur de profit
cBot
Perfectly optimized to trade EURUSD achieving high risk reward. Win rate of over 85%
cBot
Grid Recovery
TheBestBotForXAUUSDSuperProfits DEMO
19.6%
ROI
50
Facteur de profit
cBot
A risk-managed trading bot that automatically closes all positions when a daily profit target is hit or a maximum daily
cBot
ATR
Grid
+4
🌞 Smart Gold Grid. ATR Precision. + 1 800 000% ROI in 6 years backtest 🌞
34.3%
ROI
2.12
Facteur de profit
cBot
Versatile Adaptive System, for Scalper, Long trader, HFT
cBot
Key Levels
Spread Filter
+3
MATRIX INFINITY, See Beyond the Market.
22.3%
ROI
31
Facteur de profit
cBot
NZDUSD
// AUD/NZD - 2MIN TIMEFRAME // 5 YEARS BACKTEST, PROFIT 1500 USD, DRAWDOWN ABOUT 50 USD (RISKY TRADES - NO SL)
cBot
Prop
Forex
+11
Companion executor for TradeCommand: receives orders via LocalStorage, executes trades, and manages plan-driven batches.
cBot
Grid
XAUUSD
+4
GOLD trade Real Accout at https://ctrader.com/products/1728
cBot
Fixed Risk %
Risk/Reward
+3
Total passive trading control. One click Stop Loss and Take Profit. Breakeven and Goal line. Set it. Protect it. Profit.
cBot
Forex
Crypto
+2
EMA Crossover Advanced Bot Smart Trend Trading Robot for cTrader with Daily Confirmation & USD Trailing Stop
cBot
Forex
BTCUSD
+7
Fully functional demo runs until January 31, 2026 with over 100% ROI within 14 days
cBot
AI
RSI
+8
ORB cBot: Comprehensive Opening Range Breakout Strategy for XAU/USD
cBot
ADX
ATR
+5
Ai_GoldScalperPro XAU M15 – Premium Scalping Robot for cTrader
7.9%
ROI
1.92
Facteur de profit
cBot
ATR
EMA
+5
Smart Trading Bot with Rich Management Tools for FOREX PAIRS, NASDAQ, GOLD, OIL
14.4%
ROI
1.38
Facteur de profit
cBot
Trailing Stop
Break & Retest
+4
Smart Trade H4 Breakout Matrix (lower trader, higher accuracy)
3.73
Facteur de profit
cBot
ATR
Grid
+3
QuantumLimit - XAUUSD/BTCUSD - up to 100 000 %+ cumulative ROI

Prix

Depuis le 18/12/2024
2
Ventes
4.26K
Installations gratuites