Step to step writing notes to learning MT5 EA programming.
Step 1- Its basic 20 lines given by MQL5 New EA templates, So just keep the below 20 lines and Delete balance unwanted lines to keep simple.
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit(){
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason){
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick(){
}
//+------------------------------------------------------------------+
now fresh writing starting for our TimeTrader. in here program concepts is Opening order in Particular time and Closing order in Particular time. Example open order in 10 O clock and Close it in 3 hours later 13 O'clock. In here order open time and closing time is our input decision. So first we take it in code.
Step 2 : add the belw five lines in previous code as Line as 4,5,6,7,8. Now confirm total lines 25.
//+------------------------------------------------------------------+
//| Variables |
//+------------------------------------------------------------------+
input int OpenHour;
input int CloseHour;
Step 3- We need predefined trading functions for Easy programming, So add the include function call. New lines added in 4,5,6 and 7. 7th line only actual program line and balance 3 lines are comments for easy reading. now total lines 29.
Step 4- Now additional variable added in below 12th line for trade call, check in image and add that 13th line program, now total 30 lines.
Step 5- Now added time hour converstion and trade condition call lines in above image. new 10 lines added below 28th line. firs to line for fixing time and next if loop for matching the input hour and is there order running or not. is it no order and time is match then new order will open, thats same is match the close hour and its any running order, then it will get close if second loop matched.
0 comments:
Post a Comment