Topics
23 Sep 2022, 21:25
 1956
 13
26 Oct 2021, 11:33
 6
 1060
 1
25 Feb 2021, 15:07
 991
 4
19 Oct 2020, 16:18
 0
 1184
 1
Replies

xabbu
19 Oct 2020, 23:06

a guy named alexander kerker from switzerland is known for xxxx for about 10 years ago, just google his name and forex and translate it from german. It is a shame that an old man is writing and acting like this...


@xabbu

xabbu
19 Oct 2020, 11:51

thank you very much, mparama!

was only aware of "isbacktesting" and your tip helped me to learn about these other functions...

xabbu


@xabbu

xabbu
16 Oct 2020, 19:47

found it - no chart events allowed...

is there the possibility to check if the cBot is in optimization mode (like isBacktesting) or any other trick not to out comment the lines with chart.xxxx?

 

Kindest regards,


@xabbu

xabbu
15 Oct 2020, 14:09

okay, good to know it was not my error, but would be great if their is a consistancy (build in indicator parameters can be accessed by cBots) - do you have an idea for a workaround until...?

 


@xabbu

xabbu
10 Oct 2020, 10:45

„EA-Robot der 0% Verlust macht und Täglich 24 Std. min. 100% Gewinn macht“ EA robot that makes 0% loss and daily 24 hours min. 100% profit. - it seems that programming is not the only thing you are at the very first beginning, because: your goals are absolute unrealistic...


@xabbu

xabbu
10 Oct 2020, 10:40

it is a little shame that there is no actual Mac version, but:

using Parallels and Win 10 on a Mac is an easy setup and an excellent workaround until...

 


@xabbu

xabbu
09 Oct 2020, 14:17

Dear Panagiotis,

I'm now back to the first solution you have proposed, and it seems that this short code reads the csv file - but how I can get now the imported values into the IndicatorDataSeries to get the demanded result...?

I i appreciate your kind help very much!

Thats my code in this moment of time:

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


namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FileSystem)]
    public class NewIndicator : Indicator
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        string[] listA;
        string[] listB;


        protected override void Initialize()
        {

            using (var reader = new StreamReader("C:\\Users\\xabbu\\Desktop\\evzTestklein.csv"))
            {
                List<string> listA = new List<string>();
                List<string> listB = new List<string>();
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    var values = line.Split(';');

                    listA.Add(values[0]);
                    listB.Add(values[1]);


                }

                foreach (var element in listA)
                    Print(element);
                foreach (var element in listB)
                    Print(element);
            }
        }

        public override void Calculate(int index)
        {



            
        }
    }
}

@xabbu

xabbu
08 Oct 2020, 13:48

RE:

Dear Panagiotis,

I'm now back to the first solution you have proposed, and it seems that this short code reads the csv file - but how I can get now the imported values into the IndicatorDataSeries to get the demanded result...?

I i appreciate your kind help very much!

Thats my code in this moment of time:

 

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


namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FileSystem)]
    public class NewIndicator : Indicator
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        string[] listA;
        string[] listB;


        protected override void Initialize()
        {

            using (var reader = new StreamReader("C:\\Users\\xabbu\\Desktop\\evzTestklein.csv"))
            {
                List<string> listA = new List<string>();
                List<string> listB = new List<string>();
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    var values = line.Split(';');

                    listA.Add(values[0]);
                    listB.Add(values[1]);


                }

                foreach (var element in listA)
                    Print(element);
                foreach (var element in listB)
                    Print(element);
            }
        }

        public override void Calculate(int index)
        {



            
        }
    }
}

 

PanagiotisCharalampous said:

Hi xabbu,

It cannot get simpler than the link I posted above. Here is again the code sample

    using(var reader = new StreamReader(@"C:\test.csv"))
    {
        List<string> listA = new List<string>();
        List<string> listB = new List<string>();
        while (!reader.EndOfStream)
        {
            var line = reader.ReadLine();
            var values = line.Split(';');

            listA.Add(values[0]);
            listB.Add(values[1]);
        }
    }

You can do it anywhere you want. If you cannot implement it, then maybe you should ask for professional assistance.

Best Regards,

Panagiotis 

Join us on Telegram 

 


@xabbu

xabbu
07 Oct 2020, 15:11 ( Updated at: 21 Dec 2023, 09:22 )

Dear Panagiotis,

I walked a few steps further, but the final piece seems missing: the code produces only a line with one value (the last one)...

 

using System;
using System.IO;
using System.Collections.Generic;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using Microsoft.VisualBasic.FileIO;
using System.Globalization;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FileSystem)]
    public class CSVIMPORTNNFX : Indicator
    {

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        public string _datefield;
        public string _evzValue;


        protected override void Initialize()
        {
            var path = "C:\\Users\\xabbu\\Desktop\\evzTest Kopie.csv";
            //\\evzTest Kopie.csv";

            using (TextFieldParser csvParser = new TextFieldParser(path))
            {
                csvParser.CommentTokens = new string[] 
                {
                    "#"
                };
                csvParser.SetDelimiters(new string[] 
                {
                    ";"
                });
                csvParser.HasFieldsEnclosedInQuotes = true;

                // Skip the row with the column names
                csvParser.ReadLine();

                while (!csvParser.EndOfData)
                {
                    // Read current line fields, pointer moves to the next line.
                    string[] fields = csvParser.ReadFields();
                    _datefield = fields[0];

                    _evzValue = fields[1];

                }
            }

        }


        public override void Calculate(int index)
        {

            Print("Datum. " + Convert.ToDateTime(_datefield, CultureInfo.InvariantCulture) + " $EVZ: " + Convert.ToDouble(_evzValue, CultureInfo.InvariantCulture));
            Result[index] = Convert.ToDouble(_evzValue, CultureInfo.InvariantCulture);

        }
    }
}

 

 


@xabbu

xabbu
07 Oct 2020, 13:21

Hello Panagiotis,

good news, thanks to your help, I managed to read a sample .csv file into an indicator. I read the site you gave me and get the best result with this adapted solution (and maybe it could help others when searching "cTrader import / importing csv file / data":

 

using System;
using System.IO;
using System.Collections.Generic;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using Microsoft.VisualBasic.FileIO;
using System.Globalization;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FileSystem)]
    public class NewIndicator : Indicator
    {

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }




        protected override void Initialize()
        {
            var path = "C:\\Users\\xabbu\\Desktop\\evzTestklein.csv";
            //var path = "C:\\Users\\xabbu\\Desktop\\evzTest Kopie.csv";

            using (TextFieldParser csvParser = new TextFieldParser(path))
            {
                csvParser.CommentTokens = new string[] 
                {
                    "#"
                };
                csvParser.SetDelimiters(new string[] 
                {
                    ";"
                });
                csvParser.HasFieldsEnclosedInQuotes = true;

                // Skip the row with the column names
                csvParser.ReadLine();

                while (!csvParser.EndOfData)
                {
                    // Read current line fields, pointer moves to the next line.
                    string[] fields = csvParser.ReadFields();
                    string _datefield = fields[0];

                    string _evzValue = fields[1];
                    Print("Datum. " + Convert.ToDateTime(_datefield, CultureInfo.InvariantCulture) + " $EVZ: " + Convert.ToDouble(_evzValue, CultureInfo.InvariantCulture));
                }
            }
        }


        public override void Calculate(int index)
        {




        }
    }
}

 

I could also convert the fields in the .csv-file to an date and double value and printed it to the log:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

There are so many sources of C# knowledge and tutorials out there (I bought some c# courses on Udemy), but in combination with cTrader the internet wisdom is very limited. I found only 2 tutorials about cTrader / cAlgo programming to buy. One is extremly bad and outdatet and hardly to understand. The other one I bought for around $50 but it touches only the "standard" questions an procedures.

I think that is very frustrating, because cTrader is THE modern platform and years in advance compaired to the MarkeT-Leaders (-;... BUT: the interaction between the platform and the users in meaning of the choice of cBots and indicators is very small compared to the other platforms, if one compares the resources and indicators / bots available...

 

 

I would like to ask for your knowledge and kind help again:

How can I now, with this imported data from the .csv file, create the indicator data series correct, so that the imported values (date, value) can form the output of an cTrader indicator?

Kindest regards,

 

 

 

 


@xabbu

xabbu
06 Oct 2020, 10:46

Okay - thanks again. I have to import the csv data into cTrader and than bring them to an IndicatorDataSeries.

For the importing part of the question, Panagiotis: Is there an easy to implemente example how to do this? I read all the resources here and the hints you gave to external sites, but it's still confusing to me. Can I do it in cTrader or do I have to use Visual Studio for that.

Is there maybe an free indicator or cBot out there, which does a similar job I can look at and get some clues?


@xabbu

xabbu
06 Oct 2020, 10:34

Dear Panagiotis,

thank you, my "The indicator should draw a line" and your "use DrawTrendLine() method" might be a not exactly what I ment, sorry for the confusion. I try to start again:

I have an csv with data pairs:

Date,Value
11/1/2007,8.09
11/2/2007,8.12
11/5/2007,7.98

After importing that into cTrader (I did not manage that because of missing programming skills...) I would like that these data draw a line like an ordinary indicator, lets's say like the ATR. Each day has a value (closing price) and the values for each day should be connected like the ATR line.

Kindest regards


@xabbu

xabbu
04 Oct 2020, 10:00

Dear Keno,

did you try "Positions.Count " instead? For my cBot this works great under all mentioned conditions (high speed, non visual mode) to ensure, that I can`t open more trades then I want to.

Regards,

xabbu


@xabbu

xabbu
30 Sep 2020, 11:26

Dear Panagiotis,

thank you very much for your fast support. I added the line of code and it works!!!

Without your knowledge I would have NEVER found this solution.

Kindest regards to Cyprus and you & your team


@xabbu

xabbu
30 Sep 2020, 11:10

I run into the same exact problem yesterday on version 3.8 half a year later...


@xabbu

xabbu
16 Sep 2020, 09:43

Hey Panagiotis,

thanks for the always fast reply! I would like to have a clue how to read the .csv file into the cTrader indicator code and how to draw a simple line, which should connect the imported datapoints. The indicator should draw a line. Is this specific enough? And thank you in advance, Panagiotis...


@xabbu

xabbu
08 Sep 2020, 10:16

thanks, okay, and is it the right way when I only wan't to get a boolean expression from the sending to the receiving indicator / cBot - quasi as a signal?

 


@xabbu

xabbu
08 Sep 2020, 10:11

okay, I will try it with this advice, do I have to do it on indicator #1 or #2...?

and is it the right way when I only wan't to get a boolean expression from the sending to the receiving indicator / cBot?

Thanks Panagiotis


@xabbu

xabbu
08 Sep 2020, 09:54

I tried and inserted this line of new code in every possible (and impossible ;-) place in the code of indicator #1 (and #2 to also) - but I can't mange your tip to work. Can you give another little hint to get it done correctly? Danke


@xabbu

xabbu
08 Sep 2020, 09:21

Great support, Panagiotis, thanks!

Do I have to alter the indicator #1 or #2 (and how can I call the calculate() by hand...?

Best,


@xabbu