PoshTrader - Help Center
  • What is PoshTrader
  • 📌Getting started
    • Community guidelines
  • đŸ› ī¸ Accounts
    • Account settings
    • Recover your account
  • đŸ’ŗBilling & Payments
    • Billing and accepted payments
    • Refund Policy
  • đŸ“ĻProducts
    • How to install?
    • Updates and support
    • License activation
      • Free 7-day trial
  • đŸ’ŧAuthors
    • FAQ
    • Royalty details
    • Adding a product
    • Releasing an update
  • đŸ•šī¸ Developers
    • Best practices
    • Licensing library
      • Integration
        • cTrader
        • NinjaTrader 8
  • 📚Resources
    • Glossary
Powered by GitBook
On this page
  • Adding licensing to your indicator/cBot
  • Creating a distribution file

Was this helpful?

  1. đŸ•šī¸ Developers
  2. Licensing library
  3. Integration

cTrader

Guide on how to integrate licensing library into indicators and cBots

PreviousIntegrationNextNinjaTrader 8

Last updated 4 years ago

Was this helpful?

Adding licensing to your indicator/cBot

After you have created an indicator or robot you will need to integrate to validate users' licenses and protect your product from unauthorized distribution.

  1. Add as a reference using

  2. Import namespace of the library by adding using PoshTrader.Licensing;

  3. Add Item Attributes to the main class

  4. Grant Full Access rights so licensing can communicate with our server

  5. Declare ItemLicense object

  6. Create the license on startup

  7. Check license status during runtime

using System;
using cAlgo.API;
using PoshTrader.Licensing;

namespace cAlgo
{
    [Item(ID, "Sample Indicator", Version = "1.0.0", Author = "John Doe")]
    [Indicator(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class SampleIndicator : Indicator
    {
        private ItemLicense _license;

        protected override void Initialize()
        {
            _license = new ItemLicense(this);

            if (!_license.IsValid())
            {
                throw new Exception("Product license validation failed.");
            }

            // Put your Initialize logic here
        }

        public override void Calculate(int index)
        {
            if (!_license.IsValid())
                return;
                
            // Put your Calculate logic here
        }
    }
}
using System;
using cAlgo.API;
using PoshTrader.Licensing;

namespace cAlgo
{
    [Item(ID, "Sample Robot", Version = "1.0.0", Author = "John Doe")]
    [Indicator(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class SampleRobot : Robot
    {
        private ItemLicense _license;

        protected override void OnStart()
        {
            _license = new ItemLicense(this);

            if (!_license.IsValid())
            {
                throw new Exception("Product license validation failed.");
            }

            // Put your OnStart logic here
        }
    }
}

Tips: You can build an installation algo file by excluding Version in Item Attributes. This will allow you to publish installers of your indicators and cBots on the official cTrader website.

Creating a distribution file

To create the distribution file, please follow the steps below for creating an Algo file containing your indicators and/or robots.

  1. Navigate to the Automate tab in the left sidebar

  2. Select an indicator/robot you wish to export

  3. Press Build (Do NOT use Build with Source Code which would make your code unprotected!)

After you finish building your indicator/cBot you will find the distribution file as a .algo file located in %UserProfile%\Documents\cAlgo\Sources\ in Indicators or Robots folder.

See an example here:

https://ctrader.com/algos/indicators/show/2247
Licensing Library
Reference Manager
PoshTrader.Licensing.dll