Just tried a simple strategy and this bot and is not working. I've attached the conditions as image.
Also i did get the following code generated:
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
/*
This code was created using the Algo Strategy Building Tool by ClickAlgo Limited
https://clickalgo.com/strategy-builder
This cBot does not guarantee any particular outcome or
profit of any kind. Use it at your own risk.
Created: 17.02.2024
Name: Jack
*/
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class AlgoBuilderBot : Robot
{
// user parameter settings
// Indicator settings for bullish signals
[Parameter("Timeframe", DefaultValue = "m1", Group = "Fast EMA Buy #1")]
public TimeFrame EmaTimeFrameFastBuy1 { get; set; }
[Parameter("EMA Periods", DefaultValue = 13, Group = "Fast EMA Buy #1")]
public int EmaFastPeriodsBuy1 { get; set; }
[Parameter("Timeframe", DefaultValue = "m1", Group = "Slow EMA Buy #1")]
public TimeFrame EmaTimeFrameSlowBuy1 { get; set; }
[Parameter("EMA Periods", DefaultValue = 50, Group = "Slow EMA Buy #1")]
public int EmaSlowPeriodsBuy1 { get; set; }
// Indicator settings for bearish signals
[Parameter("Timeframe", DefaultValue = "m1", Group = "Fast EMA Sell #1")]
public TimeFrame EmaTimeFrameFastSell1 { get; set; }
[Parameter("EMA Periods", DefaultValue = 13, Group = "Fast EMA Sell #1")]
public int EmaFastPeriodsSell1 { get; set; }
[Parameter("Timeframe", DefaultValue = "m1", Group = "Slow EMA Sell #1")]
public TimeFrame EmaTimeFrameSlowSell1 { get; set; }
[Parameter("EMA Periods", DefaultValue = 50, Group = "Slow EMA Sell #1")]
public int EmaSlowPeriodsSell1 { get; set; }
// declaring the standard bullish indicators
private ExponentialMovingAverage _fastEMA_Buy1;
private ExponentialMovingAverage _slowEMA_Buy1;
// declaring the standard bearish indicators
private ExponentialMovingAverage _fastEMA_Sell1;
private ExponentialMovingAverage _slowEMA_Sell1;
// declaring the market data variables for bullish signals.
private Bars _fastEMABars_Buy1;
private Bars _slowEMABars_Buy1;
// declaring the market data variables for bearish signals.
private Bars _fastEMABars_Sell1;
private Bars _slowEMABars_Sell1;
// Private fields.
private string StrategyName { get; set; }
// makes sure only 1 trade opens per signal
bool IsBullish { get; set; }
bool IsBearish { get; set; }
// Initialise variables when the cBot starts.
protected override void OnStart()
{
StrategyName = "Jack";
// constructing the market data for the bullish indicators
_fastEMABars_Buy1 = MarketData.GetBars(EmaTimeFrameFastBuy1);
_slowEMABars_Buy1 = MarketData.GetBars(EmaTimeFrameSlowBuy1);
// constructing the market data for the bearish indicators
_fastEMABars_Sell1 = MarketData.GetBars(EmaTimeFrameFastSell1);
_slowEMABars_Sell1 = MarketData.GetBars(EmaTimeFrameSlowSell1);
// constructing the BULLISH indicators
_fastEMA_Buy1 = Indicators.ExponentialMovingAverage(_fastEMABars_Buy1.ClosePrices, EmaFastPeriodsBuy1);
_slowEMA_Buy1 = Indicators.ExponentialMovingAverage(_slowEMABars_Buy1.ClosePrices, EmaSlowPeriodsBuy1);
// constructing the BEARISH indicators
_fastEMA_Sell1 = Indicators.ExponentialMovingAverage(_fastEMABars_Sell1.ClosePrices, EmaFastPeriodsSell1);
_slowEMA_Sell1 = Indicators.ExponentialMovingAverage(_slowEMABars_Sell1.ClosePrices, EmaSlowPeriodsSell1);
}
// The onTick method is called on each price change.
protected override void OnTick()
{
}
// this method is called when the candle closes and is used to check the trade signals, execute trades and send alerts.
protected override void OnBarClosed()
{
TradeRulesBullish();
TradeRulesBearish();
}
// parent method to check rules and open bullish trade or send signal.
private void TradeRulesBullish()
{
// flag to open a trade if all rules true.
bool OpenBuyTrade = false;
if (IsBullishSignal())
{
OpenBuyTrade = true;
}
if (OpenBuyTrade)
{
if (!IsBullish)
{
// no open buy trades logic
}
IsBullish = true;
}
else
{
IsBullish = false;
}
}
// parent method to check rules and open bearish trade or send signal.
private void TradeRulesBearish()
{
// flag to open a trade if all rules true.
bool OpenSellTrade = false;
if (IsBearishSignal())
{
OpenSellTrade = true;
}
if (OpenSellTrade)
{
if (!IsBearish)
{
// no open buy trades logic
}
IsBearish = true;
}
else
{
IsBearish = false;
}
}
// returns true if all signals are bullish
private bool IsBullishSignal()
{
if (_fastEMA_Buy1.Result.LastValue < _slowEMA_Buy1.Result.LastValue)
{
return false;
}
return true;
}
// returns true if all signals are bearish
private bool IsBearishSignal()
{
if (_fastEMA_Sell1.Result.LastValue > _slowEMA_Sell1.Result.LastValue)
{
return false;
}
return true;
}
}
}