有谁会编写ea,写个mt4外汇ris上穿下穿的报警。
有谁会编写ea,写个mt4外汇ris上穿下穿的报警。有偿服务哈!
此EA监视所选货币对的RSI指标,根据指定的买入阈值和卖出阈值发出声音和箭头警报。它还检查上一个警报是否已过期,并在需要时删除相应的箭头和注释。
请注意,在实际使用中,需要根据实际需要调整各种参数和变量,以使EA适合个人的交易策略。同时,为了确保可靠性,建议设定一个有效的止损和/或止盈。 // 定义指标参数和变量
extern int RSI_period = 14;
extern int RSI_buy_threshold = 30;
extern int RSI_sell_threshold = 70;
int last_alert = 0;
//+------------------------------------------------------------------+
//| expert初始化函数 |
//+------------------------------------------------------------------+
int init()
{
// 指示EA需要使用的技术指标
IndicatorAdd(0, IND_RSI, RSI_period);
IndicatorSetInteger(0, IND_RSI, MODE_APPLIED_PRICE, PRICE_CLOSE); // 应用价格
return(0);
}
//+------------------------------------------------------------------+
//| expert开始函数 |
//+------------------------------------------------------------------+
int start()
{
// 获取技术指标值
double rsi_value = iRSI(Symbol(), PERIOD_CURRENT, RSI_period, PRICE_CLOSE, 0);
double prev_rsi_value = iRSI(Symbol(), PERIOD_CURRENT, RSI_period, PRICE_CLOSE, 1);
// 检查是否穿越买入或卖出阈值
if(rsi_value > RSI_sell_threshold && prev_rsi_value <= RSI_sell_threshold)
{
PlaySound("alert.wav"); // 发出声音警报
Comment("Sell Alert"); // 在图表上显示警报
ObjectCreate("sell_arrow", OBJ_ARROW, 0, Time, High + 5 * Point); // 创建箭头警报
ObjectSet("sell_arrow", OBJPROP_ARROWCODE, 2); // 设置向下箭头
last_alert = -1; // 记录最后一个警报的类型
}
else if(rsi_value < RSI_buy_threshold && prev_rsi_value >= RSI_buy_threshold)
{
PlaySound("alert.wav"); // 发出声音警报
Comment("Buy Alert"); // 在图表上显示警报
ObjectCreate("buy_arrow", OBJ_ARROW, 0, Time, Low - 5 * Point); // 创建箭头警报
ObjectSet("buy_arrow", OBJPROP_ARROWCODE, 3); // 设置向上箭头
last_alert = 1; // 记录最后一个警报的类型
}
// 检查上一个警报是否已过期
if(last_alert != 0)
{
int max_bars_back = 100; // 检查向后的最大价格栏数
bool is_expired = true;
for(int i = 1; i <= max_bars_back; i++)
{
if(last_alert == -1 && High >= ObjectGet("sell_arrow", OBJPROP_PRICE1) - 2*Point)
{
is_expired = false; // 卖出警报仍在图表上
break;
}
else if(last_alert == 1 && Low <= ObjectGet("buy_arrow", OBJPROP_PRICE1) + 2*Point)
{
is_expired = false; // 买入警报仍在图表上
break;
}
}
if(is_expired)
{
// 移除过期的箭头和注释
if(last_alert == -1)
{
ObjectDelete("sell_arrow");
}
else
{
ObjectDelete("buy_arrow");
}
Comment("");
last_alert = 0;
}
}
return(0);
} EAAA888 发表于 2023-5-9 13:45
此EA监视所选货币对的RSI指标,根据指定的买入阈值和卖出阈值发出声音和箭头警报。它还检查上一个警报是否 ...
感谢 顶下 {:1_180:} mt4外汇ris上穿下穿的报警 {:1_180:}
页:
[1]