Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

2014-02-05

MT4 Build 600

Metaquotes has finally released the new version of MT4. There are a lot of changes although they have tried to make it compatible to the older versions. If you are trading with an EA here are some of the most common errors in a code and how to fix them:

https://mqllock.com/common-compile-problems-metatrader-build-600/

2014-01-21

MQL4 - Lesson 8 - Notes

You can access Jim Dandy's MQL4 youtube course here for free. He also has a website with videos here and here. These are my notes of lesson 8:

Message box -> function 
  • function checks which button was pushed and opens message box
  • does not has to send any info back -> void
  • void message (int message) (…)
  • int m is not the same as function message -> rename: int number
  • call message function: message (number); message box ("End of Start Function");
  • message box: tool to see what changed programming makes

Function can call another function 
  • function: run when someone pushed button 3
  • button 3, 4 and 5 function: button3 (number); ….
    • if (number ==3)… else button4 (number)
    • if (number ==4)… else button5 (number)
    • if (number ==5) ->way becomes clear
  • when print is used everything is done instantly
  • another operator than if/else -> switch
    • void testswitch (int number) (switch (number)( 
      • case 3: MessageBox ("You pushed abort!!!");print("End of testswitch function");break;
      • case 4: ...
      • case 5: …)
  • default: MessageBox ("I do not…"); Print("End of…");break;) -> default runs when no case is met

Special MA that adjusts to timeframe
  • int MyMA;
  • void MAAdjuster (int number) (switch (number) (
    • case 5:...
    • case 15:...
    • case 30:...
    • case 60:MyMa=80;break;
    • case 240:MyMa=20;break;

2014-01-18

MQL4 - Lesson 7 - Notes

You can access Jim Dandy's MQL4 youtube course here for free. He also has a website with videos here and here. These are my notes of lesson 7:

Leverage Info
  • double leverage = NormalizeDouble((Bid/margin/100))*1000,0);

Buttons for message box 
  • message box is an integer
  • flags used after last comma in message box separated by pipe symbol
  • message box can be used to detect if the ea is on the right timeframe -> int message… ->if (message ==3)messagebox("You pushed …) <- look for correct number (timeframe, symbol) ->yes/no

Write our own function
  • start function calls another function -> has to send along some information-> int start (XXX)
  • e.g. ordersend function -> sends back number, true/false, … -> return (XXX)
  • programm = series of function calls

2014-01-12

MQL4 - Lesson 6 - Notes

You can access Jim Dandy's MQL4 youtube course here for free. He also has a website with videos here and here. These are my notes of lesson 6:

Message box and market info
  • disable extern string
  • enable original comment
  • delete show inputs line
  • new: message box instead of comment -> shows message box
    • message box -> integer type
    • at the message's end: …, "vital information" -> topic
    • at the end …, 1/2/3 -> different buttons in message box
  • int (double spread = market info (symbol(),Mode_Spread); … +DoubleToStr(Spread/10,1)
  • marketinfo:
    • spread: current spread
    • minlot: Smallest lot size allowed
    • maxlot: Biggest lotsize
    • lotstep: increments to increase the order
    • MarginRequired: Margin required to place a full lot trade

2014-01-07

MQL4 - Lesson 5 - Notes

You can access Jim Dandy's MQL4 youtube course here for free. He also has a website with videos here and here. These are my notes of lesson 5:


Diagnostic tool for EA
  • text in start function -> runs only when ticks are coming in
  • print ("start function has run") ->initialization function -> prints text in experts tab -> you can see whats going on in the background (which function has run e.g.) -> diagnostic tool

Make an indicator
  • custom indicator functions different from EAs
  • print from above into init, deinit and start function of the indicator
  • start function and init function runs; start function of an indicator runs when you drop it on a chart even if the market is closed
  • text is not removed of the chart when removing the indicator unless under deinit… Commen"" = nothing

Make a script
  • only the start function
  • it runs immediately if you put it on a chart and then ends immediatetely
  • #property show confirm 
    • asks you if you really want to attach the script to the chart
    • not part of the script, so no semicolon afterwards
  • #show_inputs: extern string text "" -> input text (Comment (text) in start function
Source

2014-01-05

MQL4 - Lesson 4 - Notes

You can access Jim Dandy's MQL4 youtube course here for free. He also has a website with videos here and here. These are my notes of lesson 4:

Make an EA 
  • name: hello universe
  • functions: initialize, deinitialize, start
  • function -> F1 -> helpfile
  • start function ->  function: comment ("text"); only shown when a tick comes in -> when the comment is in the initialize function it is shown when an EA starts!
  • Ctrl+Z undo
  • Crtl+y redo
  • function: comment ("text"+Period()) <-Period shows opened Chart
  • function: comment ("text"+Period+Symbol()) <-Shows the Symbol
  • Ctrl+G get rid of the grid
  • F4 -> help -> Window functions
  • \n -> new line for e.g. long comments
    • Comment("…"+
    • "\n…"
  • be careful when you work on an ea which is attached to a chart at the same time
  • function: comment ("text"+Time[0]) ->Time in seconds since 1970 that has passed; last known server time of the broker
  • convert this seconds into a string: Comment("TimetoStr(Time…)

2014-01-03

MQL4 - Lesson 3 - Notes

You can access Jim Dandy's MQL4 youtube course here for free. He also has a website with videos here and here. These are my notes of lesson 3:

extern variable and functions 
  • string variable -> can be used as label for settings -> EA Settings
  • F4 Terminal <-> Editor
  • any external number can be seen through the functions; variables in functions can only be used within that function once
  • extern variables are not constantly changing
  • variables in functions like indicators are constantly changing
  • functions can communicate over extern variables like "extern int opentrades"
void function 
  • not an information request
  • just does something
Source

2014-01-01

MQL4 - Lesson 2 - Notes

You can access Jim Dandy's MQL4 youtube course here for free. He also has a website with videos here and here. These are my notes of lesson 2:

Extern
  • outside of the start function
  • any function can see these extern values
  • extern = external settings -> user can see when moving the EA on a chart
  • after extern any type of data constant, description and value
    Types of data constants
    • int = integer = whole number
    • bool = boolean = true/false -> e.g. is trading time or hedging allowed
    • double = number with decimal point
    • string = string of text; text in quotation marks; e.g. put the name of the EA on the screen
    • color -> e.g. arrow color; e.g. = Green (capital letter)
    • datetime = number of seconds that have passed since january 1st 1970 -> specify time; determined by what time the last tick comes in

    2013-12-30

    MQL4 - Lesson 1 - Notes

    You can access Jim Dandy's MQL4 youtube course here for free. He also has a website with videos in higher resolution. You can check them out here and here. Due to the lower resolution of the free youtube videos the code is a bit blur. Nevertheless I could finish the first lesson successfully ;-). I will list the notes I took in each lesson.

    Difference between mq4 file and ex4 file
    • ex4 file computer machine file - can be used by mt4 and appears in the navigator window (mql4 does not)
    • mq4 file can be edited; code can be seen
    • mq4 -> compile -> ex4
    Comment function
    • how to comment 1: put double hashmarks (2 forward slashes = //) before each line (greys out a single line); this comments out code lines -> EA cannot see them -> make your notes in the code
    • how to comment 2: comment out a whole section -> combination of forward slash and asterisk -> /* code */
    Property copyright and link
    • don't have to be in the code
    • appears as popup of ex4 file in the navigator window
    Functions (for indicators and Eas)
    • initialisation function: what should the EA do when you first drop it on a chart? get prices?
    • deinisalisation function: what should the EA do when you remove it from a chart? clean arrows or lines for example
    • start function: what should the EA do when the price changes (tick by tick)? Here is the actual code of the EA 
    • Advice: You can build a new EA with the editor and take a look at the code

    2013-12-25

    Learn programming

    My plan

    I am a real newbie to programming. This is my plan:

    1) I will start with the free youtube course by Jimdandy1958. It looks promising. I will report if it helped me.

    2) I will read the book 'Expert Advisor Programming' by Young.

    3) I will add my notes of the official MQL4 tutorial.

    4) I will watch the german C++ course by OrangeonBlack on youtube.

    5) I will probably attend programming courses here. I am really interested in this course but I haven't had time to attend.