mql4

Structure have objects and cannot be copied

心不动则不痛 提交于 2019-12-24 02:24:22
问题 I'm trying to start with my first MQL4 expert advisor, I've created a struct to handle my orders: struct Order { int pair; int command; double quantity; double entry; double stopLoss; double profit; int slippage; string comment; int magicNumber; datetime expire; }; but it seems I can't do this: Order a; Order b=a; the compiler hangs saying: '=' - structure have objects and cannot be copied How can I assign a struct ? 回答1: As MQL4 documentation says: Structures that do not contain strings or

How to download data from an SQL-database and annotate an MT4-chart

对着背影说爱祢 提交于 2019-12-24 01:56:28
问题 I have recently download the MetaTrader Terminal platform ( MT4 ). I have my own back testing engine which stores some output in my SQL-server database. The output depends on the model I am testing. However, the output can just be as simple as the time of entry of a trade. What I would like to know Is it possible in MQL4 to download data from a SQL-server database and then annotate the chart with a simple " B " for a buy entry or " S " for a sell entry? So I have run a back test simulation (

How to “tie” 3 RSI-indicators to one Bollinger Band, using IMAonArray()?

你离开我真会死。 提交于 2019-12-23 05:44:30
问题 There are 3 RSI indicators, each having its own period. I want to tie all 3 to one Bollinger Band. Tell me how to do this better? for(i=limit; i>=0; i--) { ma=iMAOnArray(RSI,0,bb_period,0,0,i); // midle stdev=iStdDevOnArray(RSI,0,bb_period,0,0,i); // dev BBUP[i]=ma+bb_dev*stdev; // up BBDOWN[i]=ma-bb_dev*stdev; // down Buff4[i]=0; Buff5[i]=0; } if(limit<Bars-1) limit++; for(i=limit; i>0; i--) { if(PrevSignal >= 0) { if( RSI[i] < BBDOWN[i] && RSI[i+1] < BBUP[i+1] && RSI2[i] < BBDOWN[i] && RSI2

Why is my EA not moving my position to breakeven?

三世轮回 提交于 2019-12-23 03:24:06
问题 I'm attempting to modify my market orders to breakeven the position when the position get 100 pips to the good. This also accounts for the StopLevels which are around 20-30 pips for my broker. It checks the param's via a " for(){...} loop" function The MagicNumber is the timeframe number for the chart it is on (i.e. 240 =4H, 60 =1H) I don't set a TakeProfit price & initially no StopLoss price. The EA is not adding a SL to be equal to the opening price when the trade reaches 100 pip in profit

How to call a function from a DLL file from [ MQL5 ] code?

Deadly 提交于 2019-12-23 02:38:07
问题 Why the first MessageBox() works and the second doesn't? I don't know where the problem is. Does the MQL5 can access the dll file? I need to to call C# functions that read JSON . No errors appear in MetaEditor . C# .dll file: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.InteropServices; namespace TestMe { class Test { // [DllExport("Add", CallingConvention = CallingConvention.StdCall)] public static

How to send a message in MQL4/5 from MetaTrader Terminal to python using ZeroMQ?

爱⌒轻易说出口 提交于 2019-12-22 00:13:06
问题 I just want to send a message from MetaTrader Terminal, using it`s MQL4/5 to Python, just a simple client server, in which MQL4/5 is a client that sends, and python is a server who receives and these two are syncing with ZeroMQ. The Python side code is this which I am sure this part is working fine: import zmq import time context = zmq.Context() socket = context.socket(zmq.REP) socket.bind("tcp://127.0.0.1:9999") print("Server Started") while True: message = socket.recv() # Wait for next

How to set order few pips above order initiation bar in MQL4

左心房为你撑大大i 提交于 2019-12-21 06:42:37
问题 I would like to create a stoploss order that will be placed above the high of the previous order's initiation bar in case this is a Sell order OR below the low of the previous order's initiation bar in case this is a Buy order. Here is a picture to illustrate the issue ( the example depicts a sell order case ): Any idea how to do that? The code below works fine if I use stoploss that is fixed. If I replace the stoploss with variables that are based on High or Low no orders are fired. Here is

Blue border surrounding two candles

烈酒焚心 提交于 2019-12-12 02:17:13
问题 I hope to draw a graph like this (with blue border surrounding two candles) with the following code, string label_name="Rectangle"; double maxHigh=MathMax(iHigh(_Symbol,0,1),iHigh(_Symbol,0,2)); double minLow=MathMin(iLow(_Symbol,0,1),iLow(_Symbol,0,2)); ObjectCreate(0,label_name, OBJ_RECTANGLE_LABEL, 0, Time[2],maxHigh, Time[1],minLow); ObjectSetInteger(0,label_name,OBJPROP_XSIZE,100); ObjectSetInteger(0,label_name,OBJPROP_COLOR,clrBlue); ObjectSetInteger(0,label_name,OBJPROP_BACK,false);

MQL4 Can you get the trade volume from the One Click Panel?

北城余情 提交于 2019-12-11 14:47:08
问题 Does anyone know if and how you can get the trade volume from the One Click Trade panel on the current chart? I'm putting together some quick trade scripts and would be great to pull the current trade volume or lot size from the one click panel. Thanks in advance 回答1: IMHO no The recent 24 months of Metatrader 4 ( re-inventing ) product updates have brought a few teasing elements ( One-Click-Trading[TM] ( OCT ), or Depth-Of-Market ( DOM ), New-MQL4 ( nMQL4 ) ). The bad news, nevertheless, is

How to get price of Chart HLine objects and calculate Fibonacci levels

只愿长相守 提交于 2019-12-11 04:49:07
问题 Three part question: How to find 2 user created horizontal lines on a chart by name and return the price of each. Then determine which HLine was crossed by the price most recently to determine trend direction. Calculate Fibonacci levels based on prices and direction 回答1: Working example of Fibonacci object that can be edited by the user and printing of fibonacci levels. #include <ChartObjects/ChartObjectsFibo.mqh> CChartObjectFibo *Fibo; int OnInit() { Fibo = new CChartObjectFibo(); #Create