belasto
belasto's avatar

Info

Username:belasto
Name:belasto
Member since: 11 Feb 2019

About

None

Signature

None

Last Algorithm Comments

@Simple Trading Panel:  18 Sep 2021, 10:26


This robot seems not to work. Tried it in backtesting and no trades were opened or closed. Too bad..

Last Forum Posts

@How to pass data from Custom Indicator to cBot:  30 Aug 2022, 01:42


Hi Panagiotis,

Okay - with your input, I finally got it to work.

If some other Super Newbie like me has the same question, here is a super noob recap.


Indicator Code

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

namespace cAlgo
{

   [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights == AccessRights.None)]
    public class YourCustomIndicator : Indicator
    {
        [Output("Value1", LineColor = "Transparent")]
        public IndicatorDataSeries MyValue { get; set; }

        ......
    }


    public override void Calculate(int index)
    {
         MyValue[index] = WhateverYouWantToPass;
    }
}



cBot Code
(Don't forget to click on "Manage References" on the top and include your custom indicator!)
 

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

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class YourBot : Robot
    {
    
        private YourCustomIndicator theIndicator;

        protected override void OnStart()
        {
            theIndicator = Indicators.GetIndicator<YourCustomIndicator>();
        }

        protected override void OnTick()
        {
            Print("YourValue: ", theIndicator.MyValue.LastValue.ToString());
        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}




Best regards.

@How to pass data from Custom Indicator to cBot:  27 Aug 2022, 20:36


Hi all,

I read many posts about this and the reference help as well, but I am not able to get it to work - feeling totally lost. I don't get the C# concept yet.

I wrote a small indicator and would like to pass the current HighPrice and LowPrice of the Inidcator to a cBot. Could someone provide the things I need to add please? 

Indicator code below, the cBot is rather empty yet.
 

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
    public class Draw_Test : Indicator
    {
        
        double HighPrice = 0;
        double LowPrice = 100000000;
        double Distance;
        int FirstIndex = -1;
        int LastIndex = -1;
        
        DateTime MyDate;
        
        protected override void Initialize()
        {

        }

        public override void Calculate(int index)
        {
            
            // TO DO: CALC BOXES FOR CURRENT DAY AND LAST X DAYS
            MyDate = Bars.LastBar.OpenTime.Date;

            if(Bars.OpenTimes[index].Hour == 6 && Bars.OpenTimes[index].Date == MyDate){

                if(FirstIndex == -1){
                    FirstIndex = index;
                    LastIndex = FirstIndex + 11;
                }

                if(HighPrice < Bars[index].High){
                    HighPrice = Bars[index].High;
                }

                if(LowPrice > Bars[index].Low){
                    LowPrice = Bars[index].Low;
                }

                Distance = HighPrice - LowPrice;
                int intervalDistance = 263;
                int lineAmount = 7;

                Color MainCol = Color.FromHex("55FF0000");
                Color LineColDark = Color.FromHex("FF000000");
                Color LineColBright = Color.FromHex("55000000");

                // DRAW NO TRADING ZONE
                ChartRectangle rectangleFilled = Chart.DrawRectangle("rectangleFilled", FirstIndex, HighPrice, LastIndex+intervalDistance, LowPrice, MainCol);
                rectangleFilled.IsFilled = true;
                rectangleFilled.Color = MainCol;

                // DRAW SOURCE ZONE
                Chart.DrawRectangle("rectangleLine", FirstIndex, HighPrice, LastIndex, LowPrice, LineColDark);

                // DRAW LINES ABOVE
                for(int i = 1; i <= lineAmount; i++){
                    Color col;
                    if(i < 4){
                        col = LineColDark;
                    }else{
                        col = LineColBright;
                    }
                    Chart.DrawTrendLine("lineAbove"+i.ToString(), FirstIndex, HighPrice+Distance*i, LastIndex+intervalDistance, HighPrice+Distance*i, col);
                }

                // DRAW LINES BELOW
                for(int j = 1; j <= lineAmount; j++){
                
                    Color col;
                    if(j < 4){
                        col = LineColDark;
                    }else{
                        col = LineColBright;
                    }
                    Chart.DrawTrendLine("lineBelow"+j.ToString(), FirstIndex, LowPrice-Distance*j, LastIndex+intervalDistance, LowPrice-Distance*j, col);
                }

// ADD FUNCTION FOR PASSING HIGH AND LOW PRICES HERE..
// ....
// --------

            }else{
                HighPrice = 0;
                LowPrice = 100000000;
                FirstIndex = -1;
                LastIndex = -1;
                Distance = 0;
            }
        }
    }
}



Thanks a lot if you can help.

@Store downloaded historical data in Backtesting mode, instead of downloading every time?:  02 Sep 2021, 21:34


Hello again,

do I have to download historical data every time? Would it be possible to bulk download all data from a pair once and only download missing data on next restart? It feels strange to sit and wait every time, especially for long term testings. But maybe the option is present and I dont know? 

(And just a quick compliment, I really love cTrader. For me it's the best platform I tested so far.)

Cheers

@Positions have "ModifyTakeProfitPrice". PendingOrders only have "ModifyTakeProfitPips"??:  02 Sep 2021, 19:51


Thanks for the answer. It makes sense this way. However, maybe you can help me with a workaround? Not such a big deal I assume, but I am not sure how to get there.
I am creating one initial Position and 4 PendingOrders afterwards, some kind of grid trading approach. I'd like to give the PendingOrders the same TP as the initial Position. I could add listener on PendingOrder filled and immediately adjust the TP, but is there an easy way to adjust it in advance?

@Positions have "ModifyTakeProfitPrice". PendingOrders only have "ModifyTakeProfitPips"??:  02 Sep 2021, 16:01


Why do Positions have "ModifyTakeProfitPrice" method, but PendingOrders only have "ModifyTakeProfitPips"?

Did I miss something? Or does it makes sense somehow? I dont understand and would love to have this method at the moment.

@Is it not possible to Chart.DrawIcon only from a cBot?:  28 Apr 2021, 12:51


In the indicators Calculate function - working:
 

Chart.DrawIcon("arrow", ChartIconType.DownArrow, index, Bars[index].High + 5 * Symbol.PipSize, Color.Red);


In the cBot onBar function - not working, I let it run in backtesting, so onBar() is being called:
 

Chart.DrawIcon("arrow", ChartIconType.DownArrow, Bars.Count - 1, Bars[Bars.Count-1].High + 5 * Symbol.PipSize, Color.Red);



Thanks so much for helping out.


!!!! EDIT: If found the problem. I was not using the "visual mode" in backtesting... no wonder! Now it's working. Thanks!














 

@Is it not possible to Chart.DrawIcon only from a cBot?:  27 Apr 2021, 18:38


I think the title says it all. :)

If I use an indicator, I can use Draw.ChartIcon and see arrows and stuff. If I put the same line into the OnBar() of a cBot, it's not working. Do I make a mistake or is this on purpose?
(Sorry, Im new to all this)

Thanks!

@Delete indicators more directly:  01 Oct 2019, 05:01


Maybe I am blind. But when I right-click on an EMA (for instance), I don't see a delete button in that window. WHY?

Do I really always have to ....
right click on chart -> object list -> indicators -> Exponential Moving... -> X

And if I have several EMAs, I don't know which one is the right one, because the window is too small. Really annoying..
 

@Pending orders by trend lines:  01 Oct 2019, 04:53


Nice to have:
Draw a trend line, right click, use as sell or buy entry. Would need automatical "line locking", which makes that line undeletable until pending order was killed.

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.