Topics
Replies
suradi
21 Jan 2018, 13:17
RE:
Thank you! This should get me started
Panagiotis Charalampous said:
Hi Surady,
See below a very simple example on how to calculate your average equity with samples taken on each bar change.
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class AverageEquity : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } private double _equity; private double _periodCount; protected override void OnStart() { ExecuteMarketOrder(TradeType.Buy, Symbol, 10000); } protected override void OnBar() { _equity += Account.Equity; _periodCount++; Print("Average Equity:" + (_equity / _periodCount)); } protected override void OnStop() { // Put your deinitialization logic here } } }If you need something more complicated or any professional help in developing your cBot, you can post a Job or contact a professional Consultant.
Best Regards,
Panagiotis
suradi
23 Feb 2017, 13:06
( Updated at: 21 Dec 2023, 09:20 )
RE:
trend_meanreversion said:
This week was definitely tough for strategy but despite having drawdowns , it came victorious !!
Target hit for the week already ( 500$ or 10% ) :)
Next week or probably next , i am going live .
Looks great trend. Will you be posting a copy of your martingale cbot so we can test it out ? :)

suradi
06 Feb 2018, 12:31
This should get you started with perceptrons :)
private double perceptron1() { int[,] input = new int[,] { { 1, 0 }, { 1, 1 }, { 0, 1 }, { 0, 0 } }; int[] outputs = { 0, 1, 0, 0 }; Random r = new Random(); double[] weights = { r.NextDouble(), r.NextDouble(), r.NextDouble() }; double learningRate = 500; double totalError = 1; int last = MarketSeries.Close.Count - 1; while (totalError > 0.2) { totalError = 0; for (int i = 0; i < 4; i++) { int output = calculateOutput1(input[i, 0], input[i, 1], weights); int error = outputs[i] - output; weights[0] += learningRate * error * input[i, 0]; weights[1] += learningRate * error * input[i, 1]; weights[2] += learningRate * error * 1; totalError += Math.Abs(error); } } //macd.Histogram double a1 = macd.Histogram[last - 1]; double a2 = macd.Histogram[last - 1 - 1]; double a3 = macd.Histogram[last - 1 - 1 * 2]; double a4 = macd.Histogram[last - 1 - 1 * 3]; double sum = (weights[0] * a1) + (weights[1] * a2) + (weights[0] * a3) + (weights[1] * a4); return (sum >= 0) ? 1 : 0; } private static int calculateOutput1(double a1, double a2, double[] weights) { double sum = a1 * weights[0] + a2 * weights[1] + 1 * weights[2]; return (sum >= 0) ? 1 : 0; }