PacificFrontiere
https://t.me/OGtruce
PacificFrontiere's avatar

Info

Username:PacificFrontiere
Name:PacificFrontiere
Member since: 25 Apr 2020

Favorite symbols:

EURAUD

About

Experienced forex trader. Take a look at my strategy. https://ct.icmarkets.com/copy/strategy/11191

Signature

https://t.me/OGtruce

Last Algorithm Comments

@Waddah Attar with Alert:  22 Aug 2020, 09:07


You have done very very well Indeed. Can't thank you enough

Last Forum Posts

@Tamarisk Group -Strategy Provider:  22 Aug 2020, 17:43


Test 

@How can i block this demo account from following and stealing from me??:  14 Aug 2020, 18:13


How can i block a particular demo account from following me? I know he copies my trades to his own personal account and he does this to avoid paying fees! that is theft and this should not be allowed.

https://ct.icmarkets.com/copy/strategy/11191

@We need more HotKeys!!!!:  24 Jun 2020, 17:34


I am quite surprised that cTrader currently has very limited HotKey functions and I think the next version of cTrader should include hotkeys that does the following;

-Places buy or sell market order
-Places different types of limit and sell orders
-Closes all buy orders and/or closes all sell orders too
-To hedge position or open another position in the same direction.

I am sure a lot of people will agree that these will have a significant impact on the performance and efficiency of a Trader, especially the scalpers.

@We need more HotKeys!!!!:  24 Jun 2020, 17:33


I am quite surprised that cTrader currently has very limited HotKey functions and I think the next version of cTrader should include hotkeys that does the following;

-Places buy or sell market order
-Places different types of limit and sell orders
-Closes all buy orders and/or closes all sell orders too
-To hedge position or open another position in the same direction.

I am sure a lot of people will agree that these will have a significant impact on the performance and efficiency of a Trader, especially the scalpers.

@How do i copy from MT4 to Ctrader on the same computer:  20 Jun 2020, 14:22


rynfaxy said:

I am also having this question.

You would need a local MT4 EA to Ctrader Cbot copier system like i described above

reach me here ImanTheTrader's telegram

@How do i copy from MT4 to Ctrader on the same computer:  20 Jun 2020, 14:17


tgjobscv said:

tgjobscv said:

How copy to web based ctrader ?

No it is to copy to Ctrader desktop. and the link you posted- there is no MT4 sender EA.

You need the MT4 sender and the Ctrader Cbot receiver to successfully copy

@Cbot Client to connect to MT4 Server with ZeroMq sockets:  31 May 2020, 23:07


Hi there,

In my quest to establish a trade copying system between MT4 and Ctrader, I installed MQL-ZMQ bindings and have my MT4 running as a server.

The last hurdle is having a working Cbot receiver that picks from the MT4 Server.

I will attach the MT4ServerZmq.Mq4 file which i hope will be of use in modifying the Cbot receiver sample code i also have attached.

The MT4serverZmq code:

#property copyright "Copyright 2020, Toki"
#property link      "tobioluwatoki@gmail.com"
#property version   "1.00"
#property strict
#property show_inputs

#include <Mql/Lang/Script.mqh>
#include <Mql/Format/Resp.mqh>
#include <Mql/Lang/Hash.mqh>
#include <Zmq/Zmq.mqh>
#include "CommandProcessor.mqh"
//+------------------------------------------------------------------+
//| A tcp client connection                                          |
//+------------------------------------------------------------------+
class TcpClient
  {
private:
   uchar             m_id[];
public:
                     TcpClient(ZmqMsg &msg)
     {
      PrintFormat(">>> Debug: client id is %d bytes",msg.size());
      msg.getData(m_id);
     }
   bool              equals(const TcpClient *client) const
     {
      return ArrayCompare(m_id, client.m_id) == 0;
     }
   int               hash() const
     {
      return (int)MurmurHash3_x86_32(m_id,0x7e34a273);
     }
  };
//+------------------------------------------------------------------+
//| For using TcpClient in a HashMap                                 |
//+------------------------------------------------------------------+
class TcpClientEqualityComparer: public EqualityComparer<TcpClient*>
  {
public:
   bool              equals(const TcpClient *left,const TcpClient *right) const
     {
      return left.equals(right);
     }
   int               hash(const TcpClient *value) const
     {
      return value.hash();
     }
  };
//+------------------------------------------------------------------+
//| Mt4ServerRaw Parameters                                          |
//+------------------------------------------------------------------+
class Mt4ServerRawParam: public AppParam
  {
   ObjectAttr(string,listenAddresss,ListenAddress);
public:
   bool              check() {return true;}
  };
//+------------------------------------------------------------------+
//| A ZMQ STREAM server that receives command from raw tcp clients   |
//| and returns the results                                          |
//| This server enables a user to use a standard Redis client (like  |
//| the redis-cli) to send commands to a mt4 terminal instance       |
//+------------------------------------------------------------------+
class Mt4ServerRaw: public Script
  {
private:
   string            m_address;
   Context           m_context;
   HashMap<TcpClient*,RespStreamParser*>m_clients;
   Socket            m_socket;

   uchar             m_commandBuffer[];
   uchar             m_replyBuffer[];

   CommandProcessor *m_processor;
public:
                     Mt4ServerRaw(Mt4ServerRawParam *param)
   :m_address(param.getListenAddress()),m_clients(new TcpClientEqualityComparer,true),m_socket(m_context,ZMQ_STREAM)
     {
      if(!m_socket.bind(m_address))
        {
         fail(StringFormat(">>> Error binding to %s: %s",m_address,Zmq::errorMessage(Zmq::errorNumber())));
         return;
        }
      m_socket.setStreamNotify(true); // notify connect/disconnect
      m_processor=new TradeCommandProcessor;
     }
                    ~Mt4ServerRaw() {delete m_processor;}
   void              main(void);
  };
//+------------------------------------------------------------------+
//| A server that receives command from the client and returns the   |
//| results                                                          |
//+------------------------------------------------------------------+
void Mt4ServerRaw::main()
  {
//  Initialize poll set
   PollItem items[1];
   m_socket.fillPollItem(items[0],ZMQ_POLLIN);
   while(!IsStopped())
     {
      ZmqMsg id;
      ZmqMsg request;
      int ret=Socket::poll(items,500);
      if(ret==-1)
        {
         Print(">>> Polling input failed: ",Zmq::errorMessage(Zmq::errorNumber()));
         continue;
        }
      if(!items[0].hasInput()) continue;

      if(!m_socket.recv(id))
        {
         Print(">>> Failed retrieve client id: ",Zmq::errorMessage(Zmq::errorNumber()));
         continue;
        }

      TcpClient *client=new TcpClient(id);
      RespStreamParser *parser=NULL;

      if(!m_clients.contains(client))
        {
         Print(">>> New client from ",id.meta("Peer-Address"));

         if(!m_socket.recv(request))
           {
            Print(">>> Failed receive connection: ",Zmq::errorMessage(Zmq::errorNumber()));
           }
         else
           {
            parser=new RespStreamParser;
            m_clients.set(client,parser);
           }
         continue;
        }
      else
        {
         parser=m_clients[client];
         if(!m_socket.recv(request))
           {
            Print(">>> Failed receive request: ",Zmq::errorMessage(Zmq::errorNumber()));
            m_clients.remove(client);
            SafeDelete(client);
            continue;
           }
         else
           {
            //--- if the client closes the connection
            if(request.size()==0)
              {
               m_clients.remove(client);
               SafeDelete(client);
               continue;
              }
           }
        }

      ArrayResize(m_commandBuffer,request.size(),100);
      request.getData(m_commandBuffer);
      parser.feed(m_commandBuffer);
      RespValue *command=parser.parse();
      RespValue *reply;
      if(command==NULL)
        {
         if(parser.getError()!=RespParseErrorNeedMoreInput)
           {
            string error=EnumToString(parser.getError());
            Print(">>> Error parsing command: ",error);
            reply=new RespError(error);
           }
         else continue;
        }
      else if(command.getType()!=RespTypeArray)
        {
         Print(">>> Invalid command: ","Command is not a RespArray");
         reply=new RespError("Command is not a RespArray");
        }
      else
        {
         RespArray *c=dynamic_cast<RespArray*>(command);
         Print(">>> Received command: ",c.toString());
         reply=m_processor.process(c);
        }

      ArrayResize(m_replyBuffer,0,100);
      //--- the client is trying to disconnect from the server if the reply is NULL
      ZmqMsg response(reply==NULL?0:reply.encode(m_replyBuffer,0));
      if(reply!=NULL)
        {
         response.setData(m_replyBuffer);
        }
      else
        {
         m_clients.remove(client);
        }
      SafeDelete(command);
      if(reply!=Nil) SafeDelete(reply);
      SafeDelete(client);

      if(!m_socket.sendMore(id) || !m_socket.send(response))
        {
         Alert(StringFormat(">>> Critical error: failed to send response to client!!! (%s)",
               Zmq::errorMessage(Zmq::errorNumber())
               ));
        }
     }
  }

BEGIN_INPUT(Mt4ServerRawParam)
   INPUT(string,ListenAddress,"tcp://127.0.0.1:6666"); // Mt4 Server Listen Address
END_INPUT

DECLARE_SCRIPT(Mt4ServerRaw,true)
//+------------------------------------------------------------------+

Cbot receiver sample:

 protected override void OnStart()
        {

            using (var context = new Context(1))
            {
                using (Socket requester = context.Socket(SocketType.ROUTER))
                {
                    requester.Bind("tcp://*:5999");
                    System.Threading.Thread.Sleep(1000);
                    double high = consulta(context,requester,"USDJPY","High",100)
                }
            }

}

         private double consulta(ZMQ.Socket requester, string Ativo, String Series, int periodo)
        {

            requester.SendMore(Ativo, Encoding.Unicode);
            requester.SendMore(Series, Encoding.Unicode);
            requester.Send(Convert.ToString(periodo), Encoding.Unicode);
            requester.Recv();
            string buffer = requester.Recv(Encoding.Unicode);
            return Convert.ToDouble(buffer);

        }

}

@MT4 to Ctrader Trade copier using .csv file communicate:  28 May 2020, 09:40


firemyst said:

Does it print out an exception?

If not, after you read the file in, print out a random line number (like 5) to the log and see if it prints anything.

this will at least confirm whether or not it's reading the file in.

I appreciate your response,

This is the error message that generates right before the bot crashes.

28/05/2020 06:33:44.134 | New cBot, EURUSD, m1 | Crashed in OnTick with NullReferenceException: Object reference not set to an instance of an object.

This error comes after the log prints out number one (1). so that confirms it's reading the file in

@MT4 to Ctrader Trade copier using .csv file communicate:  26 May 2020, 09:39


Hello there,

I have the MT4 trade sender EA that sends orders to a file named TradeCopy.csv in the MQL directory on my computers hard-drive. Which appears to be working just fine

however i also have a Ctrader Cbot that is supposed to read this TradeCopy.csv and take orders from it but it doesn't seem to be working despite the fact that the file path in the code is correct.

Please take a look at the two codes.

The first one is the MT4 Trade sender EA

int delay=1000;
int start,TickCount;
int Size=0,PrevSize=0;
int cnt,TotalCounter;
string cmt;
string nl="\n";

int OrdId[],PrevOrdId[];
string OrdSym[],PrevOrdSym[];
int OrdTyp[],PrevOrdTyp[];
double OrdLot[],PrevOrdLot[];
double OrdPrice[],PrevOrdPrice[];
double OrdSL[],PrevOrdSL[];
double OrdTP[],PrevOrdTP[];


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {

  while(!IsStopped()) {
    start=GetTickCount();
    cmt=start+nl+"Counter: "+TotalCounter;
    get_positions();
    if(compare_positions()) save_positions();
    Comment(cmt);
    TickCount=GetTickCount()-start;
    if(delay>TickCount)Sleep(delay-TickCount-2);
  }
  Alert("end, TradeCopy EA stopped");
  Comment("");
  return(0);


//----

}


void get_positions() {
  Size=OrdersTotal();
  if (Size!= PrevSize) {
    ArrayResize(OrdId,Size);
    ArrayResize(OrdSym,Size);
    ArrayResize(OrdTyp,Size);
    ArrayResize(OrdLot,Size);
    ArrayResize(OrdPrice,Size);
    ArrayResize(OrdSL,Size);
    ArrayResize(OrdTP,Size);
  }

  for(int cnt=0;cnt<Size;cnt++) {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    OrdId[cnt]=OrderTicket();
    OrdSym[cnt]=OrderSymbol();
    OrdTyp[cnt]=OrderType();
    OrdLot[cnt]=OrderLots();
    OrdPrice[cnt]=OrderOpenPrice();
    OrdSL[cnt]=OrderStopLoss();
    OrdTP[cnt]=OrderTakeProfit();
  }  
  cmt=cmt+nl+"Size: "+Size;  
}   
   
bool compare_positions() {
  if (PrevSize != Size)return(true);
  for(int i=0;i<Size;i++) {
    if (PrevOrdSL[i]!=OrdSL[i])return(true);
    if (PrevOrdTP[i]!=OrdTP[i])return(true);
    if (PrevOrdPrice[i]!=OrdPrice[i])return(true);
    if (PrevOrdId[i]!=OrdId[i])return(true);
    if (PrevOrdSym[i]!=OrdSym[i])return(true);
    if (PrevOrdPrice[i]!=OrdPrice[i])return(true);
    if (PrevOrdLot[i]!=OrdLot[i])return(true);
    if (PrevOrdTyp[i]!=OrdTyp[i])return(true);
  }    
  return(false);
}

void save_positions() {

  if (PrevSize != Size) {
    ArrayResize(PrevOrdId,Size);
    ArrayResize(PrevOrdSym,Size);
    ArrayResize(PrevOrdTyp,Size);
    ArrayResize(PrevOrdLot,Size);
    ArrayResize(PrevOrdPrice,Size);
    ArrayResize(PrevOrdSL,Size);
    ArrayResize(PrevOrdTP,Size);
    PrevSize=Size;
  }
  
  
  for(int i=0;i<Size;i++) {
    PrevOrdId[i]=OrdId[i];
    PrevOrdSym[i]=OrdSym[i];
    PrevOrdTyp[i]=OrdTyp[i];
    PrevOrdLot[i]=OrdLot[i];
    PrevOrdPrice[i]=OrdPrice[i];
    PrevOrdSL[i]=OrdSL[i];
    PrevOrdTP[i]=OrdTP[i];
  }


  int handle=FileOpen("TradeCopy.csv",FILE_CSV|FILE_WRITE,",");
  if(handle>0) {
    FileWrite(handle,TotalCounter);
    TotalCounter++;
    for(i=0;i<Size;i++) {
      FileWrite(handle,OrdId[i],OrdSym[i],OrdTyp[i],OrdLot[i],OrdPrice[i],OrdSL[i],OrdTP[i]);
    }
    FileClose(handle);
  }else Print("File open has failed, error: ",GetLastError());
}

This is for the Ctrader Cbot receiver

using System;
using System.Collections.Generic;
using System.IO;
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.FullAccess)]
    //AccessRights.FullAccess

    public class MT2cTrader : Robot
    {

        [Parameter("Orders Input File Path", DefaultValue = "C:\\Users\\trader\\AppData\\Roaming\\MetaQuotes\\Terminal\\69420FB8433504FEA0FA029C390238DB\\MQL4\\Files\\TradeCopy.csv")]
        // C:\\Users\\trader\\CSV\\TradeCopy.csv

        public string orders_input_file { get; set; }

        [Parameter("Slippage", DefaultValue = 3.5)]
        public double slippage { get; set; }


        [Parameter("Delimiter", DefaultValue = ";")]
        public string delimiter { get; set; }

        protected override void OnStart()
        {

        }

        private bool debug = true;

        protected override void OnTick()
        {
            //todo, check M.D.
            //price = marketDepth.AskEntries[0].Price; 
            //volume = marketDepth.AskEntries[0].Volume;

            string[] lines = new String[0];

            try
            {
                lines = File.ReadAllLines(orders_input_file);

            } catch (Exception e)
            {
                Print("Exception: " + e.Message);

                return;
            }

            List<string> existing_positions = new List<string>();

            foreach (string line in lines)
            {

                OrderData order = new OrderData(line.Split(delimiter.Length > 0 ? delimiter[0] : ','), MarketData);
                existing_positions.Add(order.label);

                if (debug)
                    Print(line);

                if (order.isCorrect() && (Positions.Find(order.label) == null))
                    ExecuteMarketOrder(order.type, order.symbol, order.lot, order.label, order.sl, order.tp, slippage);
            }

            for (int pos = 0; pos < Positions.Count; pos++)
                if (!existing_positions.Contains(Positions[pos].Label))
                    ClosePosition(Positions[pos]);
        }

    }

    public class OrderData
    {

        private const long mt_lot_coefficient = 100000;
        //corrected_100000_july1
        public Symbol symbol;
        public TradeType type;
        public long lot;
        public int sl;
        public int tp;
        public string label;
        private bool initialized_properly = true;

        public OrderData(string[] raw_pieces, MarketData market_data)
        {
            try
            {
                this.label = raw_pieces[0].Trim();
                this.symbol = market_data.GetSymbol(raw_pieces[1].Trim());
                this.setType(Convert.ToInt32(raw_pieces[2].Trim()));
                this.lot = Convert.ToInt64(this.parseDouble(raw_pieces[3]) * mt_lot_coefficient);
                double price = this.parseDouble(raw_pieces[4]);
                this.sl = this.getPipDistance(price, this.parseDouble(raw_pieces[5]));
                this.tp = this.getPipDistance(price, this.parseDouble(raw_pieces[6]));
            } catch (Exception e)
            {
                return;
            }

            {
                this.initialized_properly = false;
            }
        }

        public bool isCorrect()
        {
            return this.initialized_properly;
        }

        private double parseDouble(string value)
        {
            return double.Parse(value.Trim().Replace(',', '.'), System.Globalization.CultureInfo.InvariantCulture);
        }





        private void setType(int mt_type)
        {
            this.type = mt_type == 0 ? TradeType.Buy : TradeType.Sell;
        }

        private int getPipDistance(double basic_price, double close_price)
        {
            return Convert.ToInt32(Math.Round(Math.Abs(basic_price - close_price) / this.symbol.PipSize));
        }

    }

}
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.

No uploaded.

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.
paid  16 Aug 2020
This Robot is a comprehensive system of SMA and RSI strategies which combine beautifully to produce trades of great quality. When certain conditions are met, trades are opened based on those conditions and these trades are usually of short duration. Number of positions opened at a time can be set to whatever you want. SMA has adjustable parameters for the slow and fast SMA and you can set it according to the instrument you decide to trade. RSI Period is currently set at 2 and i advise it should be left that way. This Bot has adaptive features regarding take profit and stop loss levels, take profits and stop loss are not fixed and it will set according to price action.   Currently, I have taken time out to optimize the bot for GBPAUD on the 5Min TF and the results will speak for itself. Contact me if you would the full version of the bot and also the settings for the GBPAUD pair. Contacts: Ask me any questions: email: Imanthetrader@gmail.com Telegram: https://t.me/OGtruce    
paid  05 Jul 2020
This bot instantly copies your market order trades from MT4 along with your set take profit and your stop losses. It also has the ability to copy to multiple cTrader clients. it is strictly a local trade copier meaning it will only work on the same computer so you will have your MT4 and cTrader installed on the same computer. It is also has the ability to translate whatever symbol suffix you have in your MT4. I will also do installation for you.   Contacts: Ask me any questions: email: Imanthetrader@gmail.com Telegram: https://t.me/OGtruce