E7 BBKG NumSharp Sample
"E7 BBKG NumSharp Sample" 로고
03/09/2025
80
Desktop, Mobile, Web
"E7 BBKG NumSharp Sample" 업로드된 이미지

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
고객 리뷰
이 상품에 대한 리뷰가 아직 없습니다. 이미 사용해 보셨나요? 다른 사람들에게 가장 먼저 소개해 주세요!
이 작성자의 상품 더 보기
E7 Polynomial Regression Channel
Polynomial Regression Channel which also reflects the volatility of the underlying asset.
지표
Prop
E7 BBKG Indicator
E7 BBKG indicator with 80% plus accuracy used to show both, possible reversal and trend.
최고 평점
무료
E7 Volume Profile
E7 Volume Profile, more modern look and feel.
E7 Harmonic Structures Basic
E7 Harmonic Structures Basic.
E7 Correlation Dashboard
E7 Correlation Dashboard.
지표
Indices
E7 BlackScholes Model
Option pricing using the BlackScholes model and the Math.Numerics packages
지표
Bollinger
E7 Indicators Free Overlays
Bollinger Band Cloud, Heiken Ashi, Trend Follower and Parabolic SAR.
지표
Bollinger
E7 Indicators Free Studies
ADXR, KDJ, SineWave, Bollinger Band Volatility and AEOscillator.
E7 cTrader User ID
cTrader ID
좋아하실 만한 다른 항목
cBot
Signal
Create Your Custom Candle Pattern with AlgoBuilderX
Create your own custom candlestick patterns with AlgoBuilderX, or choose from a variety of predefined pattern!
cBot
Commodities
MACD
SparrowBot-FreeTrial-V2
This bot can automatically generate buy and sell orders based on three specific Fixed bugs
cBot
Forex
EURUSD
Trend Algo Expiry 17-10-2025_noSourceCode
Trend Algo Expiry 17-10-2025
SmartBot-Hand Trade Assistant_Premium
cBot : Hand Trade Assistant
DASHBOT
DASHBOT muestra en tiempo real el Spread, Lote, Comisión, Trailing Stop sugerido y Ruido de mercado en pips.
cBot
Stocks
Commodities
Forex
Resolver Range Pro 2.3
Resolver PRO 2.3 Bot,Sophisticated, Perfect algorithm! Daily ROI 5 to 24%.Maximum drawdown 4%.
cBot
Forex
Supertrend
Signal
+1
[Fx4U] GBPUSD - Price Action
Bot is based on Price Action strategy to open & manage orders. It is effective capital management and high profitability
cBot
RSI
Daily Trading Strategy (Made with AlgoBuilderX)
This day trading strategy uses RSI and ADX with 4 TP levels, break-even, and customizable position management.
cBot
Breakout
Prop
Commodities
+4
Quantum King
**Quantum King : – Precision Trading for Forex{GBPUSD, EURUSD}, Gold & Oil** The **Quantum King**
EU 4H macd trend strategy
// EUR/USD - 4H TIMEFRAME // 5 YEARS BACKTEST, PROFIT 570 USD, DRAWDOWN MAX 118 USD
IBSBot
Buy-only IBS bot for indices on Daily timeframe. Enters near lows, exits near highs. No noise, just clean reversion.
EURCAD 30m
FUNCTNIONG EURCAD cBOT LIVE TRADING, CUSTOMISABLE AND PROFITABLE
cBot
Indices
RSI
Commodities
+3
WTI ADR +MACD + ADR+ ADMIR + RSI TF 1 Min Many more
N.B.: Results with an initial invested capital of 100 euros.
cBot
Grid
Prop
XAUUSD
+3
Maya Gold Grid ATR
🌞 Smart Gold Grid. ATR Precision. +35% in 30 Days🌞
cBot
Grid
RSI
Martingale
+2
DragonMoneyForexNet6Demo
Demo version of https://ctrader.com/products/298
cBot
XAUUSD
IBC_Marting
IBC Martin Strategy - IBC马丁策略
cBot
NZDUSD
XAUUSD
Breakout
+10
ICT Silver Bullet Strategy cBot
💎 ICT Silver Bullet Strategy cBot — liquidity sweep & breakout algorithm with risk control.
cBot
Indices
Commodities
Forex
+5
TrendFibonacciBotDemo
The Free for demo account of bot https://ctrader.com/products/1893