CT
Topics
17 Mar 2021, 01:32
939
4
11 Mar 2021, 10:08
751
4
25 Mar 2020, 04:55
1028
3
Replies
ctid444989
31 Mar 2020, 05:20
RE: Thank you.
PanagiotisCharalampous said:
Hi,
You can use PositionCloseReason to check if a position is closed by a stop loss. See below
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { Positions.Closed += Positions_Closed; } private void Positions_Closed(PositionClosedEventArgs obj) { if (obj.Reason == PositionCloseReason.StopLoss) { } } protected override void OnTick() { // Put your core logic here } protected override void OnStop() { // Put your deinitialization logic here } } }
Best Regards,
Panagiotis
@ctid444989
ctid444989
11 Mar 2021, 12:27
RE:
PanagiotisCharalampous said:
Hi Panagiotis,
I was trying to build some old code...
Error CS0618: 'cAlgo.API.Robot.ExecuteMarketOrder(cAlgo.API.TradeType, cAlgo.API.Internals.Symbol, long, string, double?, double?)' is obsolete: 'Parameter 'Symbol symbol' was replaced with 'string symbolName'. More details here https://ctrader.com/forum/whats-new/#ToBeReplace'
I have quite a lot of these type of warnings.
Mike
@ctid444989