Trading product for E7 BBKG NumSharp Sample cBot AI, image 1
cBot
243 lượt tải
Phiên bản 1.0, Feb 2025
Windows, Mac, Mobile, Web
Trading product for E7 BBKG NumSharp Sample cBot AI, image 2
Kể từ 18/12/2024
2
Lượt bán
4.17K
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
RSI
Signal
+3
## **Matrix Gold Resurrection - Professional XAUUSD Trading Algorithm** **🏆 Advanced Gold Trading Bot
cBot
Grid Recovery
Advanced institutional grid trading for Gold with trend detection, recovery, and reverse trading modes.
1.56
Hệ số lợi nhuận
cBot
Grid Recovery
Advanced Grid Trading System with Institutional Trend Detection
17.3%
ROI
2.72
Hệ số lợi nhuận
cBot
ATR
RSI
+17
The Swiss Army Knife cBot is a multi-tool trading robot that combines 10 of the most popular technical indicators
cBot
EURUSD
Bollinger
Turn $1,000 into $24,000+ 📈 This algorithmic cBot generated 2,300% ROI in under 2 years on EURUSD.
cBot
Conservative
Grid Recovery
Ziggy, an advanced algorithm designed to maximize efficiency and simplify profit control.
cBot
AI
RSI
+5
H1 and L1 BOT — Pure Price Action Automation - NEW VERSION IN PROGRESS...
1.52
Hệ số lợi nhuận
cBot
ATR
Simple and Effective Trading Panel with On-Screen Statistics and Trade Management Options.
cBot
AI Trading
Drawdown Guard
+2
Intelligent Automated Trading (Gold, Forex, commodities)
1.97
Hệ số lợi nhuận
cBot
AI
Forex
+4
Trend Following Strategy with adjustment Risk Management PLEASE ENJOY!!
10.9%
ROI
3.2
Hệ số lợi nhuận
cBot
Forex
BTCUSD
+11
CandlePatternBot — Trade classic candlestick signals with bull/bear bias and SL/TP or next-pattern exits.
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
AI
ATR
+5
No guessing — just confirmed breakouts, smart risk management, and disciplined execution. Less noise. More direction.
28.5%
ROI
4.44
Hệ số lợi nhuận
Logo "ORB Bot"
Phổ biến
4.3
(3)
$39
/
$50
cBot
AI
RSI
+8
ORB cBot: Comprehensive Opening Range Breakout Strategy for XAU/USD
cBot
ATR
Balanced
+5
FREE backtest-only. Reproduce Balanced's +218.3% in your own cTrader - no grid, no martingale. REAL INSTITUTIONAL EDGE.
1.64
Hệ số lợi nhuận
cBot
AI
ATR
+7
MR KRABS XAU 🦀🟡 — smart gold grid trading with ATR spacing, tight risk, and basket take-profit. 🎯
cBot
AI
ATR
+27
A smart trailing-stop tool that protects profits and tightens risk automatically for all your manual trades.
Kể từ 18/12/2024
2
Lượt bán
4.17K
Cài đặt miễn phí