MQL4 and MetaTrader 4 - page 161

To post a new topic, please log in or register
How do I draw rectangles on the top of the chart? I also want them to stay there if I zoom or unzoom. 
Hi, I'm relatively new to programing MQL4 and would like to know how to code an expert to understand the open and close prices of the previous bar? Any help would be appreciated. Thanks, Chris.
//-------------------------------------------------------------------- //+GLOBAL Variable declaration //+------------------------------------------------------------------- double ExecutedBarOpenPrice=0; //+------------------------------------------------------------------+ //| EA initialization...
I want to get the output result of a function and show it on the chart:   ObjectCreate(pastaverage, OBJ_LABEL, 0, 0, 0);    string value1=DoubleToStr(checkaverage(), 7);    ObjectSetText(pastaverage, "Average of previous bars:"+value1, 15, "Arial", CornflowerBlue);      ObjectSet("ObjName",...
I need a short code to add expiration date and time to my expert. void OnTick() {//1 if(!expire) {//2 expert body }//2 else message("Expired"); } //1 bool expire() { if expiration date reached return(1) else if exp date did not reached return(0) }  
So I created a text object and display it, e.g ObjectCreate(0,labelID,OBJ_LABEL,0,100,100); ...but if its output changes the old text doesn't disappear.   How to refresh the chart to remove the old text? Thanks.  
Right after spending basically all day researching and double checking bits of code from all over the place, I didn't find a nice, reliable, but simple and easy to implement function in one place that I could drop into my code which would give me the lot size, adjusted for JPY and 3/5 digit brokers...
Hi,  I have tried loads of my own EA ideas, buying "commercial" EA's, spent thousands of hours analysing indicators all with the net result of losing about £50k. So my simple question is this - Do any of you out there make any money at all from your EA's?
Hi,  I have a problem can you help me please. I have downloaded historical quotes for this month and I import it to the MT4 platform, when I'm looking back on my platform, I see that the quotes is on the mt4 platform but When I'm doing backtesting, the tester use only one day (01/12/2016) even if...
is this working? extern double MaxSpread = 5.0;Spread = (Ask-Bid)*10000;if(Spread >= MaxSpread) { return(0);}
Hello guys, we have an EA that on paper is perfect, but on the market its not working properly we would like to have some help regarding this. Please feel free to post your idea here. Thanks in advance.
Hello I want to obtain the high price of the previous candles and calculate the average price. double average1() {//average1 start double highfirst[]; CopyHigh(FirstSymbol,timeframe,0,50,highfirst); sum=0; for(int k=0;k<=noofbars;k++) sum=sum+highfirst[k]; double ave=sum/noofbars; return (ave);...
Hello, I suspect I'm getting the wrong results from my code when calculating position sizing. What I want to do is, calculate the number of lots I need to open my order of. They are dependent on the stop loss placement, and the money I would like to lose if that stop loss value is achieved. My main...
Hi all,   For my EA i want to read out a specific value from an indicator. For my case, i want to read out the int "changeofTrend" from the super-trend indicator. So whenever "changeofTrend ==1" occurs or is true, i want to the close the last order! The super-trend indicator i use is in the...
How do I install this indicator on MT4?
Hey Guys, I programmed a EA with an Indicator called SuperTrend. My problem is that if the market triggered the line to sell or buy, I am getting the Error "#02" and the Order isn't placed... Does anyone has a idea and can help me?  (SuperTrend is attached!) if(tpBuy < Bid){       hitTarget = true;...
How can I draw lines using buffers in an EA to produce the following effect? Using one buffer with DRAW_SECTION makes one continuous line, I want it broken up into segments like this -    Thanks in advance! 
Hi all, how can i count optimization passes to write them into a csv? int deinit() {     if (IsOptimization()){          // Counting passes       } } Wich approach use?  Thank you 
https://docs.mql4.com/constants/objectconstants/enum_object/obj_rectangle   I have read the above and searched, but cannot find how to amend the following piece of code so that all rectangles are extended to the hard right edge. ============ ObjectCreate (0,StringConcatenate("kkx",index)...
My EA work on H1 chart.If first cam a buy signal he must open a buy order,after 10 or 20 minutes can arrive a sell signal in the same bar ,so the buy order must remain open and he must open now a sell order. In other words, for every bar i can have maximum 2 pozitions: a buy and a sell order opened...
Hi, due to a paper linked here by Fernando (thanks!) I tried to use this by indicators. First I wanted to compare it to the original - to check whether it is correct or weird. First I compare the 'selfmade' BB (Tomato, sma dotted) against the original BB from the terminal (Magenta, solid) - as you...
Dear Traders,  I have a question about the attached EA i created. As you can see, the attached EA works with supertrend and halftrend indicator. Whenever supertrend says "TrendUp" and an up arrow occurs, a buy Order will be set, and the same with sell positions in the opposite. Now i have problems...
Hi everyone, I have created the attached indicator to alert me on some set moments in time, but being a newbie I cannot get it to work properly. Can anyone tell me what I have done wrong here end how it should be coded? #property indicator_chart_window extern int      Day_1 = 28; extern int...
Is it possible to declare an array of class objects without specifying how many there will be? Like example i want to create an instance of a Class called CTickets, i do CTickets e_ticket; To create an array of 3 instances i do  CTickets e_ticket[3]  What if i don't know how many instances i will...
  Probelm OrderSelect() (21   1 2 3)
Hello everyone, I have a problem with OrderSelect () function, I would understand if the selected order is in Gain or Loss. This simple EA works at a Binary Options Broker. I should know if the automatic closing of the Ticket, the price closed higher opening. I'm not sure that you have correctly...
Im working on algorythm, using Python language and need real time exchange rates from web or mt platform. I was using true fx (ex. http://webrates.truefx.com/rates/connect.html?f=html&c=EUR/USD) but it lags for 5 , 10 seconds sometimes. How can i import that data from mt platform or where in web can...
Dear Mql5 community,   Im working on an EA and i want to put the command:   I want the EA to put no new buy order, if the last order was a buy order, and the other way round with the sell order. therefore i found the following command to get the type of last closed order:   int LastOrderType() {...
Is there a tricky way for a class to get the program-name which is calling/using/instantiating this class. If I use __FILE__ I get the filename of the class - which is useful too of course - but not the the name of the running EA or indicator or script?
A few seconds after startup, Windows 7 suddenly started reporting that Mt4 was not functioning correctly, offering to close it down.  There were no indications of problems in the terminal or in the logs.  After trying several things, I ended, in Options, reducing Max bars in history and Max bars...
Hi Guys and Gals, I'm trying to use the price properties of the attached screen shot from an indicator as my entry, take profit and stop loss levels for an EA I'm creating. I use Mql4 compiling software so don't write very much code myself. Being new to mql4 code I dont know how to do it. I'm...