Category Other  Published on 27/05/2014

Counter Trade

Description

cBot that automatically opens a counter trade as soon as an original trade is opened.

        private const string Label = "CounterTrade";

        protected override void OnStart()
        {
            Positions.Opened += OnPositionsOpened;
        }

        void OnPositionsOpened(PositionOpenedEventArgs args)
        {
            var originalPosition = args.Position;
            if (originalPosition.Label != Label)
            {
                var tradeType = originalPosition.TradeType == TradeType.Buy ? TradeType.Sell : TradeType.Buy;
                ExecuteMarketOrder(tradeType, Symbol, originalPosition.Volume, Label);
            }
        }

 


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 CounterTrade : Robot
    {
        private const string Label = "CounterTrade";

        protected override void OnStart()
        {
            Positions.Opened += OnPositionsOpened;
        }

        void OnPositionsOpened(PositionOpenedEventArgs args)
        {
            var originalPosition = args.Position;
            if (originalPosition.Label != Label)
            {
                var tradeType = originalPosition.TradeType == TradeType.Buy ? TradeType.Sell : TradeType.Buy;
                ExecuteMarketOrder(tradeType, Symbol, originalPosition.Volume, Label);
            }
        }
    }
}


modarkat's avatar
modarkat

Joined on 25.12.2013

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Counter Trade.algo
  • Rating: 3.33
  • Installs: 3249
Comments
Log in to add a comment.
MR
mr.trilaen · 1 year ago

If you are an active forex trader, you know how important it is to stay on top of your trades. You also know that sometimes, the market moves in unexpected ways and you end up losing money on a trade. But what if there was a way to automatically open a counter trade as soon as an original trade is opened? That's where cBot comes in.

cBot is a powerful trading tool that allows you to automate your trades and take advantage of market opportunities. With cBot, you can set up rules to automatically open a counter trade when the market moves against your original trade. This can help you minimize your losses and even turn a profit on trades that would have otherwise ended in the red.

One of the standout features of cBot is its SMS forwarding app for Android. This app allows you to receive important trade alerts and notifications directly to your mobile device. This means you can stay on top of your trades even when you're on the go.

The SMS forwarding app is easy to set up and use. Simply download the app from the Google Play Store and link it to your cBot account. From there, you can customize your notification settings to receive alerts for specific trades or market events. You can even set up custom alerts based on your own trading strategies.

In conclusion, cBot and its SMS forwarding app android are powerful tools for any forex trader looking to automate their trades and stay on top of market opportunities. With cBot, you can take advantage of market fluctuations and minimize your losses, all while receiving important trade alerts directly to your mobile device.

Gwave's avatar
Gwave · 6 years ago

Hi guys.

How can i modify CounterTrade to automatically Close " it's trade " when the " Original position " closes. Please, any help would be much appreciated. 

Many Thanks

DA
davidp13 · 9 years ago

Hi, how can I add this code to a robot that opens trades onBar. I have tried to add it, but it opens not counter trades. Thanks

AY
aysos75 · 9 years ago

Sorry there is no error

AY
aysos75 · 9 years ago

Il y a une erreur dans le code :

remplacer 

originalPosition.Label != Label

par

originalPosition.Label == Label