Hi, is there anyway possible that my cbot draws its indicators that I used as an entry condition, during live trading?
I would like that it draws the emas of the cbot below.
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
//Set time zone to Eastern Standard Time EP9-Best time to trade
[Robot(TimeZone = TimeZones.EasternStandardTime, AccessRights = AccessRights.None)]
public class MACrossTemplate : Robot
{
//Create Parameters EP10-Functions and Parameters
[Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
public double Quantity { get; set; }
[Parameter("TP", DefaultValue = 20)]
public int TP { get; set; }
[Parameter("SL", DefaultValue = 300)]
public int SL { get; set; }
//Create indicator variables
private MovingAverage E4h, Pfast4h, Pslow4h, Acc4h, Crui4h, E1h, Pfast1h, Pslow1h, Acc1h, Crui1h;
private Bars H4bars, H1bars;
protected override void OnStart()
{
//Load indicators on start up
H4bars = MarketData.GetBars(TimeFrame.Hour4);
H1bars = MarketData.GetBars(TimeFrame.Hour);
E4h = Indicators.MovingAverage(H4bars.ClosePrices, 200, MovingAverageType.Exponential);
Pfast4h = Indicators.MovingAverage(H4bars.ClosePrices, 10, MovingAverageType.Exponential);
Pslow4h = Indicators.MovingAverage(H4bars.ClosePrices, 35, MovingAverageType.Exponential);
Acc4h = Indicators.MovingAverage(H4bars.ClosePrices, 20, MovingAverageType.Simple);
Crui4h = Indicators.MovingAverage(H4bars.ClosePrices, 40, MovingAverageType.Simple);
E1h = Indicators.MovingAverage(H1bars.ClosePrices, 800, MovingAverageType.Exponential);
Pfast1h = Indicators.MovingAverage(H1bars.ClosePrices, 10, MovingAverageType.Exponential);
Pslow1h = Indicators.MovingAverage(H1bars.ClosePrices, 35, MovingAverageType.Exponential);
Acc1h = Indicators.MovingAverage(H1bars.ClosePrices, 20, MovingAverageType.Simple);
Crui1h = Indicators.MovingAverage(H1bars.ClosePrices, 40, MovingAverageType.Simple);
}
protected override void OnTick()
{
// Put your core logic here
//Buy
if (Positions.Count == 0)
{
if (Pfast4h.Result.HasCrossedAbove(Pslow4h.Result, 0))
if (Acc4h.Result.HasCrossedAbove(Crui4h.Result, 0))
if (Acc1h.Result.HasCrossedAbove(Crui1h.Result, 0))
if (Acc1h.Result.HasCrossedAbove(Crui1h.Result, 0))
ExecuteMarketOrder(TradeType.Buy, SymbolName, VolumeInUnits, "Buy", SL, TP);
//Sell
else if (Pfast4h.Result.HasCrossedBelow(Pslow4h.Result, 0))
if (Acc4h.Result.HasCrossedBelow(Crui4h.Result, 0))
if (Pfast1h.Result.HasCrossedBelow(Pslow1h.Result, 0))
if (Acc1h.Result.HasCrossedBelow(Crui1h.Result, 0))
ExecuteMarketOrder(TradeType.Sell, SymbolName, VolumeInUnits, "Sell", SL, TP);
}
}
private double VolumeInUnits
{
get { return Symbol.QuantityToVolumeInUnits(Quantity); }
}
}
}