Reverse Position For All Open Trades?

12 Jun 2019, 04:51Reverse Position For All Open Trades?#1
bitmextposts: 2since: 12 Jun 2019

Hello , wish you well.

 

First of all , I would like to thank you for your amazing platform. I hope you continue your excellent work.

 

I really like the feature of 'Reverse position' , However sometimes I open several at different entry points and I was wondering how do I Reverse all of them with one click? Instead of single handedly clicking reverse on each which can be quite frustrating in moving markets.

I only trade one pair at a time so there are no worries about other positions reversing.

 

My technical knowledge is very little so I thought this would be the right place to ask.

 

Thank you.

12 Jun 2019, 09:35#2
Panagiotis Charalampousposts: 2868since: 13 Jan 2017

Hi bitmext,

Thanks for posting in our forum and for your nice feedback about the platform. There is no feature in the interface that would allow you to do so but you can achieve this by running a simple cBot. See the source code 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 ReversePositions : Robot
    {

        protected override void OnStart()
        {
            foreach (var position in Positions)
                position.Reverse();
            Stop();
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

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

Best Regards,

Panagiotis


Head of Community Management at cTrader
13 Jun 2019, 07:32RE:#3
bitmextposts: 2since: 12 Jun 2019

Panagiotis Charalampous said:

Hi bitmext,

Thanks for posting in our forum and for your nice feedback about the platform. There is no feature in the interface that would allow you to do so but you can achieve this by running a simple cBot. See the source code 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 ReversePositions : Robot
    {

        protected override void OnStart()
        {
            foreach (var position in Positions)
                position.Reverse();
            Stop();
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

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

Best Regards,

Panagiotis

I have just tested this on my Demo Account and it works perfectly !

Exactly what I needed, Thank you very much.