Ichimoku cloud breakout Bot
Ichimoku cloud breakout Bot
25 Jan 2014, 22:54
Hi, I'm a complete beginner in programming so please excuse my lack of knowledge.
I am attempting to make a cBot 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).
I know a lot is wrong with this code, I need to be pointed in the right direction and taught some code on how to do a few things. I'm not asking you to make my entire bot although it would have been awfully nice if somebody could do maybe a little bit for me ;)
I need help on:
- The buy and sell signals (and then make it execute the orders)
- Setting SL and TP (make two positions, SL 25 pips on both, TP 20 pips on one, 30 pip trailing stop triggered when @ 30 pip profit on the other)
- Make the SL move to break even when the 20 pip SL is hit on the first trade.
//#reference: ..\Indicators\Ichimoku_cloud2.algo using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC)] public class IchimokuBreakoutBot : Robot { private Ichimoku_cloud2 Ichi; [Parameter("Volume", DefaultValue = 100000)] public int Volume { get; set; } protected override void OnStart() { Ichi = Indicators.GetIndicator<Ichimoku_cloud2>(); } protected override void OnBar() { if (HasCrossedAbove(Ichi.SenkouSpanA, Ichi.SenkouSpanB && MarketSeries.Close > Ichi.SenkouSpanA)) ; { OpenPosition(TradeType.Buy); } }
Replies
Old Account
26 Jan 2014, 01:35
RE:
MrSvensli@hotmail.no *
I would be happy to help you, but i don't have much experience whit Ichimoku so you are going to have to explainit a bit more for me. You can contact me at MrSvesli@hotmail.no if you to.
@Old Account
daemon
27 Jan 2014, 17:49
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); } } }
@daemon
Ancalagon
24 Jul 2014, 21:53
RE:
this not works for me
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); } } }
@Ancalagon
tradermatrix
25 Jul 2014, 11:31
protected override void OnStart()
{
ichimoku = Indicators.GetIndicator<IchimokuCloud>(periodFast, periodMedium, periodSlow, DisplacementCloud);
}
@tradermatrix
Ancalagon
25 Jul 2014, 12:51
RE:
tradermatrix said:
protected override void OnStart()
{
ichimoku = Indicators.GetIndicator(periodFast, periodMedium, periodSlow, DisplacementCloud);
}
i have program with private ichoku cloud
cannot find the ichimokucloud
@Ancalagon
behkam21
06 Oct 2018, 19:46
RE:
OOSilgjerd said:
Hi, I'm a complete beginner in programming so please excuse my lack of knowledge.
I am attempting to make a cBot 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).
I know a lot is wrong with this code, I need to be pointed in the right direction and taught some code on how to do a few things. I'm not asking you to make my entire bot although it would have been awfully nice if somebody could do maybe a little bit for me ;)
I need help on:
- The buy and sell signals (and then make it execute the orders)
- Setting SL and TP (make two positions, SL 25 pips on both, TP 20 pips on one, 30 pip trailing stop triggered when @ 30 pip profit on the other)
- Make the SL move to break even when the 20 pip SL is hit on the first trade.
//#reference: ..\Indicators\Ichimoku_cloud2.algo using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC)] public class IchimokuBreakoutBot : Robot { private Ichimoku_cloud2 Ichi; [Parameter("Volume", DefaultValue = 100000)] public int Volume { get; set; } protected override void OnStart() { Ichi = Indicators.GetIndicator<Ichimoku_cloud2>(); } protected override void OnBar() { if (HasCrossedAbove(Ichi.SenkouSpanA, Ichi.SenkouSpanB && MarketSeries.Close > Ichi.SenkouSpanA)) ; { OpenPosition(TradeType.Buy); } }
@behkam21
abrammankheli
20 May 2021, 09:14
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
Old Account
26 Jan 2014, 01:34
I would be happy to help you, but i don't have much experience whit Ichimoku so you are going to have to explainit a bit more for me. You can contact me at MrSvesli@hotmail.no if you to.
@Old Account