How to Can I set one point as a take profit or stop loss to all opened positions

Created at 18 Jan 2018, 16:13
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MO

mosaddeqi@gmail.com

Joined 18.01.2018

How to Can I set one point as a take profit or stop loss to all opened positions
18 Jan 2018, 16:13


Hello Sir/Mam,

I wanna to set one point as a TP/SL in all open positions,

for example, I opened a lot of positions and by a bot, I want to set one fix point as a TP/SL to all open positions.

How can I do it?

 

Best regards


@mosaddeqi@gmail.com
Replies

PanagiotisCharalampous
18 Jan 2018, 16:20

Dear mosaddequ@gmail.com,

Thanks for posting in our forum. You can try something like the following

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {

        [Parameter(DefaultValue = 0.0)]
        public double StopLoss { get; set; }

        [Parameter(DefaultValue = 0.0)]
        public double TakeProfit { get; set; }

        protected override void OnStart()
        {
            foreach (var position in Positions)
            {
                ModifyPosition(position, StopLoss, TakeProfit);
            }
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

mosaddeqi@gmail.com
18 Jan 2018, 16:26

RE:

Thanks Panagiotis , I'm not a programmer, is it a ready one to use?

Panagiotis Charalampous said:

Dear mosaddequ@gmail.com,

Thanks for posting in our forum. You can try something like the following

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {

        [Parameter(DefaultValue = 0.0)]
        public double StopLoss { get; set; }

        [Parameter(DefaultValue = 0.0)]
        public double TakeProfit { get; set; }

        protected override void OnStart()
        {
            foreach (var position in Positions)
            {
                ModifyPosition(position, StopLoss, TakeProfit);
            }
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis

 


@mosaddeqi@gmail.com

PanagiotisCharalampous
18 Jan 2018, 16:32

Hi mosaddequ@gmail.com,

This cBot will modify your positions SL and TP on start based on preset values. If this is what you are looking for then yes, it is ready to use.

Best Regards,

Panagiotis


@PanagiotisCharalampous

mosaddeqi@gmail.com
19 Jan 2018, 08:50

RE:

Thank you very mutch Mr. Panagiotis, That's very usefull.

Panagiotis Charalampous said:

Hi mosaddequ@gmail.com,

This cBot will modify your positions SL and TP on start based on preset values. If this is what you are looking for then yes, it is ready to use.

Best Regards,

Panagiotis

 


@mosaddeqi@gmail.com