Topics
Replies
firemyst
30 Jul 2023, 08:45
One issue you'll have is the trendlines are overwriting each other because you're giving them the same names.
Change the line:
ObjUp = string.Format("UpTrendLine");
to be this instead:
ObjUp = string.Format("UpTrendLine") + index.toString();
Do the same for the down trend line. This way, every up obj and down obj will have unique names so they won't overwrite each other.
@firemyst
firemyst
21 Jul 2023, 00:04
RE: RE:
jamesgoodman said:
firemyst said:
Did you add your Rate of Change as a "reference" to your bot?
No I have created the RateOfChange in the indicator class and then used the Indicators.GetIndicators function in main bot. Are you saying I need to create it in an external library?
Read this:
https://clickalgo.com/ctrader-assembly-reference
@firemyst
firemyst
18 Jul 2023, 11:02
RE:
Spotware said:
Hi firemyst,
Can you please install this hotfix and let us know if it resolves the problem?
Best regards,
cTrader Team
Sure. So far I've only had 1 crash today. I'll try installing it in about 12 hours from now (bots and other things running) and see how we go from there.
Thank you.
@firemyst
firemyst
14 Jul 2023, 03:29
RE:
ncel01 said:
firemyst,
Not really. That's simply the error description.What I want is to access to the trade operation ExecuteMarketOrderAsync() parameters, in this case to the label.
The goal is to know, exactly, which operation has failed: "Position #1" vs "Position #2".
Then you might want to try a brute force way:
//written off the top of my head, so may not work exactly as is
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class MarketOrderTest : Robot
{
//we'll add the labels of the orders we place to this object:
Dictionary<int, string> d = new Dictionary<int, string>();
//keep track of each async trade
bool trade1Finished = false;
bool trade2Finished = false;
protected override void OnStart()
{
string label1 = "Position #1";
string label2 = "Position #2";
d.Add(1, label1);
d.Add(2, label2);
trade1Finished = false;
trade2Finished = false;
ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin, d[1], (TradeResult r) =>
{
if (r.IsSuccessful)
{
//remove from dictionary object as we know it completed
if (r.Position.Label == label1)
d.Remove(1);
}
trade1Finished = true; //done tracking this trade
});
ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin, d[2], (TradeResult r) =>
{
if (r.IsSuccessful)
{
//remove from dictionary object as we know it completed
if (r.Position.Label == label2)
d.Remove(2);
}
trade2Finished = true; //done. This trade finished
});
}
protected override void OnTick()
{
//check when both trades are done.
//can also alter so that you check each trade individually
if (trade1Finished && trade2Finished)
{
if (d.ContainsKey(1))
{
//error occurred with this order since key still exists
}
if (d.ContainsKey(2))
{
//error occurred with this order
}
}
}
}
}
@firemyst
firemyst
07 Aug 2023, 00:13 ( Updated at: 21 Dec 2023, 09:23 )
You need to have your charts in multichart mode and click this tool to do a little bit of what you want:
@firemyst