当前位置:网站首页>Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - identify the emergence of the new K line
Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - identify the emergence of the new K line
2022-06-22 08:02:00 【EA development - green shirt code customer】
Identify new K The appearance of lines in EA It is a very important function in the program ,K The line is the entire trading market , The main basis for trend judgment . Identify and analyze K The meaning of the line is also the basis of the transaction .
Custom method
datetime timelast,timenow;
bool isNewK(){
bool isnewk=false;
timenow=Time[0];
if(timenow!=timelast){
timelast=Time[0];
isnewk=true;
}
else isnewk=false;
return isnewk;
}
EA example :
//+------------------------------------------------------------------+
//| NewK.mq4 |
//| Copyright 2021, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
datetime timelast,timenow;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
timelast=Time[0];
timenow=Time[0];
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
if(isNewK())printf(" new K The line appears !");
}
bool isNewK(){
bool isnewk=false;
timenow=Time[0];
if(timenow!=timelast){
timelast=Time[0];
isnewk=true;
}
else isnewk=false;
return isnewk;
}
Execution effect :
The execution effect after loading the one minute cycle chart : new K Print once when lines appear : new K The line appears !

A good workman does his work well , You must sharpen your tools first , The most important thing in trading is to follow the rules , Strictly carry out . Official account , Study MQL Beginner to master EA course , Learn more EA Programming , Write your own EA, Forge your own magic weapon .

边栏推荐
- 代码覆盖率测试对编程小白的意义及其使用方法
- 关于菲涅尔现象
- 《守望先锋》阵亡镜头、全场最佳和亮眼表现是如何设计
- 【Oracle 数据库】奶妈式教程day15 DDL、DML、索引、视图、序列、死锁这一篇就够了
- MySQL intercepts the string cs0000_ 1 medium_ Following characters
- .net core 技术栈 网站收集
- Xlua environment configuration
- Mystery of power bank
- Usage and understanding of async/await in JS
- Symbolic processing of crash log
猜你喜欢

Use js to download the current image

什么是分布式事务

Upload your own library to pod

LNMP environment setup

ES6 set data type de duplication of array, intersection, union and difference

代码覆盖率测试对编程小白的意义及其使用方法

【Oracle 数据库】奶妈式教程 day13 日期函数

IP address planning

Orientdb batch execute SQL

AutoCAD 2020.3 Chinese Version (old version)
随机推荐
什么是分布式事务
[Oracle database] mammy tutorial day13 date function
Problems caused by canvas palette width and height and canvas width and height
Win openfeign from simple to deep
Unity AssetBundle packaging
JS to assign values to two objects with the same attributes
[songhongkang MySQL database] [advanced chapter] [06] logical architecture of MySQL
Why redis is so fast:
Download addresses of Xcode versions
【宋红康 MySQL数据库 】【高级篇】【06】MySQL的逻辑架构
OSI and tcp/ip
Technology blog collection
Use js to download the current image
【Oracle 數據庫】奶媽式教程 day13 日期函數
对于mysql中数据为NULL引发的一些问题和思考
Kotlin a simple Android program
The difference between get and post requests
【Oracle 数据库】奶妈式教程 day14 转换函数
Stored procedures and functions of MySQL
基于消息传递的并发编程(MPI)之异步收发