Логотип продукта "E7 BBKG NumSharp Sample"
сиБот
217 скачивания
Версия 1.0, Feb 2025
Windows, Mac, Mobile, Web
Загруженное изображение продукта "E7 BBKG NumSharp Sample"
С 18/12/2024
2
Продажи
4K
Бесплатные установки

As requested by many of you, we are now working hard to provide examples of some of our machine learning code and packages.

TensorFlow, PyTorch, Keras, Numpy, Pandas and many more .NET packages to get going inside of cTrader.

Our mission is to make Machine Learning inside cTrader easier for everyone.

Happy hunting!

*** This code does not trade anything (it only prints out data etc). It is simply sample code of how you can start creating your own AI models using our Machine Learning packages.

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

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()
        {
            // Initialize any indicators
        }

        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($"Error: {ex.Message}");
                if (ex.InnerException != null)
                {
                    Print($"Inner Exception: {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;
        }
        
        /// NumSharp Data Split Prints
        public void DataSplitPrints()
        {
            // Reshape input data to match the model's expected input shape
            //var inputShape = new Shape(-1, BarsRequired, 5);
            NDArray inputData = np.array<float>(GetDataSet());
            Print("Input NDarray: " + string.Join(", ", inputData));
            
            // Reshape target data to match the target shape expected by the model
            //var targetShape = new Shape(-1, 5);
            NDArray targetData = np.array<float>(GetTargetDataSet());
            Print("Target NDarray: " + string.Join(", ", targetData));
            
            // Split data into training and test sets
            int testSize = (int)(0.2 * inputData.shape[0]); // 20% for testing
            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("X_train data: " + string.Join(", ", x_train));
            Print("X_test data: " + string.Join(", ", x_test));
            Print("Y_train data: " + string.Join(", ", y_train));
            Print("Y_test data: " + string.Join(", ", y_test));
        }
        
        /// PandasNet Prints
        public void PandasPrints()
        {
            // Convert float[,] to 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()));
            }
            
            // Create DataFrames
            DataFrame inputDataFrame = new DataFrame(inputSeriesList);
            DataFrame targetDataFrame = new DataFrame(targetSeriesList);
            
            Print("Input DataFrame: " + inputDataFrame);
            Print("Target DataFrame: " + targetDataFrame);
            
            //Print("Input DataFrame: " + string.Join(", ", inputDataFrame));
            //Print("Target DataFrame: " + string.Join(", ", targetDataFrame));
        }
        
        /// Simple NumSharp NDArrays Prints
        public void NDArrayPrints()
        {
            if (Bars.ClosePrices.Count < BarsRequired)
                return;

            try
            {
                // Calling your Input Data float[,]
                float[,] inputData = GetDataSet();

                // Convert to NDArray and reshape to (BarsRequired, 5)
                NDArray inputNDArray = np.array(inputData);   // NumSharp
                Print("Input NumSharp NDarray Data : " + string.Join(", ", inputNDArray));
                Print("Input NumSharp NDarray Shape: " + string.Join(", ", inputNDArray.shape));
                
                int expectedLength = BarsRequired * 5;
                Print($"Expected NumSharp NDarray Length: {expectedLength}");
                Print($"Input NumSharp NDarray Size: {inputNDArray.size}");

                if (inputNDArray.size != expectedLength)
                {
                    Print($"Length MisMatch: Expected Length {expectedLength}, but got Size {inputNDArray.size}");
                    return;
                }
            }
            catch (Exception ex)
            {
                Print("Exception: " + ex.Message);
                Print("StackTrace: " + ex.StackTrace);

                Exception innerException = ex.InnerException;
                while (innerException != null)
                {
                    Print("Inner Exception: " + innerException.Message);
                    Print("Inner Exception StackTrace: " + innerException.StackTrace);
                    innerException = innerException.InnerException;
                }
            }
        }
    }
}

Торговый профиль
0.0
Отзывы: 0
Отзывы покупателей
У этого продукта еще нет отзывов. Уже попробовали его? Поделитесь впечатлениями!
AI
Продукты, доступные в cTrader Store, включая торговых ботов, индикаторы и плагины, предоставляются сторонними разработчиками и доступны исключительно в информационных и технических целях. cTrader Store не является брокером и не предоставляет инвестиционные консультации, персональные рекомендации или какие-либо гарантии будущей доходности.

Больше от этого автора

Логотип продукта "E7 Volume Profile"
Высокий рейтинг
4.6
(3)
Бесплатно
Индикатор
E7 Volume Profile, more modern look and feel.
Логотип продукта "E7 BBKG Indicator"
Популярный
5.0
(2)
$25
/
$50
Индикатор
Prop
E7 BBKG indicator with 80% plus accuracy used to show both, possible reversal and trend.
Индикатор
Polynomial Regression Channel which also reflects the volatility of the underlying asset.
Логотип продукта "E7 Harmonic Structures Basic"
Высокий рейтинг
5.0
(2)
Бесплатно
Индикатор
E7 Harmonic Structures Basic.
Индикатор
E7 Correlation Dashboard.
Логотип продукта "E7 Indicators Free Overlays"
Высокий рейтинг
5.0
(2)
Бесплатно
Индикатор
Bollinger
Bollinger Band Cloud, Heiken Ashi, Trend Follower and Parabolic SAR.
Индикатор
Indices
Option pricing using the BlackScholes model and the Math.Numerics packages
Индикатор
Bollinger
ADXR, KDJ, SineWave, Bollinger Band Volatility and AEOscillator.
Индикатор
cTrader ID

Вам также может понравиться

сиБот
AI
Smart Trading, Powered by AI – Let Algorithms Work for You! ENJOY!
сиБот
Forex
EURUSD
Easy Trade, Just Plug and Play!
сиБот
Grid
EURUSD
+2
EURUSD RE5 PROFITABLE SINCE 2014 # MINIMUMN STARTCAPITAL 150,- EURO
Логотип продукта "SmartBot-Fibonanci-FTMO"
Популярный
4.5
(2)
$39
/
$78
сиБот
RSI
Indices
SALE OFF!!! this innovative bot combines the precision of Fibonacci Retracement, EMA and RSI...
сиБот
GBPUSD
NAS100
+1
King's War Strategy V.1 ( For Trial and Backtest )
сиБот
Balanced
SL Manager
+5
Real-time prop firm challenge tracker with equity curve, drawdown alerts and trade stats. Stay on target.
Логотип продукта "RSI Simple Grid cBot"
Популярный
5.0
(2)
$39
сиБот
AI
ATR
+27
RSI Simple Grid cBot - grid trading strategy with RSI (Relative Strength Index) signals
26.8%
ROI
4.41
Фактор прибыли
0.29%
Макс. просадка
Логотип продукта "StreamDeckHotkeys"
Популярный
4.6
(3)
$49
/
$59
сиБот
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
Фактор прибыли
5%
Макс. просадка
сиБот
AI
RSI
+5
EMACrossoverBot – Smart EMA-Based Trading with Risk Management & Telegram Alerts
9.8%
ROI
2.68
Фактор прибыли
1.97%
Макс. просадка
сиБот
ADX
EMA
+5
Momentum-focused trading system for DJ30 / Dow Jones 30 / US30, designed for controlled exposure and high-quality direct
12.8%
ROI
5.27
Фактор прибыли
6.12%
Макс. просадка
Логотип продукта "PositionManager"
Популярный
5.0
(3)
$39
/
$78
сиБот
Forex
Crypto
+5
Smart position sizing, visual SL/TP lines, risk-based lot calculation, RR display, margin & lot limits, and hotkey trade
сиБот
Prop Firm Fit
Risk Dashboard
+1
Advanced prop firm risk protection and automation suite for cTrader traders.
Логотип продукта "MatrixGridPlus"
Популярный
4.5
(2)
$39
/
$78
сиБот
ATR
RSI
+5
Professional Multi-Strategy Grid Trading Bot
Логотип продукта "AURIX"
Популярный
5.0
(2)
$39
/
$78
сиБот
AI
Grid
+4
Where Algorithmic Precision Meets Gold’s Volatility. AI-Powered Gold Trading Algorithm for cTrader.
Логотип продукта "EMA Crossover Pro"
Популярный
4.0
(2)
$39
/
$40
сиБот
Automatiza tus operaciones con esta estrategia de cruce de medias móviles exponenciales (EMAs). EMA Crossover Pro.
Логотип продукта "AUD NZD 2min TF trades"
Популярный
4.0
(3)
$39
/
$40
сиБот
NZDUSD
// AUD/NZD - 2MIN TIMEFRAME // 5 YEARS BACKTEST, PROFIT 1500 USD, DRAWDOWN ABOUT 50 USD (RISKY TRADES - NO SL)
сиБот
GBPUSD
Indices
- US100 or NDXUSD
Логотип продукта "Moving Average Cbot"
Популярный
4.0
(2)
$39
/
$59
сиБот
AI
SMC
+18
Review and Parameter Guide for the "Moving Average" cBot
С 18/12/2024
2
Продажи
4K
Бесплатные установки