Topics
Replies
Cerunnos
05 Dec 2013, 16:41
( Updated at: 21 Dec 2023, 09:20 )
Perhaps there is a better solution - but it works :-) With Position.Comment it is possible to communicate between cTrader and cAlgo. With a comment such as "m30" in cTrader a special routine "m30" in cAlgo can be executed. The following simple code can be used for semi-automatic system:
protected override void OnStart()
{
Positions.Opened += OnPositionsOpened;
}
private void OnPositionsOpened(PositionOpenedEventArgs args)
{
if (args.Position.Comment == string.Empty) // manual positions without comment in cTrader
{
Print("Manual Position #{0} is open", args.Position.Comment);
// Exit-Strategy 1 ...
}
else if (args.Position.Comment == "m30") // manual positions in timeframe m30 - comment in cTrader "m30"
{
Print("Manual Position in m30 #{0} is open", args.Position.Comment);
// Exit-Strategy 2 ...
}
else if (args.Position.Comment == "h1") //only manual positions in timeframe m30 - comment in cTrader "h1"
{
Print("Manual Position in h1 #{0} is open", args.Position.Comment);
// Exit-Strategy 3 ...
}
}
@Cerunnos
Cerunnos
05 Dec 2013, 14:53
RE:
atrader said:
Why not create those positions by another robot (used just to open the positions) assigning the respective labels to them?
That would be a possibility. But then every time I'd have to log in on my VPS starting one of the two robots (m30 / H1) ...
@Cerunnos
Cerunnos
05 Dec 2013, 14:19
Thanks for reply. The use of labels is already known to me. In this case I'm using no labels because only manual positions to be processed by my Robot. I want to filter manual positions by timeframe in one robot, because I have different exit strategies for each timeframe.
M30-position in XAU/USD -> m30-exit strategy in robot
H1-position in XAU/USD -> H1-exit strategy in robot
@Cerunnos
Cerunnos
02 Dec 2013, 17:36
RE: RE:
algotrader said:
Cerunnos said:
Why is 2calgo.com offline?
Now it works. Could you please tell how you meet this problem? Did you try to convert some specific robot or indicator?
No, I couldn't launch the website (website not found). Thanks - 2calgo is a great service
@Cerunnos
Cerunnos
01 Dec 2013, 09:32
RE:
marafi5 said:
Hello
I need a help for making cBot for a small idea: If my account is making profit , all pending order should be deleted.
Thanks
if (Account.Equity >= startingBalance * BalancePercent)
{
foreach (var order in PendingOrders)
{
CancelPendingOrder(order);
}
}
@Cerunnos
Cerunnos
29 Nov 2013, 14:27
RE:
amiscell said:
Hi,
Since the latest release, (1.13) I noticed that the platform itself generates a lot of noise in the logging output such as the one below. How can I disable this so that I can see just my own messages?
01/04/2011 01:00:30 | Placing Limit Order to Sell 20k GBPUSD (Price: 1.61474, ExpireTime: 04/12/2013 00:00)
01/04/2011 01:00:30 | Placing Limit Order to Buy 20k GBPUSD (Price: 1.59382, ExpireTime: 04/12/2013 00:00)
01/04/2011 01:00:30 | → Placing Limit Order to Sell 20k GBPUSD (Price: 1.61474, ExpireTime: 04/12/2013 00:00) SUCCEEDED, PendingOrder OID1
01/04/2011 01:00:30 | → Placing Limit Order to Buy 20k GBPUSD (Price: 1.59382, ExpireTime: 04/12/2013 00:00) SUCCEEDED, PendingOrder OID3
01/04/2011 02:10:30 | Placing Limit Order to Sell 20k GBPUSD (Price: 1.61474, ExpireTime: 04/12/2013 00:00)
01/04/2011 02:10:30 | Placing Limit Order to Buy 20k GBPUSD (Price: 1.59382, ExpireTime: 04/12/2013 00:00)
I think you are watching the tab "Journal". In the cAlgo tab "Log" there will be listed no noise...
@Cerunnos
Cerunnos
28 Nov 2013, 17:03
RE: RE:
Cerunnos said:
hichem said:
From the new API:
Positions.Closed+= OnPositionsClosed;
will handle all closed positions not only in the current robot
Hi Hichem.
Even if a position was closed manually in cTrader or by SL hit. How would you code that?
Thanks in advance
protected override void OnStart()
{
Positions.Closed += OnPositionsClosed;
}
private void OnPositionsClosed(PositionClosedEventArgs args)
{
if (args.position.Label != "m10_Robot" && args.position.Label != "m5_Robot") // only manual positions
{
Print("Manually Position #{0} was closed", args.Position.Id);
}
}
Is that code right?
@Cerunnos
Cerunnos
28 Nov 2013, 14:33
RE:
jeex said:
Is it possible for a robot to manage trades that are opened by other instances (or manually)?
How can a robot act on the closing of a trade not set by that instance? OnPositionClosed can only do this for trades opened by the instance itself.
I try to build a bot that manages all my opened positions.
With using labels (Label = "m10_Robot" etc.) and a bridge which can pass variables between robots (Robolink from scyware.com)...
@Cerunnos
Cerunnos
28 Nov 2013, 12:07
RE: RE:
Spotware said:
supafly said:
Is there a simple way to create a notification email when a take profit or stop loss has been hit?
Thanks
We plan to implement a completely new API which will include methods for stop loss and take profit hit.
Hi Spotware-Team!
Which methods for SL / TP hits are now available? I need them for my semi-automatic system...
Thanks
@Cerunnos
Cerunnos
21 Nov 2013, 11:00
Many successful traders work with price action. They are looking for engulfing bars, pin bars, big belts, inside bar combos etc. But trading without indicators only works if support & resistance zones are used. And these zones have just made in the past :-) To use S & R zones in robots is likely to be quite difficult. Therefore, many prefer to use indicators ...
@Cerunnos
Cerunnos
13 Nov 2013, 09:53
RE: Lets use Pipes!! ... please dont reference syware
jhtrader said:
How does robot 1 tell robot 2 to execute a particular instruction only robot 2 can do.
So Robot 1 checks a condition say the time is 10am on Tuesday.
If condition is true it sends a message to Robot 2 to execute a particular instruction for a particular symbol.
Robot 2 will check if the SMA is rising for that particular pair and then will either Buy the pair or ignore Robot 1.
So we are looking to pass the variables and requests between robots... without 3rd party software!!!
Ok, you want to pass variables between two robots. You don't want to use a third-party software and you don't want to store variables in an external file or windows registry to make them read. So you're sure to have a more complex solution with pipes. Then code it and publish it in the forum. Thanks in advance :-)
@Cerunnos
Cerunnos
11 Nov 2013, 20:05
Add following code:
protected int Index
{
get { return MarketSeries.Close.Count - 1; }
}
For learning you should view the sample robots in the left column of cAlgo. And with <Search> you find a solution to almost any problem :-)
I can code your strategy, but then you have to pay for work.
@Cerunnos
Cerunnos
11 Nov 2013, 10:11
With the following basic structure of COG you should be able to complete your Robot:
// Center of Gravity by Belkhayate -----------------------------
[Parameter(DefaultValue = 3.0, MinValue = 1, MaxValue = 4)]
public int degree { get; set; }
[Parameter(DefaultValue = 120)]
public int period { get; set; }
[Parameter(DefaultValue = 1.4)]
public double strdDev { get; set; }
[Parameter(DefaultValue = 2.4)]
public double strdDev2 { get; set; }
[Parameter(DefaultValue = 3.4)]
public double strdDev3 { get; set; }
//--------------------------------------------------------------
private double main;
private double red_1;
private double red_2;
private double red_3;
private double blue_1;
private double blue_2;
private double blue_3;
private BelkhayatePRC BEL;
protected override void OnStart()
{
BEL = Indicators.GetIndicator<BelkhayatePRC>(degree, period, strdDev, strdDev2, strdDev3);
}
protected override void OnTick()
{
// COG main line
main = BEL.prc[Index];
// COG lines
red_1 = BEL.sqh[Index];
red_2 = BEL.sqh2[Index];
red_3 = BEL.sqh3[Index];
blue_1 = BEL.sql[Index];
blue_2 = BEL.sql2[Index];
blue_3 = BEL.sql3[Index];
//your buy-condition...
if (MarketSeries.Close[Index] > red_2)...
}
@Cerunnos
Cerunnos
05 Dec 2013, 19:57
/forum/calgo-reference-samples/415
@Cerunnos