//+------------------------------------------------------------------+ //+------------------------------------------------------------------+ #property copyright "2005-2022, MetaQuotes Software Corp." #property link "http://www.mql4.com" #property description "" #property strict //blabla..... enum Trademarketselect { a=0, // Futures b=1, // Spot }; //--- input parameters input Trademarketselect Trademarket=a; string URL="http://localhost/"; //---Variables //..... MqlRates rate; string NewFileName=""; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- Perioden[0]= "1m"; /* ... */ Periodestr=Periode; c_symbol=Symbol(); NewFileName=c_symbol+DoubleToStr(Period(),0)+".hst"; if(ObjectFind("periode")>=0)ObjectDelete("periode"); if(ObjectFind("symbol")>=0)ObjectDelete("symbol"); if(ObjectFind("Market")>=0)ObjectDelete("Market"); if(ObjectFind("Quantity")>=0)ObjectDelete("Quantity"); //--- if(Trademarket==0)Market="Futures"; if(Trademarket==1)Market="Spot"; if(quantiryvariable==0)quantiryvariable=Tradequantity; Comment(""); EventSetTimer(4); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Create Button | //+------------------------------------------------------------------+ // blablabla........ //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, // Event identifier const long& lparam, // Event parameter of long type const double& dparam, // Event parameter of double type const string& sparam) // Event parameter of string type { //--- the left mouse button has been pressed on the chart if(id==CHARTEVENT_CLICK) { } //--- the mouse has been clicked on the graphic object if(id==CHARTEVENT_OBJECT_CLICK) { Print("The mouse has been clicked on the object with name '"+sparam+"'"); if(sparam=="buy" || sparam=="sell") { //+------------------------------------------------------------------+ //| Webrequest Variablen | //+------------------------------------------------------------------+ string cookie=NULL,headers; char post[],result[]; int res; int timeout=5000; ResetLastError(); if(sparam=="buy") { string url=URL+"trading/?symbol="+Symbolname+"&quantity="+DoubleToString(Tradequantity,2)+"&type=buy&market="+Market; res=WebRequest("GET",url,cookie,NULL,timeout,post,0,result,headers); string str=""; if(res==-1) { Print("Error in WebRequest Error code = ",GetLastError()); } else { str = CharArrayToString(result);Print(str); } } if(sparam=="sell") { string url=URL+"trading/?symbol="+Symbolname+"&quantity="+DoubleToString(Tradequantity,2)+"&type=sell&market="+Market; res=WebRequest("GET",url,cookie,NULL,timeout,post,0,result,headers); string str=""; if(res==-1) { Print("Error in WebRequest Error code = ",GetLastError()); } else { str = CharArrayToString(result);Print(str); } } } if(sparam=="1m" || sparam=="5m" || sparam=="15m" || sparam=="30m" || sparam=="1h" || sparam=="4h" || sparam=="1d" || sparam=="1w" || sparam=="1M") { Periodestr=sparam; if(ObjectFind("periode")>=0)ObjectDelete("periode"); //-- reset color all buttons for(int a=0; a<9; a++) { if(ObjectFind(Perioden[a])>=0) { //--- set background color ObjectSetInteger(0,Perioden[a],OBJPROP_BGCOLOR,clrWhite); //--- set text color ObjectSetInteger(0,Perioden[a],OBJPROP_COLOR,clrBlack); } } //--- set background color ObjectSetInteger(0,sparam,OBJPROP_BGCOLOR,clrBlue); //--- set text color ObjectSetInteger(0,sparam,OBJPROP_COLOR,clrWhite); } if(sparam=="quantityplus") { quantiryvariable=quantiryvariable+Tradequantity; if(ObjectFind("Quantity")>=0)ObjectDelete("Quantity"); textinfo2("Quantity", 10, 50, clrWhite, 10, "Quantity: "+DoubleToString(quantiryvariable,2)); } if(sparam=="quantityminus") { quantiryvariable=quantiryvariable-Tradequantity;if(quantiryvariable<1)quantiryvariable=1; if(ObjectFind("Quantity")>=0)ObjectDelete("Quantity"); textinfo2("Quantity", 10, 50, clrWhite, 10, "Quantity: "+DoubleToString(quantiryvariable,2)); } } } //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ void OnTimer() { //--- //if(TimeCurrent()>StringToTime("2017.12.22")){Alert("expiry reached");return;} //+------------------------------------------------------------------+ //| Webrequest Variablen | //+------------------------------------------------------------------+ string cookie=NULL,headers; char post[],result[]; int res; int timeout=5000; ResetLastError(); string url=URL+"?symbol="+Symbolname+"&periode="+Periodestr; res=WebRequest("GET",url,cookie,NULL,timeout,post,0,result,headers); string str=""; if(res==-1) { Print("Error in WebRequest Error code = ",GetLastError()); } else { str = CharArrayToString(result);//Alert(str); } //+------------------------------------------------------------------+ //| Candelsticks aus Textdatei in History File schreiben | //+------------------------------------------------------------------+ if(StringLen(str)>10) { ExtHandle=FileOpenHistory(NewFileName,FILE_BIN|FILE_WRITE|FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_ANSI); if(ExtHandle<0) return; /* .......blablabla.... */ //--- FileFlush(ExtHandle); FileClose(ExtHandle); }//StringLen(str)>10 //+------------------------------------------------------------------+ //| Update Chart | //+------------------------------------------------------------------+ static long chart_id; if(chart_id==0) { long id=ChartFirst(); while(id>=0) { //--- find appropriate offline chart if(ChartSymbol(id)==c_symbol && ChartPeriod(id)==i_period && ChartGetInteger(id,CHART_IS_OFFLINE)) { chart_id=id; ChartSetInteger(chart_id,CHART_AUTOSCROLL,true); ChartSetInteger(chart_id,CHART_SHIFT,true); ChartNavigate(chart_id,CHART_END); ChartRedraw(chart_id); PrintFormat("Chart window [%s,%d] found",c_symbol,i_period); break; } //--- enumerate opened charts id=ChartNext(id); } } //--- refresh window not frequently than 1 time in 2 seconds if(chart_id!=0) { ChartSetSymbolPeriod(chart_id,Symbol(),i_period); //Print("Chart refresh call"); } //+------------------------------------------------------------------+ //| Chart Buttons | //+------------------------------------------------------------------+ //--- M1 if(ObjectFind("1m")<0)ButtonCreate(0, // chart's ID "1m", // button name 0, // subwindow index 990, // vertikal coordinate 19, // horizontal coordinate 30, // button width 25, // button height CORNER_RIGHT_UPPER,// chart corner for anchoring "M1", // text "Arial Black", // font 10, // font size clrBlack, // text color clrWhite, // background color clrNONE, // border color false, // pressed/released false, // in the background false, // highlight to move false, // hidden in the object list 0); //--- M5 /*......*/ //--- Sell if(ObjectFind("sell")<0)ButtonCreate(0, // chart's ID "sell", // button name 0, // subwindow index 100, // vertikal coordinate 50, // horizontal coordinate 45, // button width 25, // button height CORNER_RIGHT_LOWER,// chart corner for anchoring "Sell", // text "Arial Black", // font 10, // font size clrWhite, // text color clrRed, // background color clrNONE, // border color false, // pressed/released false, // in the background false, // highlight to move false, // hidden in the object list 0); //--- Quantity plus if(ObjectFind("quantityplus")<0)ButtonCreate(0, // chart's ID "quantityplus", // button name 0, // subwindow index 30, // vertikal coordinate 70, // horizontal coordinate 25, // button width 20, // button height CORNER_RIGHT_UPPER,// chart corner for anchoring "+", // text "Arial Black", // font 10, // font size clrBlack, // text color clrWhite, // background color clrNONE, // border color false, // pressed/released false, // in the background false, // highlight to move false, // hidden in the object list 0); //--- Quantity minus if(ObjectFind("quantityminus")<0)ButtonCreate(0, // chart's ID "quantityminus", // button name 0, // subwindow index 70, // vertikal coordinate 70, // horizontal coordinate 25, // button width 20, // button height CORNER_RIGHT_UPPER,// chart corner for anchoring "-", // text "Arial Black", // font 10, // font size clrBlack, // text color clrWhite, // background color clrNONE, // border color false, // pressed/released false, // in the background false, // highlight to move false, // hidden in the object list 0); textinfo2("..", ".."); //+------------------------------------------------------------------+ //| Write Text | //+------------------------------------------------------------------+ textinfo2("periode", 10, 30, clrWhite, 10, "Periode: "+Periodestr); textinfo2("symbol", 120, 30, clrWhite, 10, "Symbol: "+Symbolname); textinfo2("Market", 120, 50, clrWhite, 10, "Market: "+Market); textinfo2("Quantity", 10, 50, clrWhite, 10, "Quantity: "+DoubleToString(quantiryvariable,2)); //--- } //+------------------------------------------------------------------+ //| OnTimer | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- //--- } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+
You can't place an order with GET type request. You need a POST type request. You need to create a request to url with a spot Binance endpoint. Then put parameters you want there (symbol/volume/buy/sell/market/limit etc.). And then sign it with your Binance API key and secret using HMAC algorithm.
General info on sending requests to Binance can be found here:
https://binance-docs.github.io/apidocs/spot/en/#general-info
Info on placing spot orders is here:
https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
Thank you.
Actually problem is about something else. Solved.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello to all and thanks from now.
My code can send "Buy Market Orders" to Binace (SPOT) successfully, but only this. I'm trying to do the same for Sell, Limit, StopLimit, Getting Current account Info, etc. But I could not.
I need the URL structure for the mentioned other actions. Is there anyone can help me?
-----------------------------------------------------
I'm also adding the whole code