E7 BBKG NumSharp Sample
cBot
186 التنزيلات
الإصدار 1.0، Feb 2025
Windows, Mac, Mobile, Web
صورة "E7 BBKG NumSharp Sample" المحملة
منذ 18/12/2024
2
المبيعات
3.69K
التثبيتات المجانية

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
تقييمات العملاء
لا توجد تقييمات لهذا المنتج حتى الآن. هل جرَّبته بالفعل؟ كن أول من يخبر الآخرين!
AI
Products available through cTrader Store, including indicators, plugins and cBots, are provided by third-party developers and made available for informational and technical access purposes only. cTrader Store is not a broker and does not provide investment advice, personal recommendations or any guarantee of future performance.

المزيد من هذا المؤلف

شعار "E7 Volume Profile"
الأعلى تقييمًا
4.6
(3)
مجاني
E7 Volume Profile, more modern look and feel.
E7 BBKG indicator with 80% plus accuracy used to show both, possible reversal and trend.
شعار "E7 Polynomial Regression Channel"
الأعلى تقييمًا
4.7
(4)
مجاني
Polynomial Regression Channel which also reflects the volatility of the underlying asset.
شعار "E7 Harmonic Structures Basic"
الأعلى تقييمًا
5.0
(2)
مجاني
E7 Harmonic Structures Basic.
شعار "E7 Indicators Free Overlays"
الأعلى تقييمًا
5.0
(2)
مجاني
مؤشر
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.

قد يعجبك أيضًا

cBot
Indices
Prop
Auto risk management for Apex EOD evaluations. Enforces drawdown, DLL, profit target & max contracts automatically.
شعار "Prop Scalper Gold"
مشهور
نسخة مجانية
$ 49
/
$89
cBot
NAS100
NZDUSD
+25
Premium algorithmic scalping for funded traders. Capture precise breakouts with ironclad risk management across all majo
14%
العائد على الاستثمار
4
عامل الربح
5%
أقصى تراجع
cBot
NAS100
NZDUSD
+26
Review and User Guide: PROP Account Guardian Pro cBot 🛡️
شعار "Petra Oil Breakout"
مشهور
نسخة مجانية
$ 39
/
$60
cBot
Breakout
Prop
+1
✨Petra Oil Breakout - Session Box Precision for WTI & Brent. Up to +136% in 30 Days✨
136%
العائد على الاستثمار
4.35
عامل الربح
13.08%
أقصى تراجع
شعار "StrongBar v1"
مشهور
نسخة مجانية
$ 39
/
$49
cBot
NAS100
NZDUSD
+17
No guessing — just confirmed breakouts, smart risk management, and disciplined execution. Less noise. More direction.
28.5%
العائد على الاستثمار
4.44
عامل الربح
10.41%
أقصى تراجع
شعار "RSI Simple Grid cBot"
نسخة مجانية
$ 39
cBot
NAS100
NZDUSD
+27
RSI Simple Grid cBot - grid trading strategy with RSI (Relative Strength Index) signals
26.8%
العائد على الاستثمار
4.41
عامل الربح
0.29%
أقصى تراجع
شعار "ORFB v2"
نسخة مجانية
$ 50
/
$52
cBot
Breakout
XAUUSD
+4
Automates the Asia range breakout into Fair Value Gaps using ICT concepts. Built-in trailing stop, equity protection. &.
81%
العائد على الاستثمار
1.66
عامل الربح
38.45%
أقصى تراجع
cBot
Prop
Breakout
+1
One-Click, Auto-Risk Entry Tool. FUN and FAST, No Math !
cBot
Indices
XAUUSD
+8
Intelligent negotiations and analysis!
47.3%
العائد على الاستثمار
3
عامل الربح
2%
أقصى تراجع
cBot
Breakout
XAUUSD
+2
Fractal breakout bot for XAUUSD. Auto lot sizing, trailing stop & daily profit target. Built for gold trading.
30.4%
العائد على الاستثمار
3.83
عامل الربح
31.87%
أقصى تراجع
شعار "Linear Close"
نسخة مجانية
$ 39
cBot
VWAP
Breakout
+4
Professional gold scalping bot with smart linear exit logic designed to capture fast XAUUSD market movements.
37%
العائد على الاستثمار
5.19
عامل الربح
64%
أقصى تراجع
شعار "CBOT FTH BTCUSD 5M"
مشهور
نسخة مجانية
$ 44
/
$50
cBot
Crypto
BTCUSD
CBOT FTH BTCUSD M5 is an automated trading bot using trend-following
35.5%
العائد على الاستثمار
1.17
عامل الربح
24.43%
أقصى تراجع
منذ 18/12/2024
2
المبيعات
3.69K
التثبيتات المجانية