MT5 beginner issues
Page 1 of 612 12 LastLast
Results 1 to 10 of 12

Thread: MT5 beginner issues

  1. #1
    This is my very first attempt to write a code in mql5 and there are a couple of issues I'm facing.

    I wished to compose a very simple indior that displays a red block if Pair1 bar is bullish and a green cube if it's bearish.

    Problem

    #1: the label and arrow settings are not applied to the 2nd pair buffer. It reveals a little circle instead of a square.

    #2: my iClose and iOpen return wrong values.

    I have to have made some basic mistakes but I'm unable to loe them myself. Can somebody please help me out here.

    Inserted Code // ------------------------------------------------------------------ //| Hedge.mq5 | //| Copyright 2012, MetaQuotes Software Corp.. | //| http://www.mql5.com | // ------------------------------------------------------------------ #property copyright Copyright 2012, MetaQuotes Software Corp.. #property link http://www.mql5.com #property version 1.00 #property indior_separate_window #property indior_minimum 1 #property indior_maximum 10 #property indior_buffers 4 #property indior_plots 2 //-- plot Label1 #property indior_color1 clrLime,clrRed #property indior_type1 DRAW_COLOR_ARROW #property indior_style1 STYLE_SOLID #property indior_width1 2 // -- plot Pair1 #property indior_color2 clrLime,clrRed #property indior_type2 DRAW_COLOR_ARROW #property indior_style2 STYLE_SOLID #property indior_width2 2 //-- input parameters input series Pair1=EURUSD; input series Pair2=USDCHF; //-- indior buffers double Pair1Buffer#91;#93;,Pair2Buffer#91;#93;; double Pair1CBuffer#91;#93;,Pair2CBuffer#91;#93;; // ------------------------------------------------------------------ //| Custom indior initialization function | // ------------------------------------------------------------------ int OnInit() //-- indior buffers mapping SetIndexBuffer(0,Pair1Buffer,INDICATOR_DATA); PlotIndexSetInteger(0,PLOT_ARROW,110); PlotIndexSetString(0,PLOT_LABEL,Pair1); SetIndexBuffer(1,Pair1CBuffer,INDICATOR_COLOR_INDE X); SetIndexBuffer(2,Pair2Buffer,INDICATOR_DATA); PlotIndexSetInteger(2,PLOT_ARROW,110); PlotIndexSetString(2,PLOT_LABEL,Pair2); SetIndexBuffer(3,Pair2CBuffer,INDICATOR_COLOR_INDE X); return(0); // ------------------------------------------------------------------ //| Custom indior iteration function | // ------------------------------------------------------------------ int OnCalculate(const int rates_total, const int prev_calculated, const datetime time#91;#93;, const double open#91;#93;, const double high#91;#93;, const double low#91;#93;, const double close#91;#93;, const long tick_volume#91;#93;, const long volume#91;#93;, const int disperse #91;#93;-RRB- //-- //-- additional variables int I=0; //-- place position for beginning if(ilt;prev_calculated) I=prev_calculated-1; //-- start calculations while(ilt;rates_total) Pair1Buffer#91;I#93; = 2; Pair2Buffer#91;I#93; = 8; if( iClose(Pair1,0,I) gt;= iOpen(Pair1,0,I) ) Pair1CBuffer#91;I#93; = 1; else Pair1CBuffer#91;I#93; = 0; if( iClose(Pair2,0,I) gt; iOpen(Pair2,0,I) ) Pair2CBuffer#91;I#93; = 1; else Pair2CBuffer#91;I#93; = 0; I ; //Attempt a fix change. Double temp#91;1#93;; int change = 5; CopyOpen(Pair1,PERIOD_CURRENT,change,1,temp); Comment(Open: DoubleToString(temp#91;0#93;,Digits()) \n Close: DoubleToString(iClose(Pair1,0,shift),Digits()) \nShift: IntegerToString(change,1)); return(rates_total); // ------------------------------------------------------------------ double iClose(string symbol,int period, int shift) double temp#91;1#93;; if(CopyClose(emblem,period(period),change,1,temp) == 1) return(temp#91;0#93;-RRB-; elsereturn(-1); double iOpen(string symbol,int period, int shift) double temp#91;1#93;; if(CopyOpen(emblem,period(period),change,1,temp) == 1) return(temp#91;0#93;-RRB-; otherwise return(-1); double iHigh(string symbol,int period, int shift) double temp#91;1#93;; if(CopyOpen(emblem,period(period),change,1,temp) == 1) return(temp#91;0#93;-RRB-; otherwise return(-1); double iLow(string symbol,int period, int shift) double temp#91;1#93;; if(CopyLow(emblem,period(period),change,1,temp) == 1) return(temp#91;0#93;-RRB-; otherwise return(-1); long iVolume(string symbol,int period, int change, bool realVolume = true) long temp#91;1#93;; if(realVolume) if(CopyRealVolume(emblem,period(period),change,1,t emp)! = -1) return(temp#91;0#93;-RRB-; otherwise return(-1); else if (CopyTickVolume(emblem,period(period),change,1,tem p)! = -1) return(temp#91;0#93;-RRB-; otherwise return(-1); ENUM_TIMEFRAMES period(int tf = 0) switch(tf) case 0: return(PERIOD_CURRENT); case 1: return(PERIOD_M1); case 5: return(PERIOD_M5); case 15: return(PERIOD_M15); case 30: return(PERIOD_M30); case 60: return(PERIOD_H1); case 240: return(PERIOD_H4); case 1440: return(PERIOD_D1); case 10080: return(PERIOD_W1); case 43200: return(PERIOD_MN1); case 2: return(PERIOD_M2); case 3: return(PERIOD_M3); case 4: return(PERIOD_M4); case 6: return(PERIOD_M6); case 10: return(PERIOD_M10); case 12: return(PERIOD_M12); case 16385: return(PERIOD_H1); case 16386: return(PERIOD_H2); case 16387: return(PERIOD_H3); case 16388: return(PERIOD_H4); case 16390: return(PERIOD_H6); case 16392: return(PERIOD_H8); case 16396: return(PERIOD_H12); case 16408: return(PERIOD_D1); case 32769: return(PERIOD_W1); case 49153: return(PERIOD_MN1); default: return(PERIOD_CURRENT);

  2. #2
    I am attempting to find out MQL5 also. I started using MT5. I utilized MT4 for a little. The tutorials are long and it seems to take a lot of code just to make a simply indior. I know other languages and would like to begin my own trading platform but I am not sure were to find a free forex feed using historic data.

  3. #3
    Quote Originally Posted by ;
    I understand other languages and would love to start my trading platform but I am not sure were to find a free Currency Market feed together with historic data.
    You wont find anything for free, and considering the amount of programming required for a complete work trading platform, I doubt you see much benefit. MT4 is good for the basic basics.

  4. #4
    Quote Originally Posted by ;
    You won't find anything at no cost, and considering the amount of programming required for a complete work trading platform, I doubt you see much advantage.
    You are sort of right and sort of wrong. I wasn't looking to create a full functional platform, not at the start. I was looking to create a platform probably in Java in which you can create an indior in the few lines of code and then use that information to make your trades on another platform. I can say that making indiors in different languages is alot easier than MT4/MT5 and you can find more accessible developers, novels, code examples and tutorials out there.

  5. #5
    You have a lot to learn. Fantastic luck.

  6. #6
    Quote Originally Posted by ;
    You are sort of right and sort of wrong. I was not seeking to make a whole functional platform, at least not in the beginning. I was more looking to make a platform probably in Java in which you can make an indior from a few lines of code and then use that information to make your trades on another platform. I can say that making indiors in other languages is alot simpler than MT4/MT5 and there are more available programmers, novels, code examples and tutorials available.
    They place a lot of work into Mql5 nd it's object orientated. You can import java dlls or all windows c . I don't think that there is a lot you could exit to make the entire process simpler.

    You need all the mathematics expressions along with the calculations if you would like to control the price in the method by which the indior logic tells you. You will need an array which saves all the necessary price info and one that holds the indior value. I believe that it could be quite fun to wok on this kind of job, however in my view it really isn't worth the quantity of time you install. In mql5 you have predefined functions that use moving averages and all those items. Only take 1 or two weeks get used to it and you will see that it actually is pretty nice

  7. #7
    I have extensive programming experience so I am well that arrays are required which is sometime that is far more developed in Java with it's various datasets. I have found free historic raw data and there are a few methods of having delayed realtime data which both are just good for testing. However I did not realize you could write data items with coffee for MT5. I may give it a look.

  8. #8
    I'm rather curious please keep us updated. I have some minor java experience as well so I might have the ability to accompany you in some cases

  9. #9
    Quote Originally Posted by ;
    I understand other languages and would like to begin my own trading platform but I am not sure were to find a free Foreign Exchange feed with historic data.
    Well, obviously you'd discover free feed out of MT4/5 itself. .
    There's a number of ways to port a platform with MT4/5. I am using a DLL that runs from within MT4 (a full platform). One can conduct a Java VM this way. A DLL is your shortes way and quickest, to port with said platforms, because then your code runs in the same procedure (that of MT4/5).
    Btw, my platform (GUI) looks like this (obviously an older picture lol):

  10. #10
    There is an choice to allow MT4 MT5 operate as a DDE server.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.