Hi,
Can I ask some questions regarding MT4? i'm asking this because it's mql5 forum, but i can see mql4 questions here. is it allowed?
Yes, it is allowed, you can ask any questions concerning MT4 and MT5
//--------------------------------------------------------------------------------------------------------------- #property indicator_chart_window // Indicator is drawn in the main window #property indicator_buffers 3 // Number of buffers #property indicator_color1 Blue // Color of the 1st line #property indicator_color2 Red // Color of the 2nd line #property indicator_color3 Yellow // Color of the 3th line double Buf_0[],Buf_1[],Buf_2[]; // Declaring arrays (for indicator buffers) //-------------------------------------------------------------------- int init() // Special function init() { SetIndexBuffer(0,Buf_0); // Assigning an array to a buffer SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2); // Line style SetIndexBuffer(1,Buf_1); // Assigning an array to a buffer SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,2); // Line style SetIndexBuffer(2,Buf_2); // Assigning an array to a buffer SetIndexStyle (2,DRAW_LINE,STYLE_SOLID,2); // Line style return; // Exit the special funct. init() } //-------------------------------------------------------------------- int start() // Special function start() { int i, // Bar index Counted_bars; // Number of counted bars //-------------------------------------------------------------------- Counted_bars=IndicatorCounted(); // Number of counted bars i=Bars-Counted_bars-1; // Index of the first uncounted while(i>=0) // Loop for uncounted bars { Buf_0[i]=Close[i]; Buf_1[i]=iMA(NULL,0,5,0,MODE_SMA,Buf_0[i],i); Buf_2[i]=iMA(NULL,0,5,0,MODE_SMA,Buf_1[i],i); i--; } //-------------------------------------------------------------------- return; // Exit the special funct. start() } //----------------------------------------------------------------------------------------------
Hi everybody.
I'm learnin new MT4 coding. But I know metastock very well.
I want to draw diffarent a moving average for examination and learning code writing menthality.
For example (Metastock version)
M1= Close;
M2=MOV(M1,5,S); // Simple 5 period moving average of M1
M3=MOV(M2,5,S); // Simple 5 period moving average of M2
I've wrote above code on MT4 but not working. How can i write this code on MT4 ?
Can anybody help me??
Thanks for your advice.
...
Forum on trading, automated trading systems and testing trading strategies
Hello,
Please EDIT your post and use the SRC button when you post code.
Thank you.
- monty1: Can I ask some questions regarding MT4? i'm asking this because it's mql5 forum, but i can see mql4 questions here. is it allowed? I've wrote above code on MT4 but not workingLook at the URL of the up arrow it is https://www.mql5.com/en/forum/mql4 Which is the MQL4 section, (bottom of the Root page.) Either you posted in the correct location, or more likely a moderator has already moved it.
General rules and best pratices of the Forum. - General - MQL5 programming forumAnd edited hsaglam's broken code using SRC.
- "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't
start, won't go in gear, no electrical, missing the key, flat tires -
meaningless. There are no mind readers here and our crystal balls are cracked. You must provide information.
Buf_1[i]=iMA(NULL,0,5,0,MODE_SMA,Buf_0[i],i);
The second from the last argument must be ENUM_APPLIED_PRICE
iMA - Technical Indicators - MQL4 ReferenceWhat you are trying to do, requires iMAOnArray
int start() // Special function start() : Counted_bars=IndicatorCounted(); // Number of counted bars
Start using the new Event Handling Functions.
Event Handling Functions - Functions - Language Basics - MQL4 Reference
How to do your lookbacks correctly.
- Look at the URL of the up arrow it is https://www.mql5.com/en/forum/mql4 Which is the MQL4 section, (bottom of the Root page.)
Either you posted in the correct location, or more likely a moderator has already moved it.
General rules and best pratices of the Forum. - General - MQL5 programming forumAnd edited hsaglam's broken code using SRC.
- "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't
start, won't go in gear, no electrical, missing the key, flat tires -
meaningless. There are no mind readers here and our crystal balls are cracked. You must provide information.
- The second from the last argument must be ENUM_APPLIED_PRICE
iMA - Technical Indicators - MQL4 ReferenceWhat you are trying to do, requires iMAOnArray
-
Start using the new Event Handling Functions.
Event Handling Functions - Functions - Language Basics - MQL4 Reference
How to do your lookbacks correctly.
Hi.
First my english is not good. I'm sorry for this.
And thanks for your helpfull advice.
I want to draw a moving average on chart window like above graphic.
I'll try loopbacks methods and iMAOnArray function.
- docs.mql4.com
Use the "SendNotification()" to send out Push Notifications to the app. but remember to setup the app's "MetaQuotes ID" in the settings of the desktop MT4 terminal application, for it to work!
Hello everybody. I am new in mql4 programming. How can I attach two objects together as the they move at the same time. I mean when I move object1 by mouse, I need the object2 to follow the direction of object1. I have the following code and it works good, but there are two problems:
1. As my timer function works permanently, the memory or CPU is working too much.
2. There is a tiny lag between movement of object1 and object2 that does not look like pretty (it moves with a kind of vibration). I tried to solve it by changing in timer speed, but the result was not good. I am looking for code to attach two objects perfectly.
For example descriptions on Fibonacci levels (i.e., 61.8%) move perfectly when I move my Fibonacci retracement. I'm looking for an attachment like that.
Thank you
//+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { EventSetMillisecondTimer(100); ObjectCreate(0,"Object1",OBJ_TREND,0,Time[40],High[1],Time[1],High[1]); ObjectSetInteger(0,"Object1",OBJPROP_RAY,0); ObjectSetInteger(0,"Object1",OBJPROP_COLOR,clrRed); ObjectSetInteger(0,"Object1",OBJPROP_WIDTH,3); ObjectCreate(0,"Object2",OBJ_TEXT,0,Time[20],High[20]); ObjectSetText("Object2","TEXT",12,"Arial",clrBlue); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { datetime time_1 = ObjectGetInteger(0,"Object1",OBJPROP_TIME1,0); double price_1 = ObjectGetDouble(0, "Object1", OBJPROP_PRICE1,0); ObjectSetInteger(0,"Object2",OBJPROP_TIME1,time_1); ObjectSetDouble(0,"Object2",OBJPROP_PRICE1,price_1); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Can I ask some questions regarding MT4? i'm asking this because it's mql5 forum, but i can see mql4 questions here. is it allowed?