如何使用 MQL4 在图表上创建静态趋势线对象?

发布于 2025-01-19 05:25:28 字数 527 浏览 1 评论 0原文

每当前 500 根蜡烛中的最高蜡烛高于最近 5 根蜡烛的最高蜡烛时,我想要一条下降趋势线。然而,趋势线是第一次创建但不会更新。

int highestCandle=iHighest(Symbol(),0,MODE_HIGH,500,0);
if(High[highestCandle]>High[5])
{
ObjectCreate(0,"HT",OBJ_TREND,0,Time[highestCandle],High[highestCandle],Time[0],High[0]);
ObjectSetInteger(0,"HT",OBJPROP_COLOR,clrBlue); ObjectSetInteger(0,"HT",OBJPROP_STYLE,STYLE_SOLID); ObjectSetInteger(0,"HT",OBJPROP_RAY,true);
}

我不想删除这个对象并在每个新的价格变动时重新创建,我只想在图表上更新它。 在此处输入图像描述

I want a down trend line whenever the highest candle in the previous 500 bars is higher than latest 5 candles highest bar. However the trend line is created the first time but does not update.

int highestCandle=iHighest(Symbol(),0,MODE_HIGH,500,0);
if(High[highestCandle]>High[5])
{
ObjectCreate(0,"HT",OBJ_TREND,0,Time[highestCandle],High[highestCandle],Time[0],High[0]);
ObjectSetInteger(0,"HT",OBJPROP_COLOR,clrBlue); ObjectSetInteger(0,"HT",OBJPROP_STYLE,STYLE_SOLID); ObjectSetInteger(0,"HT",OBJPROP_RAY,true);
}

I do not want to delete this object and recreate on every new tick, I would just like it to be updated on the chart.
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流年里的时光 2025-01-26 05:25:28

因为您已经创建了对象,所以尝试再次创建它不会移动坐标。您需要使用 objectMove 。尝试以下代码:

int highestCandle=iHighest(Symbol(),0,MODE_HIGH,500,0);
if(High[highestCandle]>High[5])
{
   ObjectCreate(0,"HT",OBJ_TREND,0,Time[highestCandle],High[highestCandle],Time[0],High[0]);
   ObjectSetInteger(0,"HT",OBJPROP_COLOR,clrBlue);
   ObjectSetInteger(0,"HT",OBJPROP_STYLE,STYLE_SOLID); 
   ObjectSetInteger(0,"HT",OBJPROP_RAY,true);
   ObjectMove("HT",0,Time[highestCandle],High[highestCandle]);
   ObjectMove("HT",1,Time[0],High[0]);
}

Because you have already created your object, trying to create it again will not move the coordinates. You need to use ObjectMove. Try the following code:

int highestCandle=iHighest(Symbol(),0,MODE_HIGH,500,0);
if(High[highestCandle]>High[5])
{
   ObjectCreate(0,"HT",OBJ_TREND,0,Time[highestCandle],High[highestCandle],Time[0],High[0]);
   ObjectSetInteger(0,"HT",OBJPROP_COLOR,clrBlue);
   ObjectSetInteger(0,"HT",OBJPROP_STYLE,STYLE_SOLID); 
   ObjectSetInteger(0,"HT",OBJPROP_RAY,true);
   ObjectMove("HT",0,Time[highestCandle],High[highestCandle]);
   ObjectMove("HT",1,Time[0],High[0]);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文