RE: can you please post the Ichimoku cloud breakout Bot code
daemon said:
Hi This is how to open a long position. The rest of the code for the short is similar. You can also find examples on trailing stop and break even here on the forum.
I used the Ichimoku Cloud from here.
/*
* that enters a long position if:
The last candle closed above the kumo (cloud)
But only if:
It opened inside or on the opposite side of the kumo and
It is currently no more than 30 pips away from the kumo.
(Opposite requirements for a short position).
*/
using cAlgo.API;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC)]
public class IchimokouBot : Robot
{
private IchimokuCloud ichimoku;
[Parameter(DefaultValue = 9)]
public int periodFast { get; set; }
[Parameter(DefaultValue = 26)]
public int periodMedium { get; set; }
[Parameter(DefaultValue = 52)]
public int periodSlow { get; set; }
[Parameter(DefaultValue = 26)]
public int DisplacementCloud { get; set; }
[Parameter(DefaultValue = "MyLabel")]
public string MyLabel { get; set; }
[Parameter(DefaultValue = 10000)]
public int Volume { get; set; }
[Parameter("Stop Loss", DefaultValue = 25, MinValue = 0, MaxValue = 100)]
public int StopLossPips { get; set; }
[Parameter("Take Profit", DefaultValue = 20, MinValue = 0, MaxValue = 100)]
public int TakeProfitPips { get; set; }
protected override void OnStart()
{
ichimoku = Indicators.GetIndicator(periodFast, periodMedium, periodSlow, DisplacementCloud);
}
protected override void OnBar()
{
var closedAbove = MarketSeries.Close.Last(1) > ichimoku.SenkouSpanA.Last(1);
var openedInsideKumo = MarketSeries.Open.Last(1) <= ichimoku.SenkouSpanA.Last(1) &&
MarketSeries.Open.Last(1) >= ichimoku.SenkouSpanB.Last(1);
var distanceFromKumo = (MarketSeries.Close.LastValue - ichimoku.SenkouSpanA.LastValue)/Symbol.PipSize;
if (closedAbove && openedInsideKumo && distanceFromKumo <= 30)
ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, MyLabel, StopLossPips, TakeProfitPips);
}
}
}
abrammankheli
20 May 2021, 09:14
RE: can you please post the Ichimoku cloud breakout Bot code
daemon said:
@abrammankheli