Topics
Replies
cicondo
11 Dec 2017, 08:45
( Updated at: 21 Dec 2023, 09:20 )
RE: RE:
jalmir.coelho@gmail.com said:
Panagiotis Charalampous said:
Hi jalmir.coelho@gmail.com,
You can close loop and close positions based on certain conditions as below.
foreach (var position in Positions) { //Put here any condition required to close the position if (position.Pips < -1) ClosePosition(position); }If you need access to historical trades, use the History collection.
Let me know if the above information helps.
Best Regards,
Panagiotis
How to close only the highlighted blue order using your id? how to get the value of pips (-1.7) and apply to a variable?Do you have an example?
I would recommend to create a specific label for each order you're placing....
The best way to get a specific position is to use a LINQ expression like:
var position = (from p in positions where p.Label == "yourLabel" && p.Pips > 0 select p).FirstOrDefault();
So you dont need to iterate through any collection, thats a direct query ;-)
Cheers Markus
@cicondo
cicondo
25 Feb 2015, 14:34
RE: where is the support
It looks like the support exists only for repeating problems.. :-)
watch this:
Using a smal testindicator for displying the problem I don't understand:
If I'M using the indicator only on a chart it display the rigth values related to it's calculation.
Referencing anf using the same indicator within a robot I always get the same result. What is going wrong, where is the mistake?I don't understand this....maybe I'm not alone ;-)
********************** indicator
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class TestIndicator : Indicator
{
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
protected override void Initialize()
{
// Initialize and create nested indicators
//Result = CreateDataSeries();
}
public override void Calculate(int index)
{
if (MarketSeries.Open[index] >= MarketSeries.Close[index])
{
Result[index] = -1.0;
}
else if (MarketSeries.Open[index] < MarketSeries.Close[index])
{
Result[index] = 1.0;
}
else
{
Result[index] = 0;
}
ChartObjects.DrawText("test", string.Format("Value: {0}", Result[index - 1]), StaticPosition.TopRight, Colors.Red);
}
}
}
********************* robot
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class TestBot : Robot
{
private TestIndicator _test1;
protected override void OnStart()
{
_test1 = Indicators.GetIndicator;
}
protected override void OnBar()
{
Print("TestValue {0}", _test1.Result.LastValue);
}
}
}
@cicondo
cicondo
24 Feb 2015, 08:29
Maybe I did not describe what's going wrong.
I expect that in the OnBar-Method of the robot that _haCurrent.CurrentTrend gets -1 or 1 depending on what the HeikinAshi Indikator displays for a trend. But I receive alweas 0. What's going wrong or better where I'm wrong.
Many Thx guys
@cicondo
cicondo
16 Feb 2014, 23:28
RE:
cicondo said:
Hi folks,
as a serious and discretionary trader it is essential to observe my account equity. I'm trying to implement this as
an indicator.So for that I need the result of each trade I had made (manually-non robots) and which is closed.
I cannot find some functions within the API wich would help me to do that.Do you have some ideas on how to solve that problem?
The simplest way I guess, would be to listen to any order, executed in the account so I would store it by myself.
cheers Cicondo
Hey,
has nobody here an answer? Or my description is badly explained?
Need some help.
C.
@cicondo
cicondo
29 Jun 2018, 10:03
RE:
5026484 said: Sorry,
after sleeping one night and thinking of wahts going on, I finally fixed taht problem, It was a bug in my code, not in cTrader.
Sorry for that :-(
@cicondo