E7 BBKG NumSharp Sample
cBot
259 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.25K
Cài đặt miễn phí

Mô tả

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;
                }
            }
        }
    }
}

Tóm tắt

Tóm tắt AI
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.
Hồ sơ giao dịch

Đánh giá của khách hàng

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!

Thảo luận

Câu hỏi thường gặp

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
Aggressive
automates entries based on the RSX indicator — a smoothed, low-lag variant of the classic RSI.
1.67
Hệ số lợi nhuận
cBot
ATR
EMA
+5
Momentum driven, Compounding. Volatility adaptive EMA BOLLINGER ATR base Strategy
93.4%
ROI
1.31
Hệ số lợi nhuận
cBot
Prop
Forex
+6
PropFirm Forex trader
cBot
A risk-managed trading bot that automatically closes all positions when a daily profit target is hit or a maximum daily
cBot
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
cBot
Fibonacci
Fixed Lot
+5
Trading dashboard for fast order execution, position management, risk controls and automatic Fibonacci levels.
1.52
Hệ số lợi nhuận
cBot
Trading_stop Plus 🧾 General Description Trading_stop Plus is the complete, enhanced version of the original Trading_sto
cBot
AI
ATR
+9
Gold Predict AI – Advanced Predictive Trading for XAUUSD (M15)
cBot
AI
ATR
+9
Trade Smarter, Not Harder – The AI Edge: The Trader's Quantum Leap. Enjoy For FREE
cBot
AI
Forex
+4
A Trend Master AI, Suitable for more advance pro trader with fully customisation and risk control PLEASE ENJOY!!
10.9%
ROI
4
Hệ số lợi nhuận
cBot
ADX
ATR
+5
Ai_GoldScalperPro XAU M15 – Premium Scalping Robot for cTrader
7.9%
ROI
1.92
Hệ số lợi nhuận
cBot
// XAU/USD 1H TIMEFRAME // 5 YEARS BACKTEST, PROFIT 200 USD, DRAWDOWN MAX 37 USD
cBot
AI
ATR
+7
MR KRABS XAU 🦀🟡 — smart gold grid trading with ATR spacing, tight risk, and basket take-profit. 🎯
cBot
Fixed Risk %
Risk/Reward
+5
One-click fixed-risk execution with a built-in daily loss guard. Made for manual traders and prop challenges.
0.01
Hệ số lợi nhuận
cBot
Forex
BTCUSD
+13
Automatically manages Stop Loss and Take Profit using Support & Resistance levels, with intelligent trailing stop protec
cBot
SMA EMA NASSIMI" is a powerful and free cBot designed for cTrader, leveraging SMA (Simple Moving Average) and EMA (Expon
cBot
ATR
RSI
+4
UltimateAI Trading Robot – Smart Trend & Momentum Trader for cTrader
cBot
AI
ATR
+8
Breakout scalping with prop-firm grade equity control.

Giá

Kể từ 18/12/2024
2
Lượt bán
4.25K
Cài đặt miễn phí