Trading Software
    Menu Close

    JavaScript Framework for cTrader

    Mida is a JavaScript framework by that can be used with cTrader to trade financial assets such as stocks, crypto, forex or commodities, to create feature-rich web applications and analyze the markets.


    cTrader Javascript MIDA

    A JavaScript framework to easily operate in global financial markets


    cTrader Mida Libraries

    There is a core Mida library that you need to download and then a plugin for it to work with cTrader.


    How to Execute a Market Order

    The example code below shows how you can connect to a cTrader broker account, you will need to get a clientId, clientSecret and accessToken by creating an account on cTrader Open API.


    const { Mida, MidaBroker, } = require("@reiryoku/mida");
    // Use the Mida cTrader plugin
    // Login into any cTrader broker account
    const myAccount = await MidaBroker.login("cTrader", {
        clientId: "",
        clientSecret: "",
        accessToken: "",
        cTraderBrokerAccountId: "",


    To execute a short market order with no stop loss or take profit for EURUSD you can use the following code block.


    const { MidaBrokerOrderDirection, } = require("@reiryoku/mida");
    const myOrder = await myAccount.placeOrder({
        symbol: "EURUSD",
        direction: MidaBrokerOrderDirection.SELL,
        volume: 0.1,


    The following code block shows how you can submit a long market order with a take profit and stop loss.


    const { MidaBrokerOrderDirection, } = require("@reiryoku/mida");
    const symbol = "EURUSD";
    const lastBid = await myAccount.getSymbolBid(symbol);
    const myOrder = await myAccount.placeOrder({
        direction: MidaBrokerOrderDirection.BUY,
        volume: 0.1,
        protection: {
            stopLoss: lastBid - 0.0010, // <= SL 10 pips
            takeProfit: lastBid + 0.0030, // <= TP 30 pips


    How to check the order submission status from the broker.


    if (myOrder.isRejected) {
        switch (myOrder.rejectionType) {
            case MidaBrokerOrderRejectionType.MARKET_CLOSED: {
                console.log("#AAPL market is closed!");
            case MidaBrokerOrderRejectionType.NOT_ENOUGH_MONEY: {
                console.log("You don't have enough money in your account!");
            case MidaBrokerOrderRejectionType.INVALID_SYMBOL: {
                console.log("Your broker account doesn't support trading Apple stocks!");


    Real-Time Economic Rates & News

    The Apollo JavaScript library gets real-time economic declarations from such as inflation rates, unemployment rates & interest rates reported by governments and other entities.


    NameIdValue typeSource/s
    U.S. Non Farm Payrolls (MoM)US/NonFarmPayrolls/MoMPure
    U.S. Crude Oil Inventories (WoW)US/CrudeOilInventories/WoWPure
    Eurozone CPI (YoY)Eurozone/CPI/
    Italy CPI (YoY)Italy/CPI/
    Japan CPI (YoY)Japan/CPI/
    Canada Interest Rate CPI (MoM)Canada/InterestRate/


    This is a basic list of economic factors, it is possible to edit a file and add more to the list and customise it to your needs.


    Usage Code Example 

    First, you have to choose an economic factor and then request its declarations.


    const { ApolloEconomicFactor } = require("@reiryoku/apollo");
    const japanInflationRate = ApolloEconomicFactor.getById("Japan/CPI/YoY");
    const lastDeclaration = await japanInflationRate.getLastDeclaration();
    console.log(`Japan inflation rate is ${lastDeclaration.actualValue}%`);
    console.log(`The last declaration was made on ${}`);


    Web Applications

    By using a Javascript framework to connect to a cTrader broker to submit and manage orders as well as get the account information, a person can create a simple or complex web page that will be accessible to anyone with a web browser.

    The Real-Time Economic Rates library can be used to display on your web page real news events as they happen.



    There are various levels of support for this framework, as it is still fairly new the amount of documentation is limited, but we hope that at ClickAlgo we can fill that gap to help.