TE
Topics
02 Jul 2014, 13:07
2332
2
02 Jul 2014, 04:02
0
2863
2
01 Jul 2014, 13:45
2732
2
09 Jun 2014, 12:50
2912
4
06 Jun 2014, 17:19
3563
3
05 Jun 2014, 17:12
2965
2
08 May 2014, 17:38
2813
1
07 May 2014, 07:20
3754
1
Replies
tete13
09 Jun 2014, 13:09
Sorry. The code did not indicate correctlty.
using System; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class Stoporder : Robot { [Parameter("News Day (1-5)", DefaultValue = 1, MinValue = 1, MaxValue = 5)] public int NewsDay { get; set; } [Parameter("News Hour", DefaultValue = 9, MinValue = 0, MaxValue = 23)] public int NewsHour { get; set; } [Parameter("News Minute", DefaultValue = 30, MinValue = 0, MaxValue = 59)] public int NewsMinute { get; set; } [Parameter("Volume", DefaultValue = 10000, MinValue = 10000)] public int Volume { get; set; } [Parameter("Seconds Before", DefaultValue = 30, MinValue = 1)] public int SecondsBefore { get; set; } private bool _ordersCreated; private const string Label = "News Robot"; protected override void OnStart() { MarketData.GetMarketDepth(Symbol).Updated += PlaceStopOrders; } // Place stop order protected override void OnTick() { PlaceStopOrders(); } void PlaceStopOrders() { 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 <= SecondsBefor) { _ordersCreated = true; var SellStop1 = Symbol.Bid - 50 * Symbol.PipSize; PlaceStopOrder(TradeType.Sell, Symbol, Volume, SellStop1); } } } } }
@tete13
tete13
09 Jun 2014, 12:56
1. Place a sell stop order at specificed time (ex: 30s before news).
In this step, I want to place a sell stop order 30s before news, the open price is far from current market price (let's say 50 pips) without stop loss, take profit and expiration time.
I use this code and it works well.
using System; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class Stoporder : Robot { [Parameter("News Day (1-5)", DefaultValue = 1, MinValue = 1, MaxValue = 5)] public int NewsDay { get; set; } [Parameter("News Hour", DefaultValue = 9, MinValue = 0, MaxValue = 23)] public int NewsHour { get; set; } [Parameter("News Minute", DefaultValue = 30, MinValue = 0, MaxValue = 59)] public int NewsMinute { get; set; } [Parameter("Volume", DefaultValue = 10000, MinValue = 10000)] public int Volume { get; set; } [Parameter("Seconds Before", DefaultValue = 30, MinValue = 1)] public int SecondsBefore { get; set; } private bool _ordersCreated; private const string Label = "News Robot"; protected override void OnStart() { MarketData.GetMarketDepth(Symbol).Updated += PlaceStopOrders; } // Place stop order protected override void OnTick() { PlaceStopOrders(); } void PlaceStopOrders() { 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 SellStop1 = Symbol.Bid - 50 * Symbol.PipSize; PlaceStopOrder(TradeType.Sell, Symbol, Volume, SellStop1); } } } } }
@tete13
tete13
09 Jun 2014, 13:17
Step 2: Modify sell stop order just before news (ex: 5s before news)
I want to modify sell stop order just 5s before the news. Let's assume I want the open price is 10 pips away from current price, stop loss is 30 pips, take profit is 60 pips, expiration time is 15s after the news.
I add the following code into my Cbot:
There was not any error when I built the cBot, however price was not modified.
Can you help me point out the mistake in this code?
I also added 2 parameters into cBot
@tete13