Replies

ctid444989
11 Mar 2021, 12:27

RE:

PanagiotisCharalampous said:

Hi ctid444989,

Where did you find this link?

Best Regards,

Panagiotis 

Join us on Telegram

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

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 

Join us on Telegram

 

 


@ctid444989