Topics
Replies
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
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
@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
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
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