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

По просьбе многих из вас, мы сейчас усердно работаем над предоставлением примеров некоторого нашего кода и пакетов машинного обучения.

TensorFlow, PyTorch, Keras, Numpy, Pandas и многие другие пакеты .NET для начала работы внутри cTrader.

Наша миссия — сделать машинное обучение внутри cTrader проще для всех.

Удачной охоты!

*** Этот код ничего не торгует (он только выводит данные и т.д.). Это просто пример кода, показывающий, как вы можете начать создавать свои собственные модели ИИ, используя наши пакеты машинного обучения.

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

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

        [Parameter("Источник")]
        public DataSeries Source { get; set; }

        [Parameter("Требуемое количество баров", DefaultValue = 50, MinValue = 1, MaxValue = 10000, Step = 1)]
        public int BarsRequired { get; set; }

        [Parameter("Имя метода", DefaultValue = MethodName.DataSplitPrints)]
        public MethodName Mode { get; set; }
        public enum MethodName
        {
            DataSplitPrints,
            PandasPrints,
            NDArrayPrints
        }
        
        protected override void OnStart()
        {
            // Инициализация любых индикаторов
        }

        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($"Ошибка: {ex.Message}");
                if (ex.InnerException != null)
                {
                    Print($"Внутреннее исключение: {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
        public void DataSplitPrints()
        {
            // Изменение формы входных данных для соответствия ожидаемой форме модели
            //var inputShape = new Shape(-1, BarsRequired, 5);
            NDArray inputData = np.array<float>(GetDataSet());
            Print("Входной NDarray: " + string.Join(", ", inputData));
            
            // Изменение формы целевых данных для соответствия ожидаемой форме модели
            //var targetShape = new Shape(-1, 5);
            NDArray targetData = np.array<float>(GetTargetDataSet());
            Print("Целевой NDarray: " + string.Join(", ", targetData));
            
            // Разделение данных на обучающую и тестовую выборки
            int testSize = (int)(0.2 * inputData.shape[0]); // 20% для тестирования
            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: " + string.Join(", ", x_train));
            Print("Данные X_test: " + string.Join(", ", x_test));
            Print("Данные Y_train: " + string.Join(", ", y_train));
            Print("Данные Y_test: " + string.Join(", ", y_test));
        }
        
        /// Выводы PandasNet
        public void PandasPrints()
        {
            // Преобразование float[,] в 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()));
            }
            
            // Создание DataFrame
            DataFrame inputDataFrame = new DataFrame(inputSeriesList);
            DataFrame targetDataFrame = new DataFrame(targetSeriesList);
            
            Print("Входной DataFrame: " + inputDataFrame);
            Print("Целевой DataFrame: " + targetDataFrame);
            
            //Print("Входной DataFrame: " + string.Join(", ", inputDataFrame));
            //Print("Целевой DataFrame: " + string.Join(", ", targetDataFrame));
        }
        
        /// Простые выводы NumSharp NDArrays
        public void NDArrayPrints()
        {
            if (Bars.ClosePrices.Count < BarsRequired)
                return;

            try
            {
                // Вызов ваших входных данных float[,]
                float[,] inputData = GetDataSet();

                // Преобразование в NDArray и изменение формы на (BarsRequired, 5)
                NDArray inputNDArray = np.array(inputData);   // NumSharp
                Print("Входные данные NumSharp NDarray : " + string.Join(", ", inputNDArray));
                Print("Форма входного NumSharp NDarray: " + string.Join(", ", inputNDArray.shape));
                
                int expectedLength = BarsRequired * 5;
                Print($"Ожидаемая длина NumSharp NDarray: {expectedLength}");
                Print($"Размер входного NumSharp NDarray: {inputNDArray.size}");

                if (inputNDArray.size != expectedLength)
                {
                    Print($"Несоответствие длины: ожидалась длина {expectedLength}, но получен размер {inputNDArray.size}");
                    return;
                }
            }
            catch (Exception ex)
            {
                Print("Исключение: " + ex.Message);
                Print("Стек вызовов: " + ex.StackTrace);

                Exception innerException = ex.InnerException;
                while (innerException != null)
                {
                    Print("Внутреннее исключение: " + innerException.Message);
                    Print("Стек вызовов внутреннего исключения: " + innerException.StackTrace);
                    innerException = innerException.InnerException;
                }
            }
        }
    }
}

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

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

Индикатор
E7 Volume Profile, more modern look and feel.
Индикатор
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.
Индикатор
E7 Correlation Dashboard.
Индикатор
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
ATR
+27
TrustGuard - Simple, Smart Account Protection for cTrader
сиБот
EURUSD
GBPUSD
+1
BEST PRO XAUUSD TRIAL DAY15
сиБот
RSI
MACD
+9
EURGBP MARKET ORDER TRADING ALGORITHM
2.41
Фактор прибыли
13.69%
Макс. просадка
сиБот
Prop
Forex
+9
Forex Wizard
сиБот
Prop
Forex
+2
Ultimate Trade Panel - a powerful, on-chart trading tool designed for precision and efficiency.
0.01
Фактор прибыли
0%
Макс. просадка
сиБот
Perfectly optimized to trade EURUSD achieving high risk reward. Win rate of over 85%
сиБот
AI
SMC
+18
Review and Parameter Guide for the "Moving Average" cBot
сиБот
Channel
SL Manager
+4
cTrader to Telegram trade notifier with custom message formats, risk alerts, and an on-chart dashboard.
сиБот
AI
ATR
+27
The Prop-Ready Bot The Definitive Automaton for Challenges 🛡️ V2.0
сиБот
Prop
Forex
+2
Aggressive Gold Bot: BB+MACD strategy. Smart ATR-based risk management. Professional on-chart trading dashboard
1.32
Фактор прибыли
12.98%
Макс. просадка
сиБот
ATR
Grid
+3
QuantumLimit - XAUUSD/BTCUSD - up to 100 000 %+ cumulative ROI
сиБот
AI
ATR
+8
AI Trading that you can adjust to your own strategy, this AI will do a work for you, Adjust to suit your own strategy
сиБот
RSI
Aggressive
automates entries based on the RSX indicator — a smoothed, low-lag variant of the classic RSI.
1.67
Фактор прибыли
10.25%
Макс. просадка
сиБот
Key Levels
SL Manager
+4
RISK REWARD VISUALIZER Part of the MACRO ZERO Suite Visualize your active positions, pending orders, and cl
сиБот
EMA
SL Manager
+5
Fully automated dual-symbol hedging cBot for cTrader.
20.6%
ROI
8.66
Фактор прибыли
20%
Макс. просадка
сиБот
A risk-managed trading bot that automatically closes all positions when a daily profit target is hit or a maximum daily
сиБот
Forex
EURUSD
+3
This Version only supports Demo accounts or Backtest Please Download the pro version at https://ctrader.com/products/312
Логотип продукта "EngulfingCoreBotPro"
Популярный
3.6
(3)
$39
/
$50
сиБот
XAUUSD
Engulfing Pattern cBot Pro: Smart candlestick trading with filters, risk control & daily protection.
231.4%
ROI
1.32
Фактор прибыли
12.87%
Макс. просадка
С 18/12/2024
2
Продажи
4.11K
Бесплатные установки