I am trying but with no result of the goal I want
Thank you Mike
using cAlgo.API;
using cAlgo.API.Internals;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class NewcBot : Robot
{
[Parameter("Renko Pips", DefaultValue = 100, MinValue = 0.1)]
public double RenkoPips { get; set; }
[Parameter("Number Of Bricks", DefaultValue = 1000, MinValue = 0.1)]
public int BricksToShow { get; set; }
[Parameter("Zoom Level", DefaultValue = 3.5, MinValue = 0.1)]
public double ZoomLevel { get; set; }
[Parameter("Bullish Color", DefaultValue = "Green")]
public string ColorBull { get; set; }
[Parameter("Bearish Color", DefaultValue = "Red")]
public string ColorBear { get; set; }
[Parameter("Quantity", DefaultValue = 1, MinValue = 0.1)]
public int Quantity { get; set; }
[Output("Open", LineColor = "Transparent", Thickness = 1, PlotType = PlotType.Points)]
public IndicatorDataSeries Open { get; set; }
[Output("High", LineColor = "Transparent", Thickness = 1, PlotType = PlotType.Points)]
public IndicatorDataSeries High { get; set; }
[Output("Low", LineColor = "Transparent", Thickness = 1, PlotType = PlotType.Points)]
public IndicatorDataSeries Low { get; set; }
[Output("Close", LineColor = "Transparent", Thickness = 1, PlotType = PlotType.Points)]
public IndicatorDataSeries Close { get; set; }
[Parameter("Stop Loss", Group = "Protection", DefaultValue = 250, MinValue = 1)]
public int StopLoss { get; set; }
[Parameter("Take Profit", Group = "Protection", DefaultValue = 500, MinValue = 1)]
public int TakeProfit { get; set; }
private Renko renko;
protected override void OnStart()
{
object[] parameterValues =
{
RenkoPips,
BricksToShow,
ZoomLevel,
ColorBull,
ColorBear
};
Print("start");
renko = Indicators.GetIndicator<Renko>(parameterValues);
}
protected override void OnTick()
{
double renkoPips = RenkoPips * Symbol.PipSize;
bool isLastBrickBullish = renko.Open.Last(0) < renko.Close.Last(0);
var buyPosition = Positions.Find("Renko", SymbolName, TradeType.Buy);
var sellPosition = Positions.Find("Renko", SymbolName, TradeType.Sell);
if (buyPosition != null)
{
if (buyPosition.Pips < -2 * RenkoPips)
{
Print("buyPositionpips=" + buyPosition.Pips);
Print("renkoPips=" + renkoPips + "cbot Symbol.Bid=" + Symbol.Bid + " Symbol.Ask=" + Symbol.Ask);
Print("renko.Open.LastValue=" + renko.Open.LastValue + " renko.Close.LastValue=" + renko.Close.LastValue);
Print("difference Symbol.Bid - renko.Open.LastValue= " + (Symbol.Bid - renko.Open.LastValue));
Print("difference Symbol.Bid - renko.Close.LastValue= " + (Symbol.Bid - renko.Close.LastValue));
Print("difference Symbol.Bid - renko.Close.LastValue= " + (Symbol.Ask - renko.Open.LastValue));
Print("difference Symbol.Bid - renko.Close.LastValue= " + (Symbol.Ask - renko.Close.LastValue));
}
}
if (sellPosition != null)
{
if (sellPosition.Pips < -2 * RenkoPips || sellPosition.Id == 11)
{
Print("sellPositionpips=" + sellPosition.Pips);
Print("renkoPips=" + renkoPips + "cbot Symbol.Bid=" + Symbol.Bid + " Symbol.Ask=" + Symbol.Ask);
Print("renko.Open.LastValue=" + renko.Open.LastValue + " renko.Close.LastValue=" + renko.Close.LastValue);
Print("difference Symbol.Bid - renko.Open.LastValue= " + (Symbol.Bid - renko.Open.LastValue));
Print("difference Symbol.Bid - renko.Close.LastValue= " + (Symbol.Bid - renko.Close.LastValue));
Print("difference Symbol.Bid - renko.Close.LastValue= " + (Symbol.Ask - renko.Open.LastValue));
Print("difference Symbol.Bid - renko.Close.LastValue= " + (Symbol.Ask - renko.Close.LastValue));
}
}
if (isLastBrickBullish && buyPosition == null)
{
if (sellPosition != null)
ClosePosition(sellPosition);
var result = ExecuteMarketOrder(TradeType.Buy, SymbolName, Quantity, "Renko", StopLoss, TakeProfit);
}
else if (!isLastBrickBullish && sellPosition == null)
{
if (buyPosition != null)
ClosePosition(buyPosition);
var result = ExecuteMarketOrder(TradeType.Sell, SymbolName, renkoPips, "Renko", StopLoss, TakeProfit);
if (result.Error == ErrorCode.NoMoney)
Stop();
}
}
}
}
``