Topics
Replies
admin
20 Nov 2012, 16:22
All platforms always host limit and stop orders. This includes cTrader, ECNs, aggregators, etc. They are almost never hosted with individual Bank LPs. This is due to the fact that (1) you never know what Bank LP will quote the required price first and (2) the Banks do not provide such functionality. Limits and Stops are then sent to the LP when the price is triggered. Price advantage is still probable for Limits. Also, what makes cTrader different is that (1) it is located right next to the LPs, (2) that there is no need for unnatural hops (i.e. bridges) because we operate over FIX and (3) cTrader treats resting orders as Limits and Stops respectively, not as Market Orders like some other platforms do.
@admin
admin
20 Nov 2012, 16:21
All platforms always host limit and stop orders. This includes cTrader, ECNs, aggregators, etc. They are almost never hosted with individual Bank LPs. This is due to the fact that (1) you never know what Bank LP will quote the required price first and (2) the Banks do not provide such functionality. Limits and Stops are then sent to the LP when the price is triggered. Price advantage is still probable for Limits. Also, what makes cTrader different is that (1) it is located right next to the LPs, (2) that there is no need for unnatural hops (i.e. bridges) because we operate over FIX and (3) cTrader treats resting orders as Limits and Stops respectively, not as Market Orders like some other platforms do.
@admin
admin
20 Nov 2012, 11:56
Here it is
How do I correct this please? I need the exact code that can make the necessary corrections so it can start working properly and place the 2 pending stop orders as required of the robot.
using System; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot] public class NewsRobot : Robot { [Parameter("News Day (1-5)", DefaultValue=1, MinValue=1, MaxValue=5)] public int NewsDay { get; set; } [Parameter("News Hour", DefaultValue=14, MinValue=0, MaxValue=23)] public int NewsHour { get; set; } [Parameter("News Minute", DefaultValue=30, MinValue=0, MaxValue=59)] public int NewsMinute { get; set; } [Parameter("Pips away", DefaultValue=10)] public int PipsAway { get; set; } [Parameter("Take Profit", DefaultValue=50)] public int TakeProfit { get; set; } [Parameter("Stop Loss", DefaultValue=10)] public int StopLoss { get; set; } [Parameter("Volume", DefaultValue=100000, MinValue=1000)] public int Volume { get; set; } [Parameter("Seconds Before", DefaultValue=5, MinValue=1)] public int SecondsBefore { get; set; } [Parameter("Seconds Timeout", DefaultValue=10, MinValue=1)] public int SecondsTimeout { get; set; } [Parameter("One Cancels Other", DefaultValue=1, MinValue=0, MaxValue=1)] public int Oco { get; set; } private bool _ordersCreated; private PendingOrder _buyOrder; private PendingOrder _sellOrder; protected override void OnTick() { if ((int)Server.Time.DayOfWeek == NewsDay && !_ordersCreated) { var triggerTime = new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, NewsHour, NewsMinute, 0); if (Server.Time <= triggerTime && (triggerTime - Server.Time).TotalSeconds <= SecondsBefore) { _ordersCreated = true; var expirationTime = triggerTime.AddSeconds(SecondsTimeout); var sellOrderTargetPrice = Symbol.Bid - PipsAway * Symbol.PipSize; Trade.CreateSellStopOrder(Symbol, Volume, sellOrderTargetPrice, sellOrderTargetPrice + StopLoss * Symbol.PipSize, sellOrderTargetPrice - TakeProfit * Symbol.PipSize, expirationTime); var buyOrderTargetPrice = Symbol.Ask + PipsAway * Symbol.PipSize; Trade.CreateBuyStopOrder(Symbol, Volume, buyOrderTargetPrice, buyOrderTargetPrice - StopLoss * Symbol.PipSize, buyOrderTargetPrice + TakeProfit * Symbol.PipSize, expirationTime); } } } protected override void OnPendingOrderCreated(PendingOrder newOrder) { if (newOrder.TradeType == TradeType.Buy) _buyOrder = newOrder; else _sellOrder = newOrder; } protected override void OnPositionOpened(Position openedPosition) { if (Oco == 1) { Trade.DeletePendingOrder(_buyOrder); Trade.DeletePendingOrder(_sellOrder); } } } }
@admin
admin
26 Nov 2012, 09:34
Yes, the only problem is in the backtesting and it only affects code with referenced indicators.
@admin