notzen
notzen's avatar

Info

Username:notzen
Name:notzen
Member since: 30 Jan 2017

About

None

Signature

None

Last Algorithm Comments

@Renko Volume Heat map:  23 Aug 2021, 17:06


once i use it my cpu jumps to 90% and more.  it consume too much reources and I do not seem to work

@Pattern Drawing:  14 Apr 2021, 13:35


Hi, Would be useful for ichimoku users to add kihon suchi cycles and Taito suchi cycles. Thank you  Excellent work 

@Advanced Ichimoku Kinko Hyo:  04 Feb 2021, 00:47


thanks a lot!

@Heikin Ashi Multi-Symbol Strategy:  22 Jan 2021, 04:23


sorry bi meant optimization  

@Heikin Ashi Multi-Symbol Strategy:  22 Jan 2021, 04:19


also cannot change time frame on first pair

@Heikin Ashi Multi-Symbol Strategy:  22 Jan 2021, 04:19


backtesting does not work, looks like it doest take any trade

@Advanced Ichimoku Kinko Hyo:  13 Jan 2021, 03:12


Hi,  Thank you for this system,  Would be possible to insert buy/sell arrows into it? 

@Smart Kestrel:  05 Dec 2020, 02:27


interesting bot, would be useful to insert the possibility to set take profit and a small guide about the parameters

Last Forum Posts

@Customized Pips for Range Bars and Renko:  19 Nov 2021, 15:18


 I think that could be better to let user to set a number for renko pips directly , they are asset like palladium that need more pips , atr on palladium could be 7k pips in day chart,

@scale bars on multi time frame indicator:  03 Nov 2021, 10:22


Hi ,

thanks for your feedback

the base code is this ,

unfortunately even using more instances the result is the same , except the scaling, I am not sure if there is anything else wrong . 

the indicator itself work ok and show ichimoku correctly and fix the wrong displacement in the built-in indicator (it is 26 candle from the current so candle 0 not candle 1...about that I wonder is the other lines use calculation from candle 1 or 0 as it should be start from current always in ichimoku because Japaneses count from 1 not 0...)

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using System.Collections.Generic;

namespace cAlgo
{



    [Cloud("Senkou Span B", "Senkou Span A", Opacity = 0.2)]

    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]



    public class Tony_ICH_Fixed : Indicator
    {


        private Bars _baseTimeFrameBars;



        [Parameter("TimeFrame-1", DefaultValue = "Daily", Group = "Time Frame")]
        public TimeFrame BaseTimeFrame { get; set; }

        [Parameter("Tenkan Sen Periods", DefaultValue = 9, Group = "Ichimoku")]
        public int TenkanSenPeriods { get; set; }

        [Parameter("Kijun Sen Periods", DefaultValue = 26, Group = "Ichimoku")]
        public int KijunSenPeriods { get; set; }

        [Parameter("Senkou Span B Periods", DefaultValue = 52, Group = "Ichimoku")]
        public int SenkouSpanBPeriods { get; set; }

        [Parameter("Displacement Chikou 25+current candle 0", DefaultValue = 25, Group = "Ichimoku")]
        public int DisplacementChikou { get; set; }

        [Parameter("DisplacementKumo 25+current candle 0", DefaultValue = 25, Group = "Ichimoku")]
        public int DisplacementKumo { get; set; }


        //------------------------

        [Output("Tenkan Sen", LineColor = "#FF02AFF1")]
        public IndicatorDataSeries TenkanSen { get; set; }

        [Output("Kijun Sen", LineColor = "#FFFF6666")]
        public IndicatorDataSeries KijunSen { get; set; }

        [Output("Chikou Span", LineColor = "#FFFFFF00")]
        public IndicatorDataSeries ChikouSpan { get; set; }

        [Output("Senkou Span B", LineColor = "#FFFF0000", LineStyle = LineStyle.Solid)]
        public IndicatorDataSeries SenkouSpanB { get; set; }

        [Output("Senkou Span A", LineColor = "FF008000", LineStyle = LineStyle.Solid)]
        public IndicatorDataSeries SenkouSpanA { get; set; }




        //[Parameter("Magic Number", DefaultValue = 0)]
        public int mgc = 0;
        public double maxfast, minfast, maxmedium, minmedium, maxslow, minslow;






        protected override void Initialize()
        {

            _baseTimeFrameBars = MarketData.GetBars(BaseTimeFrame);



        }

        public override void Calculate(int index)
        {


            //Ichimoku 5 lines

            var baseIndex = _baseTimeFrameBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);

            if ((baseIndex < TenkanSenPeriods) || (baseIndex < SenkouSpanBPeriods))
            {
                return;
            }

            maxfast = _baseTimeFrameBars.HighPrices[baseIndex];
            minfast = _baseTimeFrameBars.LowPrices[baseIndex];

            maxmedium = _baseTimeFrameBars.HighPrices[baseIndex];
            minmedium = _baseTimeFrameBars.LowPrices[baseIndex];

            maxslow = _baseTimeFrameBars.HighPrices[baseIndex];
            minslow = _baseTimeFrameBars.LowPrices[baseIndex];

            for (int i = 0; i < TenkanSenPeriods; i++)
            {
                if (maxfast < Bars.HighPrices[baseIndex - i])
                {
                    maxfast = Bars.HighPrices[baseIndex - i];
                }
                if (minfast > Bars.LowPrices[baseIndex - i])
                {
                    minfast = Bars.LowPrices[baseIndex - i];
                }
            }
            for (int i = 0; i < KijunSenPeriods; i++)
            {
                if (maxmedium < Bars.HighPrices[baseIndex - i])
                {
                    maxmedium = Bars.HighPrices[baseIndex - i];
                }
                if (minmedium > Bars.LowPrices[baseIndex - i])
                {
                    minmedium = Bars.LowPrices[baseIndex - i];
                }
            }
            for (int i = 0; i < SenkouSpanBPeriods; i++)
            {
                if (maxslow < Bars.HighPrices[baseIndex - i])
                {
                    maxslow = Bars.HighPrices[baseIndex - i];
                }
                if (minslow > Bars.LowPrices[baseIndex - i])
                {
                    minslow = Bars.LowPrices[baseIndex - i];
                }
            }
            TenkanSen[baseIndex] = (maxfast + minfast) / 2;
            KijunSen[baseIndex] = (maxmedium + minmedium) / 2;
            ChikouSpan[baseIndex - DisplacementChikou] = Bars.ClosePrices[baseIndex];

            SenkouSpanA[baseIndex + DisplacementKumo] = (TenkanSen[baseIndex] + KijunSen[baseIndex]) / 2;
            SenkouSpanB[baseIndex + DisplacementKumo] = (maxslow + minslow) / 2;





        }

    }
}

amusleh said:

Hi,

I tested your code and something is wrong on it, because some of the outputs doesn't continue to the last bar.

Instead of using multiple time frames on a single indicator which makes debugging much harder for you I recommend you to use only one single time frame.

Develop an Ichimoku indicator that get just one time frame and then you can use three instance of that indicator for multiple time frames.

Regarding scaling, Ichimoku lines mostly follow the price and you should not have any scaling issue, the scaling issue occurs if your indicator lines are very far away from price series.

@scale bars on multi time frame indicator:  02 Nov 2021, 12:49


Hi,

I try to code an indicator to show ichimoku on multiple time frames ,

the indicators are not in the correct scale so I wonder is there is a method to scale bars in order to make it look consistently .

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using System.Collections.Generic;

namespace cAlgo
{



    [Cloud("Senkou Span B1", "Senkou Span A1", Opacity = 0.3)]
    [Cloud("Senkou Span B2", "Senkou Span A2", Opacity = 0.3)]
    [Cloud("Senkou Span B3", "Senkou Span A3", Opacity = 0.3)]
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]



    public class Tony_ICH_Fixed : Indicator
    {


        private Bars _baseTimeFrameBars1;
        private Bars _baseTimeFrameBars2;
        private Bars _baseTimeFrameBars3;



        [Parameter("TimeFrame-1", DefaultValue = "Daily", Group = "Time Frame")]
        public TimeFrame BaseTimeFrame1 { get; set; }

        [Parameter("TimeFrame-2", DefaultValue = "Hour4", Group = "Time Frame")]
        public TimeFrame BaseTimeFrame2 { get; set; }

        [Parameter("TimeFrame-3", DefaultValue = "Hour", Group = "Time Frame")]
        public TimeFrame BaseTimeFrame3 { get; set; }
        //--------------------------------------------------------------------------

        [Parameter("Tenkan Sen Periods1", DefaultValue = 9, Group = "Ichimoku")]
        public int TenkanSenPeriods1 { get; set; }

        [Parameter("Kijun Sen Periods1", DefaultValue = 26, Group = "Ichimoku")]
        public int KijunSenPeriods1 { get; set; }

        [Parameter("Senkou Span B Periods1", DefaultValue = 52, Group = "Ichimoku")]
        public int SenkouSpanBPeriods1 { get; set; }

        //-------------------------------------------------------------------------------

        [Parameter("Tenkan Sen Periods2", DefaultValue = 9, Group = "Ichimoku")]
        public int TenkanSenPeriods2 { get; set; }

        [Parameter("Kijun Sen Periods2", DefaultValue = 26, Group = "Ichimoku")]
        public int KijunSenPeriods2 { get; set; }

        [Parameter("Senkou Span B Periods2", DefaultValue = 52, Group = "Ichimoku")]
        public int SenkouSpanBPeriods2 { get; set; }

        //-----------------------------------------------------------------------------

        [Parameter("Tenkan Sen Periods3", DefaultValue = 9, Group = "Ichimoku")]
        public int TenkanSenPeriods3 { get; set; }

        [Parameter("Kijun Sen Periods3", DefaultValue = 26, Group = "Ichimoku")]
        public int KijunSenPeriods3 { get; set; }

        [Parameter("Senkou Span B Periods3", DefaultValue = 52, Group = "Ichimoku")]
        public int SenkouSpanBPeriods3 { get; set; }

        //--------------------------------------------------------------------------------------


        [Parameter("Displacement Chikou 25+current candle 0", DefaultValue = 25, Group = "Ichimoku")]
        public int DisplacementChikou { get; set; }

        [Parameter("DisplacementKumo 25+current candle 0", DefaultValue = 25, Group = "Ichimoku")]
        public int DisplacementKumo { get; set; }


        //-------------------------------------------------------------------------

        [Output("Tenkan Sen", LineColor = "#FF02AFF1")]
        public IndicatorDataSeries TenkanSen1 { get; set; }

        [Output("Kijun Sen", LineColor = "#FFFF6666")]
        public IndicatorDataSeries KijunSen1 { get; set; }

        [Output("Chikou Span", LineColor = "#FFFFFF00")]
        public IndicatorDataSeries ChikouSpan1 { get; set; }

        [Output("Senkou Span B1", LineColor = "#FF808080", LineStyle = LineStyle.Solid)]
        public IndicatorDataSeries SenkouSpanB1 { get; set; }

        [Output("Senkou Span A1", LineColor = "FFCCCCCC", LineStyle = LineStyle.Solid)]
        public IndicatorDataSeries SenkouSpanA1 { get; set; }

//-----------------------------------
        [Output("Tenkan Sen2", LineColor = "#FF02AFF1")]
        public IndicatorDataSeries TenkanSen2 { get; set; }

        [Output("Kijun Sen2", LineColor = "#FFFF6666")]
        public IndicatorDataSeries KijunSen2 { get; set; }

        [Output("Chikou Span2", LineColor = "#FFFFFF00")]
        public IndicatorDataSeries ChikouSpan2 { get; set; }

        [Output("Senkou Span B2", LineColor = "#FF0071C1", LineStyle = LineStyle.Solid)]
        public IndicatorDataSeries SenkouSpanB2 { get; set; }

        [Output("Senkou Span A2", LineColor = "FFFED966", LineStyle = LineStyle.Solid)]
        public IndicatorDataSeries SenkouSpanA2 { get; set; }

        //-----------------------------------

        [Output("Tenkan Sen3", LineColor = "#FF02AFF1")]
        public IndicatorDataSeries TenkanSen3 { get; set; }

        [Output("Kijun Sen3", LineColor = "#FFFF6666")]
        public IndicatorDataSeries KijunSen3 { get; set; }

        [Output("Chikou Span3", LineColor = "#FFFFFF00")]
        public IndicatorDataSeries ChikouSpan3 { get; set; }

        [Output("Senkou Span B3", LineColor = "#FFFF0000", LineStyle = LineStyle.Solid)]
        public IndicatorDataSeries SenkouSpanB3 { get; set; }

        [Output("Senkou Span A3", LineColor = "FF008000", LineStyle = LineStyle.Solid)]
        public IndicatorDataSeries SenkouSpanA3 { get; set; }
        //-----------------------------------


        //[Parameter(DefaultValue = 26)]
        // public int DisplacementChikou { get; set; }

        //[Parameter(DefaultValue = 26)]
        // public int DisplacementKumo { get; set; }




        //[Parameter("Magic Number", DefaultValue = 0)]
        public int mgc = 0;
        public double maxfast1, minfast1, maxmedium1, minmedium1, maxslow1, minslow1;
        public double maxfast2, minfast2, maxmedium2, minmedium2, maxslow2, minslow2;
        public double maxfast3, minfast3, maxmedium3, minmedium3, maxslow3, minslow3;

        private string name;



        protected override void Initialize()
        {

            _baseTimeFrameBars1 = MarketData.GetBars(BaseTimeFrame1);
            _baseTimeFrameBars2 = MarketData.GetBars(BaseTimeFrame2);
            _baseTimeFrameBars3 = MarketData.GetBars(BaseTimeFrame3);



            //DisplacementChikou = KijunSenPeriods - 1;
            // DisplacementKumo = KijunSenPeriods - 1;

            name = "" + mgc.ToString();
        }

        public override void Calculate(int index)
        {
            var index1 = index;
            var index2 = index;
            var index3 = index;
            //Ichimoku 5 lines

            var baseIndex1 = _baseTimeFrameBars1.OpenTimes.GetIndexByTime(Bars.OpenTimes[index1]);
            var baseIndex2 = _baseTimeFrameBars2.OpenTimes.GetIndexByTime(Bars.OpenTimes[index2]);
            var baseIndex3 = _baseTimeFrameBars3.OpenTimes.GetIndexByTime(Bars.OpenTimes[index3]);

            if ((index < TenkanSenPeriods1) || (index < SenkouSpanBPeriods1))
            {
                return;
            }



            maxfast1 = _baseTimeFrameBars1.HighPrices[index1];
            minfast1 = _baseTimeFrameBars1.LowPrices[index1];

            maxmedium1 = _baseTimeFrameBars1.HighPrices[index1];
            minmedium1 = _baseTimeFrameBars1.LowPrices[index1];

            maxslow1 = _baseTimeFrameBars1.HighPrices[index1];
            minslow1 = _baseTimeFrameBars1.LowPrices[index1];

            for (int i = 0; i < TenkanSenPeriods1; i++)
            {
                if (maxfast1 < Bars.HighPrices[index1 - i])
                {
                    maxfast1 = Bars.HighPrices[index1 - i];
                }
                if (minfast1 > Bars.LowPrices[index1 - i])
                {
                    minfast1 = Bars.LowPrices[index1 - i];
                }
            }
            for (int i = 0; i < KijunSenPeriods1; i++)
            {
                if (maxmedium1 < Bars.HighPrices[index1 - i])
                {
                    maxmedium1 = Bars.HighPrices[index1 - i];
                }
                if (minmedium1 > Bars.LowPrices[index1 - i])
                {
                    minmedium1 = Bars.LowPrices[index1 - i];
                }
            }
            for (int i = 0; i < SenkouSpanBPeriods1; i++)
            {
                if (maxslow1 < Bars.HighPrices[index1 - i])
                {
                    maxslow1 = Bars.HighPrices[index1 - i];
                }
                if (minslow1 > Bars.LowPrices[index1 - i])
                {
                    minslow1 = Bars.LowPrices[index1 - i];
                }
            }
            TenkanSen1[index1] = (maxfast1 + minfast1) / 2;
            KijunSen1[index1] = (maxmedium1 + minmedium1) / 2;
            ChikouSpan1[index1 - DisplacementChikou] = Bars.ClosePrices[index1];

            SenkouSpanA1[index + DisplacementKumo] = (TenkanSen1[index1] + KijunSen1[index1]) / 2;
            SenkouSpanB1[index + DisplacementKumo] = (maxslow1 + minslow1) / 2;




            if ((index2 < TenkanSenPeriods2) || (index2 < SenkouSpanBPeriods2))
            {
                return;
            }



            maxfast2 = _baseTimeFrameBars2.HighPrices[index2];
            minfast2 = _baseTimeFrameBars2.LowPrices[index2];

            maxmedium2 = _baseTimeFrameBars2.HighPrices[index2];
            minmedium2 = _baseTimeFrameBars2.LowPrices[index2];

            maxslow2 = _baseTimeFrameBars2.HighPrices[index2];
            minslow2 = _baseTimeFrameBars2.LowPrices[index2];

            for (int i = 0; i < TenkanSenPeriods2; i++)
            {
                if (maxfast2 < Bars.HighPrices[index2 - i])
                {
                    maxfast2 = Bars.HighPrices[index2 - i];
                }
                if (minfast2 > Bars.LowPrices[index2 - i])
                {
                    minfast2 = Bars.LowPrices[index2 - i];
                }
            }
            for (int i = 0; i < KijunSenPeriods2; i++)
            {
                if (maxmedium2 < Bars.HighPrices[index2 - i])
                {
                    maxmedium2 = Bars.HighPrices[index2 - i];
                }
                if (minmedium2 > Bars.LowPrices[index2 - i])
                {
                    minmedium2 = Bars.LowPrices[index2 - i];
                }
            }
            for (int i = 0; i < SenkouSpanBPeriods2; i++)
            {
                if (maxslow2 < Bars.HighPrices[index2 - i])
                {
                    maxslow2 = Bars.HighPrices[index2 - i];
                }
                if (minslow2 > Bars.LowPrices[index2 - i])
                {
                    minslow2 = Bars.LowPrices[index2 - i];
                }
            }
            TenkanSen2[index2] = (maxfast2 + minfast2) / 2;
            KijunSen2[index2] = (maxmedium2 + minmedium2) / 2;
            ChikouSpan2[index2 - DisplacementChikou] = Bars.ClosePrices[index2];

            SenkouSpanA2[index2 + DisplacementKumo] = (TenkanSen2[index2] + KijunSen2[index2]) / 2;
            SenkouSpanB2[index2 + DisplacementKumo] = (maxslow2 + minslow2) / 2;






            if ((index3 < TenkanSenPeriods3) || (index3 < SenkouSpanBPeriods3))
            {
                return;
            }




            maxfast3 = _baseTimeFrameBars3.HighPrices[index3];
            minfast3 = _baseTimeFrameBars3.LowPrices[index3];

            maxmedium3 = _baseTimeFrameBars3.HighPrices[index3];
            minmedium3 = _baseTimeFrameBars3.LowPrices[index3];

            maxslow3 = _baseTimeFrameBars3.HighPrices[index3];
            minslow3 = _baseTimeFrameBars3.LowPrices[index3];

            for (int i = 0; i < TenkanSenPeriods3; i++)
            {
                if (maxfast3 < Bars.HighPrices[index3 - i])
                {
                    maxfast3 = Bars.HighPrices[index3 - i];
                }
                if (minfast3 > Bars.LowPrices[index3 - i])
                {
                    minfast3 = Bars.LowPrices[index3 - i];
                }
            }
            for (int i = 0; i < KijunSenPeriods3; i++)
            {
                if (maxmedium3 < Bars.HighPrices[index3 - i])
                {
                    maxmedium3 = Bars.HighPrices[index3 - i];
                }
                if (minmedium3 > Bars.LowPrices[index3 - i])
                {
                    minmedium3 = Bars.LowPrices[index3 - i];
                }
            }
            for (int i = 0; i < SenkouSpanBPeriods3; i++)
            {
                if (maxslow3 < Bars.HighPrices[index3 - i])
                {
                    maxslow3 = Bars.HighPrices[index3 - i];
                }
                if (minslow3 > Bars.LowPrices[index3 - i])
                {
                    minslow3 = Bars.LowPrices[index3 - i];
                }
            }
            TenkanSen3[index3] = (maxfast3 + minfast3) / 2;
            KijunSen3[index3] = (maxmedium3 + minmedium3) / 2;
            ChikouSpan3[index3 - DisplacementChikou] = Bars.ClosePrices[index3];

            SenkouSpanA3[index3 + DisplacementKumo] = (TenkanSen3[index3] + KijunSen3[index3]) / 2;
            SenkouSpanB3[index3 + DisplacementKumo] = (maxslow3 + minslow3) / 2;

        }

    }
}

@High Memory consumption by ctrader during backtest:  20 Jul 2021, 11:40


Hello,

I notice an high memory value during backtest ,

this looks like a memory leacking 

@Exporting Optimizations Setups:  18 Jul 2021, 12:04


ctrader.guru said:

Congratulations for the constant updates, I would like to suggest an option that would solve many sharing problems, export optimization parameters.

It becomes impossible when a cbot has a lot of parameters and sharing them becomes impossible.

This option should have been included a long time ago, don't miss this opportunity.

Totally agree 

@Ichimoku incorrect periods:  13 Jul 2021, 12:28


PanagiotisCharalampous said:

Hi notzen,

I did not understand what the problem is and I do not see any issue with the indicator. Could you please provide a better explanation? The indicator seems to work as per the indicator's definition.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Hi,

The issue in not in the way the indicator is working but in the nunber of candles it use

the distance from the current candle (numbered as candle 0 ) and chicou spam for exsample is 26 , this seems to be right but since the current candle is 0 not 1  , the indicator is putting the chikou at a distance of 27 bars. 

this applies to the displacement of the kumo and the calculations of kijun , tenkan, senkou spam A and B.

@Ichimoku incorrect periods:  12 Jul 2021, 14:27


Hello,

I notice that ichimoku indicator is not taking in account the current candle 0 ,

from the current candle to the chikou are 26 peridos that plus the candle 0 are 27 , the same for kumo,

I suppose that also the tenkan and kijun are considering 9+0 candle and 26+0 candle

Please verify that and fix it if necessary

as you can see on tradeview.com they count correctly as it is bar 0 + 25 candles = 26

@remove demo accounts spotware:  29 Apr 2021, 17:41


Hello,

could be possibel to remove this demo accounts please ?

@can't figure out why does not open trades:  07 Feb 2021, 01:04


cant figure out why does not open trades, the bot is still a workn in progress , need also to make pairs selectables

using System;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MultisymbolBacktesting : Robot
    {

        [Parameter("EURUSD", DefaultValue = true)]
        public bool EURUSD { get; set; }

        [Parameter("GBPUSD", DefaultValue = true)]
        public bool GBPUSD { get; set; }

        [Parameter("USDJPY", DefaultValue = true)]
        public bool USDJPY { get; set; }

        [Parameter("USDCHF", DefaultValue = true)]
        public bool USDCHF { get; set; }

        [Parameter("SSL Periods", DefaultValue = 20)]
        public int SSLPer { get; set; }

        [Parameter("SSL MA", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType SSLMa { get; set; }

        [Parameter("ATR multiply", DefaultValue = 1.5)]
        public double ATRM { get; set; }

        [Parameter("Risk ", DefaultValue = 1)]
        public double Risk { get; set; }

        [Parameter("SMA period ", DefaultValue = 50)]
        public int maPeriod { get; set; }

        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }
        public Symbol[] MySymbols;

        private SSLChannel ssl;
        private AverageTrueRange atr;
        private SimpleMovingAverage sma;


        protected override void OnStart()
        {

            Risk = Risk / 100;



            // We get a symbol array for the following for symbols
            MySymbols = Symbols.GetSymbols("EURUSD", "GBPUSD", "USDJPY", "USDCHF");
            // We subscribe to the tick event for each symbol
            foreach (var symbol in MySymbols)
            {
                symbol.Tick += Symbol_Tick;
            }
            // We subscribe to the bar event for each symbol for the current timeframe
            foreach (var symbol in MySymbols)
            {

                var bars = MarketData.GetBars(TimeFrame, symbol.Name);
                bars.BarOpened += Bars_BarOpened;

            }
        }
        protected override void OnTick()
        {
            ssl = Indicators.GetIndicator<SSLChannel>(SSLPer, SSLMa);
            //stoc = Indicators.StochasticOscillator(K, KS, D, StocMa);
            atr = Indicators.AverageTrueRange(20, MovingAverageType.Exponential);
            sma = Indicators.SimpleMovingAverage(Bars.ClosePrices, maPeriod);

        }

        private void Bars_BarOpened(BarOpenedEventArgs obj)
        {

            var up3 = Bars.ClosePrices.Last(0) > Bars.ClosePrices.Last(1) && Bars.ClosePrices.Last(1) > Bars.ClosePrices.Last(2);
            //&& Bars.ClosePrices.Last(2) > Bars.ClosePrices.Last(3);
            var down3 = Bars.ClosePrices.Last(0) < Bars.ClosePrices.Last(1) && Bars.ClosePrices.Last(1) < Bars.ClosePrices.Last(2);
            // && Bars.ClosePrices.Last(2) < Bars.ClosePrices.Last(3);
            var smaLast = sma.Result.Last(0);
            var position = Positions.Find("");
            var price = Bars.ClosePrices.Last(0);
            var stopPips = Math.Round(atr.Result.Last(0) / Symbol.PipSize);
            var TakeProfitPips = (2 * stopPips);
            var tradeAmount = (Account.Equity * Risk) / (ATRM * stopPips * Symbol.PipValue);
            tradeAmount = Symbol.NormalizeVolumeInUnits(tradeAmount, RoundingMode.Down);
            var sslUp = ssl._sslUp;
            var sslDown = ssl._sslDown;



//------------------------------------buy
            //When a bar opens we check the previous bar. If the bar is bullish, we send a buy order
            if ((sslUp.HasCrossedAbove(sslDown, 1)) & up3)
            {
                ExecuteMarketOrder(TradeType.Buy, obj.Bars.SymbolName, tradeAmount, "", TakeProfitPips, stopPips, null, true);


                // When a bar opens we check the previous X bar for anoter buy
                if (up3)
                {
                    ExecuteMarketOrder(TradeType.Buy, obj.Bars.SymbolName, tradeAmount, "", TakeProfitPips, stopPips, null, true);
                }
            }



//------------------------------------sell
            //When a bar opens we check the previous bar. If the bar is bearish, we send a sell order
            if (sslDown.HasCrossedAbove(sslUp, 1) & down3)
            {
                ExecuteMarketOrder(TradeType.Sell, obj.Bars.SymbolName, tradeAmount, "", TakeProfitPips, stopPips, null, true);


                // When a bar opens we check the previous X bar for another sell
                if (down3)
                {
                    ExecuteMarketOrder(TradeType.Sell, obj.Bars.SymbolName, tradeAmount, "", TakeProfitPips, stopPips, null, true);
                }


            }


        }


        private void Symbol_Tick(SymbolTickEventArgs obj)
        {
            // On each symbol tick, we print the symbol's bid/ask prices on the chart
            var sb = new StringBuilder();
            foreach (var symbol in MySymbols)
            {
                var textLine = string.Format("{0} {1} {2}", symbol.Name, symbol.Bid, symbol.Ask);
                sb.AppendLine(textLine);
            }
            Chart.DrawStaticText("symbols", sb.ToString(), VerticalAlignment.Top, HorizontalAlignment.Left, Chart.ColorSettings.ForegroundColor);
        }

        private void PositionsOnClosed(PositionClosedEventArgs args)
        {
            if (args.Reason == PositionCloseReason.TakeProfit)
            {
                var position = Positions.Find("");
                ModifyPosition(position, position.EntryPrice, null);
            }
        }

        /* protected override void OnTick()
        {
            // Put your core logic here

        }*/
        protected override void OnBar()
        {
        }
        /* var smaLast = sma.Result.Last(0);
            
            if (position != null)
            {
                if (position.TradeType == TradeType.Buy & price > smaLast)
                    ModifyPosition(position, sma, position.TakeProfit, true);
                else if (position.TradeType == TradeType.Sell & price < smaLast)
                    ModifyPosition(position, sma, position.TakeProfit, true);
            }
            */
        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

@Check if tenkan and kijun are over /inside /below kumo:  05 Feb 2021, 13:04


Hello, 

I try to figure out how to insert this checks on cbot, 

Is there any function or way to know when tenkan sen and kijun sen are below, above or inside kumo? 

Also, there is a way to Chek if the last 2 candles close above, below on inside kijun sen?

Thank you! 

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.

No uploaded.

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.

No uploaded.