在最新 bar 上移动特定的点数报警
//+------------------------------------------------------------------+
//| AlertPriceMovement.mq4 |
//| Copyright 2023, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window
input int InpMovementPoints = 50;
double MovementValue;
int OnInit() {
MovementValue = InpMovementPoints * SymbolInfoDouble(Symbol(), SYMBOL_POINT);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[]) {
static datetime currentBarTime = 0;
static double highTarget = 0;
static double lowTarget = 0;
// Get out if bars are still loading
if (rates_total != prev_calculated) return(rates_total);
if (currentBarTime != time[0]) {
currentBarTime = time[0];
highTarget = open[0] + MovementValue;
lowTarget = open[0] - MovementValue;
}
if (highTarget > 0 && close[0] >= highTarget) {
AlertMe(highTarget, close[0], "High", TimeCurrent() - time[0]);
highTarget = 0;
}
if (lowTarget > 0 && close[0] <= lowTarget) {
AlertMe(lowTarget, close[0], "Low", TimeCurrent() - time[0]);
lowTarget = 0;
}
return(rates_total);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void AlertMe(double targetPrice, double currrentPrice, string type, int seconds) {
string msg = StringFormat("Current price %f has passed %s target price of %f in %i seconds", currrentPrice, type, targetPrice, seconds);
Alert(msg);
}
//+------------------------------------------------------------------+
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇