Topics
Replies
Spotware
27 Jul 2017, 10:28
Dear theonlinemick,
Thanks for your post. You can try something like the following
protected override void OnTick() { foreach (var order in PendingOrders) { var pipDistance = Math.Abs((order.TargetPrice - Symbol.Ask) / Symbol.PipValue); if (pipDistance > MaxPipDistance) { CancelPendingOrder(order); } } }
You can ajdust the price you will consider (Symbol.Ask or Symbol.Bid) based on your order's direction.
Best Regards,
cTrader Team
@Spotware
Spotware
26 Jul 2017, 14:39
Hi,
Can you please remove it and try to add it again manually? Please follow the steps below
- Go to References.
- Select Connect API Library and press Delete.
- Right click on References.
- Select Add Reference
- Select Projects
- Select Connect API Library
- Press OK
- Try to build again
Let us know if the above fixes the problem
Best Regards,
cTrader Team
@Spotware
Spotware
26 Jul 2017, 14:24
( Updated at: 21 Dec 2023, 09:20 )
Hi again,
Can you please check if the Connect API Library project is referenced properly? Please expand the References section of Connect API Web and verify that the reference exists and doesn't have any issues. You should see the following
In case there is an issue e.g. a yellow sign, try to add the reference again manually.
Best Regards,
cTrader Team
@Spotware
Spotware
26 Jul 2017, 14:09
( Updated at: 21 Dec 2023, 09:20 )
Dear Trader,
Thanks for posting your question in the forum. It seems that you are using the Connect API Web Example. The code for the missing libraries is located in a separate project within the same solution.
Have you downloaded both projects from GitHub? If you open the solution, it will contain both projects and you will be able to build without problems.
Best Regards,
cTrader Team
@Spotware
Spotware
26 Jul 2017, 09:41
Dear MagicTurtle,
We cannot see anything wrong in the provided code sample. Can we have a sample cBot as well trading conditions (Symbol, Timeframe) that we can use to reproduce the message? If we can reproduce the message we would be able to give you some advice. It doesn't need to be your cBot but just a cBot that reproduces the message.
Best Regards,
cTrader Team
@Spotware
Spotware
26 Jul 2017, 09:23
Dear Trader,
Here is the code for the cBot
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class CloseAllPositions : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { // Put your initialization logic here } protected override void OnTick() { if (DateTime.Now.Hour == 8 && DateTime.Now.Minute == 0) foreach (var position in Positions) { ClosePosition(position); } } protected override void OnStop() { // Put your deinitialization logic here } } }
Best Regards,
cTrader Team
@Spotware
Spotware
25 Jul 2017, 10:40
Dear acrigney,
Thanks for posting your question in the forum. We tried to run your cBot but the build fails with 11 errors. Community members will probably not spend their time fixing the cBot. You will increase your chances of getting an answer if you provide a cBot that is working and make your questions more specific. For example, you say that you don't get valid numbers for the indicators. What numbers do you get and what would you expect to get?
If you could provide us with a working cBot as well as some numbers that you think are not valid, we would be more than happy to have a look at it.
Best Regards,
cTrader Team
@Spotware
Spotware
25 Jul 2017, 10:20
Hi GammaQuant,
There isn't any obvious issue in your code, so maybe you could try debugging your cBot in VS and add a try/catch around your POnBar() initialization code, like below, and check what is going wrong
try { var price = algo.MarketSeries.Open.LastValue; algo.Print("Hello World - Bar Open Price {0}", price); PrintInMainRobot(); } catch { }
Let us know if the above helps
Best Regards,
cTrader Team
@Spotware
Spotware
27 Jul 2017, 14:39
Hi obaum1,
Connect API does not offer this function. However, normalization requires a simple function like the following
The Symbol's step is provided by the Accounts API. You can get it using the following request
https://sandbox-api.spotware.com/connect/tradingaccounts/89214/symbols?oauth_token=test002_access_token
Based on your needs you can replace (int) with Math.Floor() or Math.Ceiling(). You can also add conditions for minimum and maximum quantity.
Best Regards,
cTrader Team
@Spotware