![]() |
|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
![]() |
|
Опции темы | Поиск в этой теме |
![]() |
#1 |
Новичок
Джуниор
Регистрация: 22.05.2014
Сообщений: 2
|
![]()
К имеющемуся коду надо добавить еще один Parameter "Slippage".
Это можно зделать так: Cancel Pending Order The cancel an order the syntax is CancelPendingOrder(order); Where order is of type PendingOrder. Example 1 - Cancel all the orders that have the label “myLabel”. Code [Robot()] public class Sample_cBot : Robot { protected override void OnTick() { foreach (var order in PendingOrders) { if (order.Label == "myLabel") { CancelPendingOrder(order); } } } } или же так: Cancel Pending Orders Asynchronously Example 1 – Cancel all pending orders. Code [Robot()] public class Sample_cBot : Robot { protected override void OnBar() { foreach (var pendingOrder in PendingOrders) { CancelPendingOrderAsync(pendingOrde r); } } } Log Output | cBot "Sample_cBot" was started successfully for EURUSD, h1. | Cancelling pending order OID253328 | → Cancelling pending order OID253328 SUCCEEDED, PendingOrder OID253328 Example 2 – Cancel pending orders with label myLabel Code [Robot()] public class Sample_cBot : Robot { protected override void OnBar() { foreach (var pendingOrder in PendingOrders) { if (pendingOrder.Label == "myLabel") CancelPendingOrderAsync(pendingOrde r); } } } Я не знаю какой вариант лутче. Смысл в том, что параметра [Parameter("Pips away", DefaultValue = 10)] public int PipsAway { get; set; } явно не достаточно. Если значение [Parameter("Pips away", DefaultValue = 10)] public int PipsAway { get; set; } БОЛЬШЕ 13 (>13), необходимо что бы выполнялось команда Cancel Pending Order или Cancel Pending Orders Asynchronously. Ниже преведен весь код бота, которого нужно дополнить. Пожалуйста напишите это дополнение. Language: C# Trading Platform: cAlgo using System; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewsRobot : Robot { [Parameter("Pips away", DefaultValue = 10)] public int PipsAway { get; set; } protected override void OnStart() { MarketData.GetMarketDepth(Symbol).U pdated += PlaceStopOrders; Positions.Opened += OnPositionOpened; } 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 expirationTime = triggerTime.AddSeconds(SecondsTimeo ut); var sellOrderTargetPrice = Symbol.Bid - PipsAway * Symbol.PipSize; PlaceStopOrder(TradeType.Sell, Symbol, Volume, sellOrderTargetPrice, Label, StopLoss, TakeProfit, expirationTime); var buyOrderTargetPrice = Symbol.Ask + PipsAway * Symbol.PipSize; PlaceStopOrder(TradeType.Buy, Symbol, Volume, buyOrderTargetPrice, Label, StopLoss, TakeProfit, expirationTime); } } } private void OnPositionOpened(PositionOpenedEven tArgs args) { var position = args.Position; if (position.Label == Label && position.SymbolCode == Symbol.Code) { if (Oco) { foreach (var order in PendingOrders) { if (order.Label == Label && order.SymbolCode == Symbol.Code) { CancelPendingOrderAsync(order); } } } Stop(); } } } } |
![]() |
![]() |
![]() |
![]() |
||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Как добавить новый элемент в массив? Ассемблер | Пиф | Assembler - Ассемблер (FASM, MASM, WASM, NASM, GoASM, Gas, RosAsm, HLA) и не рекомендуем TASM | 2 | 07.03.2013 16:51 |
Добавить запуск через параметр | Dzib | Assembler - Ассемблер (FASM, MASM, WASM, NASM, GoASM, Gas, RosAsm, HLA) и не рекомендуем TASM | 2 | 08.09.2012 19:31 |
Как в редактор кода Delphi 7 добавить новый шрифт? | lexaltd | Общие вопросы Delphi | 13 | 22.06.2012 18:34 |
Как добавить новый язык в среду Delphi | Яшар | Общие вопросы Delphi | 9 | 15.03.2011 08:50 |
Как выполнить поиск по XML файлу и добавить к нему новый узел в Delphi? | LexaL | Помощь студентам | 0 | 24.12.2010 17:12 |