Topics
Replies
noppanon
22 Feb 2018, 08:07
( Updated at: 21 Dec 2023, 09:20 )
Hi Hamidrtafx,
You may try to cut and past the code to notepad and save as ANSI text file to clean any encoding.
I modified the code so that you can change how many periods you want to check for flating.
Here is sample if flat periods is 3.
Here is the code.
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class TKFlat : Indicator { [Parameter("Tenkan Sen Period", DefaultValue = 9)] public int TenkanPeriod { get; set; } [Parameter("Kijun Sen Period", DefaultValue = 26)] public int KijunPeriod { get; set; } [Parameter("Senkou Span B Period", DefaultValue = 52)] public int SenkouPeriod { get; set; } [Parameter("Flat Period", DefaultValue = 3)] public int FlatPeriod { get; set; } private IchimokuKinkoHyo Cloud; private Random ChartID; protected override void Initialize() { ChartID = new Random(); Cloud = Indicators.IchimokuKinkoHyo(TenkanPeriod, KijunPeriod, SenkouPeriod); } public override void Calculate(int index) { for (int i = 0; i < FlatPeriod; i++ ) { if (Cloud.TenkanSen[index - i] != Cloud.TenkanSen[index - i - 1]) { return; } } for (int j = 0; j < FlatPeriod; j++) { if (Cloud.KijunSen[index - j] != Cloud.KijunSen[index - j - 1]) { return; } } ChartObjects.DrawVerticalLine("Flat_" + ChartID.Next(0, 100000).ToString(), index, Colors.Aqua, 2, LineStyle.Solid); } } }
Happy trading,
Noppanon
@noppanon
noppanon
31 Aug 2018, 04:22 ( Updated at: 21 Dec 2023, 09:20 )
Hi There,
In a few minute later, same Bot, same code section, it could submit another open stop order. Bot was not restarted to submit another order.
Regards,
Noppanon
@noppanon