Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

Algomojo Button Trading Expert Advisor for Metatrader 4 Platform

4 min read

Here is a video tutorial and button trading expert advisor code for MetaTrader 4 platform. You can use the expert advisor to send automated orders to the Algomojo Platform with just the click of a button.

How to Send Automated Orders to Metatrader 4 Platform

You have to follow the 6 steps to send automated orders

Step 1: Make sure you have a trading account with Algomojo Partner Broker. If not get one. Login to your Algomojo Partner Broker Account.

Step 2. Download and Install the Multi Broker Bridge

Step 3: Download the Algomojo Expert Advisor and Copy the Expert Advisor File Button Trading – Algomojo.ex4

Step 4: Open your Metatader 4 Platform and Goto File ->Open Data Folder->Open MQL4/Experts Folder->Paste the Button Trading – Algomojo.ex4 as shown below

Step 5: Configuring the Algomojo Expert Advisor

i)Drag and drop the Expert Advisor to the charts
ii)Enable Allow DLL Imports from the common menu of Expert Advisor Properties


iii)Set the API key and API Secret key that you receive from the Algomojo My API section . Now set the appropriate exchange (NSE,NFO, MCX..etc) and select the appropriate symbol, order details , enter the broker shortcode and API version and Enable_Algo = True and Press the OK Button

Step 6 : Press the Buy or Sell Button to send Automated orders from Metatrader 4 to MQL4 trading terminal and check out the same in the expert advisor log section

Watch this video tutorial to configure AlgmojoButtons Expert Advisor and Send Automated Orders to your broker account.

In case if you need any assistance kindly check with Algomojo Tech support team or send a email at [email protected]

Download Algomojo MQL4 code

//+------------------------------------------------------------------+
//|                                    Button Trading - Algomojo.mq4 |
//|                            Copyright 2022, Finfolab Technologies |
//|                               Website : https://www.algomojo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Algomojo"
#property link      "https://www.algomojo.com"
#property version   "1.00"
#property strict
#property strict
#property script_show_inputs
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+



//Algomojo Autotrading Modules


input string apikey = "xxxxxxxxxxxxxxxxxxxxxx"; //Enter your API key here
input string apisecret = "xxxxxxxxxxxxxxxxxxxxxx"; //Enter your API secret key here
input string ver = "v1"; //API Version



enum exch{
   NSE,
   BSE,
   NFO,
   MCX,
   CDS,
};

enum otype{
   MARKET
    
};

enum ptype{
   MIS,
   NRML,
   CNC
   
};



enum br{
   an,
   ab,
   fs,
   fy,
   gc,
   sm,
   up,
   zb,
   ze
   
};

enum split{
   NO,
   YES
   
};


input br broker = an; 
input string strategy = "Metatrader Strategy";
input exch exchange = NSE;
input string symbol = "BHEL-EQ"; //Symbol Name
input ptype product =MIS; // Product Code
input otype pricetype =MARKET; // Order Type
input int quantity = 1;
input int price = 0;
input int disclosed_quantity = 0;


input int trigger_price = 0;
input string amo = "NO";
input split splitorder = NO;
input int split_quantity = 1;



string response;
string api_data;


#import "AMMT4BRIDGE.dll"
     string AMDispatcher(string api_key, string api_secret, string api_name, string api_data, string br_code, string version);
#import


extern bool Enable_Algo = false;

//+------------------------------------------------------------------+
//| PlaceOrder  function                                               |
//+------------------------------------------------------------------+  


void PlaceOrder(string action, int orderqty)
   {
  
     //Algomojo Place Buy Order


      api_data ="{ \"broker\": \""+EnumToString(broker)+"\",      \"strategy\":\""+strategy+"\",            \"exchange\":\""+EnumToString(exchange)+"\",             \"symbol\":\""+symbol+"\",            \"action\":\""+action+"\",            \"product\":\""+EnumToString(product)+"\",            \"pricetype\":\""+EnumToString(pricetype)+"\",            \"quantity\":\""+IntegerToString(orderqty)+"\",            \"price\":\""+IntegerToString(price)+"\",                  \"disclosed_quantity\":\""+IntegerToString(disclosed_quantity)+"\",            \"trigger_price\":\""+IntegerToString(trigger_price)+"\",            \"amo\":\""+amo+"\",            \"splitorder\":\""+EnumToString(splitorder)+"\",            \"split_quantity\":\""+IntegerToString(split_quantity)+"\"    }"; 
      response=AMDispatcher(apikey, apisecret,"PlaceOrder",api_data,"am",ver);
      Print("api : " ,api_data);
      Print("Algomojo Order response : " ,response);
      Alert(symbol+": "+action+ " Order Placed");
      
    }
    
    void ExitOrder(string action, int position_size)
   {
  
     //Algomojo Place Buy Order


      api_data ="{ \"broker\": \""+EnumToString(broker)+"\",            \"strategy\":\""+strategy+"\",             \"exchange\":\""+EnumToString(exchange)+"\",            \"symbol\":\""+symbol+"\",            \"action\":\""+action+"\",            \"product\":\""+EnumToString(product)+"\",            \"pricetype\":\""+EnumToString(pricetype)+"\",            \"quantity\":\""+"0"+"\",            \"price\":\""+IntegerToString(price)+"\",             \"position_size\":\""+IntegerToString(position_size)+"\",                         \"disclosed_quantity\":\""+IntegerToString(disclosed_quantity)+"\",            \"trigger_price\":\""+IntegerToString(trigger_price)+"\",            \"amo\":\""+amo+"\",            \"splitorder\":\""+EnumToString(splitorder)+"\",             \"split_quantity\":\""+IntegerToString(split_quantity)+"\"     }"; 

      response=AMDispatcher(apikey, apisecret,"PlaceSmartOrder",api_data,"am",ver);
      Print("api : " ,api_data);
      Print("Algomojo Order response : " ,response);
      Alert(symbol+": Exit "+action+ " Order Placed");
      
    }
 

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   //if(IsTesting())
     {
      string name;
      string heading[4]={"Long Entry","Long Exit","Short Entry","Short Exit"};
      int xc=5;
      int yc=30;
      int xsize = 500;
      int ysize = 300;
      for(int i=0;i<4;i++)
        {
         name=heading[i];
         ObjectCreate(0,name,OBJ_BUTTON,0,0,0);
         ObjectSetText(name,name,16,"Arial",clrWhite);
         ObjectSetInteger(0,name,OBJPROP_XSIZE,xsize);
         ObjectSetInteger(0,name,OBJPROP_XSIZE,ysize);
         ObjectSetInteger(0,name,OBJPROP_XDISTANCE,xc);
         ObjectSetInteger(0,name,OBJPROP_YDISTANCE,yc);
         ObjectSetInteger(0,name,OBJPROP_COLOR,clrWhite);
         if(i==0)
         {
         ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clrGreen);
         }
         if(i==1)
         {
         ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clrTomato);
         }
         if(i==2)
         {
         ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clrOrangeRed);
         }
         if(i==3)
         {
         ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clrLime);
         }
         yc+=20;
        }

     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  //Delete the Buttons
  string ButtonName;
  string heading[4]={"Long Entry","Long Exit","Short Entry","Short Exit"};
  for(int i=0;i<4;i++)
        {
         ButtonName=heading[i];
         ObjectDelete(ButtonName);
         }
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  }
  
  
  
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id==CHARTEVENT_OBJECT_CLICK)
     {
  
      if(ObjectGetInteger(0,"Long Entry",OBJPROP_STATE)==true)
        {
        if(Enable_Algo){
         //Algomojo Place Buy Order - Double the Quantity

         ObjectSetInteger(0,"Long Entry",OBJPROP_STATE,false);
         PlaceOrder("BUY",quantity);
         }
        }
     
      if(ObjectGetInteger(0,"Short Entry",OBJPROP_STATE)==true)
        {
         if(Enable_Algo){
         //Algomojo Place Buy Order - Double the Quantity
         ObjectSetInteger(0,"Short Entry",OBJPROP_STATE,false);
         PlaceOrder("SELL",quantity);
         }
        }
      
      if(ObjectGetInteger(0,"Long Exit",OBJPROP_STATE)==true)
        {
         if(Enable_Algo){
         //Algomojo Place Buy Order - Double the Quantity
         ObjectSetInteger(0,"Long Exit",OBJPROP_STATE,false);
         ExitOrder("SELL",0);
         }
        }
      
      if(ObjectGetInteger(0,"Short Exit",OBJPROP_STATE)==true)
        {
         if(Enable_Algo){
         //Algomojo Place Buy Order - Double the Quantity
         ObjectSetInteger(0,"Short Exit",OBJPROP_STATE,false);
         ExitOrder("BUY",0);
         }
        }
     }
     
     
     
     
//---
 
  }
Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

Metatrader 4 – Simple Expert Advisor for Algomojo Platform

f writing a simple expert advisor for Metatrader 4 to send automated orders from MT4 to Algomojo - Cloud-Based Trading Platform. This tutorial provides...
Rajandran R
1 min read

How to Send Orders from Metatrader 4 Expert Advisor…

This tutorial helps you to convert your Metatrader 4 expert advisor to send automated orders to the Algomojo Platform. Currently, Algomojo supported brokers are...
Rajandran R
2 min read

Algomojo Now Supports Multi-Client Trading with Amibroker, Metatrader, Python,…

Yes, from now onwards Multi-Account Execution from trading tools like Amibroker, Metatrader 4 and Metatrader 5, Ninjatrader 7, Ninjatrader 8, Excel is now possible...
Rajandran R
1 min read

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More