Logo "E7 BBKG NumSharp Sample"
cBot
230 lượt tải
Phiên bản 1.0, Feb 2025
Windows, Mac, Mobile, Web
Ảnh "E7 BBKG NumSharp Sample" được tải lên
Kể từ 18/12/2024
2
Lượt bán
4.1K
Cài đặt miễn phí

Theo yêu cầu của nhiều bạn, chúng tôi hiện đang làm việc chăm chỉ để cung cấp các ví dụ về một số mã và gói học máy của chúng tôi.

TensorFlow, PyTorch, Keras, Numpy, Pandas và nhiều gói .NET khác để bắt đầu bên trong cTrader.

Sứ mệnh của chúng tôi là làm cho Machine Learning trong cTrader trở nên dễ dàng hơn cho mọi người.

Chúc bạn săn tìm vui vẻ!

*** Mã này không giao dịch gì cả (nó chỉ in ra dữ liệu, v.v.). Đây chỉ là mã mẫu về cách bạn có thể bắt đầu tạo các mô hình AI của riêng mình bằng cách sử dụng các gói Machine Learning của chúng tôi.

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

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

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

        [Parameter("Số lượng Bars cần thiết", DefaultValue = 50, MinValue = 1, MaxValue = 10000, Step = 1)]
        public int BarsRequired { get; set; }

        [Parameter("Tên phương pháp", DefaultValue = MethodName.DataSplitPrints)]
        public MethodName Mode { get; set; }
        public enum MethodName
        {
            DataSplitPrints,
            PandasPrints,
            NDArrayPrints
        }
        
        protected override void OnStart()
        {
            // Khởi tạo bất kỳ chỉ báo nào
        }

        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($"Lỗi: {ex.Message}");
                if (ex.InnerException != null)
                {
                    Print($"Lỗi bên trong: {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;
        }
        
        /// In dữ liệu NumSharp Data Split
        public void DataSplitPrints()
        {
            // Định dạng lại dữ liệu đầu vào để phù hợp với hình dạng đầu vào mong đợi của mô hình
            //var inputShape = new Shape(-1, BarsRequired, 5);
            NDArray inputData = np.array<float>(GetDataSet());
            Print("NDarray đầu vào: " + string.Join(", ", inputData));
            
            // Định dạng lại dữ liệu mục tiêu để phù hợp với hình dạng mục tiêu mong đợi của mô hình
            //var targetShape = new Shape(-1, 5);
            NDArray targetData = np.array<float>(GetTargetDataSet());
            Print("NDarray mục tiêu: " + string.Join(", ", targetData));
            
            // Chia dữ liệu thành tập huấn luyện và kiểm tra
            int testSize = (int)(0.2 * inputData.shape[0]); // 20% cho kiểm tra
            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("Dữ liệu X_train: " + string.Join(", ", x_train));
            Print("Dữ liệu X_test: " + string.Join(", ", x_test));
            Print("Dữ liệu Y_train: " + string.Join(", ", y_train));
            Print("Dữ liệu Y_test: " + string.Join(", ", y_test));
        }
        
        /// In dữ liệu PandasNet
        public void PandasPrints()
        {
            // Chuyển đổi float[,] thành 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()));
            }
            
            // Tạo DataFrames
            DataFrame inputDataFrame = new DataFrame(inputSeriesList);
            DataFrame targetDataFrame = new DataFrame(targetSeriesList);
            
            Print("DataFrame đầu vào: " + inputDataFrame);
            Print("DataFrame mục tiêu: " + targetDataFrame);
            
            //Print("Input DataFrame: " + string.Join(", ", inputDataFrame));
            //Print("Target DataFrame: " + string.Join(", ", targetDataFrame));
        }
        
        /// In dữ liệu NumSharp NDArray đơn giản
        public void NDArrayPrints()
        {
            if (Bars.ClosePrices.Count < BarsRequired)
                return;

            try
            {
                // Gọi dữ liệu đầu vào float[,]
                float[,] inputData = GetDataSet();

                // Chuyển đổi sang NDArray và định dạng lại thành (BarsRequired, 5)
                NDArray inputNDArray = np.array(inputData);   // NumSharp
                Print("Dữ liệu NumSharp NDarray đầu vào : " + string.Join(", ", inputNDArray));
                Print("Hình dạng NumSharp NDarray đầu vào: " + string.Join(", ", inputNDArray.shape));
                
                int expectedLength = BarsRequired * 5;
                Print($"Độ dài NumSharp NDarray mong đợi: {expectedLength}");
                Print($"Kích thước NumSharp NDarray đầu vào: {inputNDArray.size}");

                if (inputNDArray.size != expectedLength)
                {
                    Print($"Không khớp độ dài: Độ dài mong đợi {expectedLength}, nhưng nhận được kích thước {inputNDArray.size}");
                    return;
                }
            }
            catch (Exception ex)
            {
                Print("Ngoại lệ: " + ex.Message);
                Print("Dấu vết ngăn xếp: " + ex.StackTrace);

                Exception innerException = ex.InnerException;
                while (innerException != null)
                {
                    Print("Ngoại lệ bên trong: " + innerException.Message);
                    Print("Dấu vết ngăn xếp ngoại lệ bên trong: " + innerException.StackTrace);
                    innerException = innerException.InnerException;
                }
            }
        }
    }
}

Hồ sơ giao dịch
0.0
Đánh giá: 0
Đánh giá của khách hàng
Sản phẩm này chưa có đánh giá nào. Bạn đã dùng thử chưa? Hãy là người đầu tiên chia sẻ với mọi người!
AI
Các sản phẩm có sẵn trên cTrader Store, bao gồm bot giao dịch, chỉ báo và plugin, được cung cấp bởi các nhà phát triển bên thứ ba và chỉ nhằm mục đích cung cấp thông tin và tiếp cận kỹ thuật. cTrader Store không phải là nhà môi giới và không cung cấp lời khuyên đầu tư, khuyến nghị cá nhân hay bất kỳ đảm bảo nào về hiệu suất trong tương lai.

Sản phẩm khác của tác giả này

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

Bạn cũng có thể thích

cBot
AI
RSI
+4
Smart Trend Trading Bot, Best Trend Identified, Please try default setting before making any changes
cBot
Channel
SL Manager
+4
cTrader to Telegram trade notifier with custom message formats, risk alerts, and an on-chart dashboard.
cBot
EMA
SL Manager
+5
Fully automated dual-symbol hedging cBot for cTrader.
20.6%
ROI
8.66
Hệ số lợi nhuận
20%
Mức sụt giảm tối đa
cBot
AI
ATR
+27
TrustGuard - Simple, Smart Account Protection for cTrader
cBot
AI
ATR
+8
A sophisticated cBot that implements a Fair Value Gap (FVG) trading strategy with comprehensive risk management
cBot
Perfectly optimized to trade EURUSD achieving high risk reward. Win rate of over 85%
cBot
RSI
MACD
+3
N.B.: Results with an initial invested capital of 100 euros.
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
Hệ số lợi nhuận
37%
Mức sụt giảm tối đa
cBot
AI
ATR
+27
Review and User Guide: PROP Account Guardian Pro cBot 🛡️
Logo "ORB"
Phổ biến
4.3
(3)
$39
/
$78
cBot
Breakout
Powerfull and Optimized strategy based on the "Opening Range Breakout" on the 15 min chart.
cBot
Key Levels
SL Manager
+4
Multi-symbol dashboard with 3 fixed charts, dynamic position slots ranked by profit, Ratio analysis, MZ phase detection
cBot
SMC
Forex
+11
💎 ICT Silver Bullet Strategy cBot — liquidity sweep & breakout algorithm with risk control.
cBot
Forex
XAUUSD
Low Risk Jesko Trial DAY 15
cBot
RSI
Signal
+3
## **Matrix Gold Resurrection - Professional XAUUSD Trading Algorithm** **🏆 Advanced Gold Trading Bot
cBot
ATR
Prop
+4
🚀 HTF Power 3 (PO3) – Automated ICT AMD Strategy
70.2%
ROI
1.31
Hệ số lợi nhuận
23.13%
Mức sụt giảm tối đa
cBot
AI
ATR
+5
Ai_ScalperPro Max is a sophisticated automated trading robot designed specifically for gold (XAUUSD) trading
100%
ROI
2.44
Hệ số lợi nhuận
25.93%
Mức sụt giảm tối đa
cBot
Prop
Forex
+3
QuantumGuard - EUR/USD - More than 1000% profit per year
cBot
ADX
ATR
+4
Trend-following bot using Ichimoku, ADX and ATR; trades strong trends with strict risk filters.
1.51
Hệ số lợi nhuận
39.61%
Mức sụt giảm tối đa
Kể từ 18/12/2024
2
Lượt bán
4.1K
Cài đặt miễn phí