//+------------------------------------------------------------------+ //| DRAW_COLOR_LINE Lite.mq5 | //| Copyright 2016, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright"Copyright 2011, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"#property description"An indicator to demonstrate DRAW_COLOR_LINE"#property description"It draws a line on Close price in colored pieces of 20 bars each"#property description"The width, style and color of the line parts are changed randomly"#property description"every N ticks"#property indicator_chart_window#property indicator_buffers2#property indicator_plots1//--- plot ColorLine #property indicator_label1"ColorLine"#property indicator_type1DRAW_COLOR_LINE//--- Define 5 colors for coloring each bar (they are stored in the special array) #property indicator_color1clrBlue,clrRed// (Up to 64 colors can be specified) #property indicator_style1STYLE_SOLID#property indicator_width13//--- A buffer for plotting double ColorLineBuffer[];
//--- A buffer for storing the line color on each bar double ColorLineColors[];
//+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ intOnInit()
{
//--- Binding an array and an indicator buffer SetIndexBuffer(0,ColorLineBuffer,INDICATOR_DATA);
SetIndexBuffer(1,ColorLineColors,INDICATOR_COLOR_INDEX);
//---ArraySetAsSeries(ColorLineBuffer,true);
ArraySetAsSeries(ColorLineColors,true);
//--- return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
ArraySetAsSeries(close,true);
if(prev_calculated==0)
{
for(int i=0;i<rates_total;i++)
ColorLineBuffer[i]=close[i];
}
//--- Block for calculating indicator values for(int i=0;i<10;i++)
{
//--- Write the indicator value into the buffer
ColorLineBuffer[i]=close[i];
//--- For this bar, the line will have the color with the index color_index if(ColorLineBuffer[i]>ColorLineBuffer[i+1])
ColorLineColors[i]=0;
else
ColorLineColors[i]=1;
}
//--- Return the prev_calculated value for the next call of the function return(rates_total);
}
//+------------------------------------------------------------------+
В своей статье я сделал достаточно убедительные тесты, доказывающие тот факт, что далеко не каждый вызов пользовательского или даже технического индикатора в коде - это самый оптимальный вариант для обработки им промежуточных расчетов в разрабатываемом индикаторе. Итоговый результат по скорости своего исполнения может оказаться значительно...
谢谢你!如果用于商业目的呢?
对于市场的意义是什么?
那么你必须在你自己的图像中建立你自己的GUI库 :-(
MQL并不打算用于复杂的GUI。它是用于计数和交易的。
也就是说,它可以做到,但它是令人痛苦的愚蠢。
决定研究CCanvas库
想不明白--没有错误(或者说,编译器没有给出任何错误),而且屏幕上也没有任何东西。我想画一个红色的三角形 ...
结果是这样的
决定探索CCanvas库
谢谢你提供的现成的例子
如果你不介意的话,我可以就我的错误说几句吗?只是我在网站上看了一下帮助,文档中只有对函数本身的描述,而下面的例子中哪个函数在哪个函数之后都没有。
谢谢你提供的现成的例子
如果你不介意的话,我可以就我的错误说几句吗?只是我看了一下网站上的帮助,文档中只有对函数本身的描述,下面没有例子说明哪个函数在哪个地方之后。
阅读文章,有很多现成的例子https://www.mql5.com/ru/search#!keyword=Canvas&module=mql5_module_articles
下午好!!!。
我想尝试写一个函数,通过利润、手数和票数来记忆亏损的订单。
我以前从未与数组打过交道,我是通过实例和参考来完成的。
我不知道在哪里以及如何指定阵列的大小。
请检查并尽可能地纠正。
======
StructOrder结构
{
Double OrProf;
双倍OrLot。
意思是说:"我不知道。
};
StructOrder OrBuy[];
StructOrder OrSell[];
====
空白 Cloce_No_FreeMargin()
{
double profit_SELL = 0;
double profit_BUY = 0;
double no_profits_BUY = 0;
double no_profits_SELL = 0;
double cur_profits_SELL = 0;
double cur_profits_BUY = 0;
//---
int bo = 0。
int so = 0。
InitStruct_Order(OrBuy)。
InitStruct_Order(OrSell)。
//ArrayResize(OrBuy,bo)。
//ArrayResize(OrSell,so)。
for(int trade= OrdersTotal()-1; trade>= 0; trade--)
{
如果(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)==false)
突破。
如果(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
{
如果(OrderType()==OP_SELL)
{
profit_SELL+=OrderProfit()+OrderSwap()+OrderCommission()。
}
如果(OrderType()==OP_BUY)
{
profit_BUY+=OrderProfit()+OrderSwap()+OrderCommission()。
}
//===========================================================
如果(OrderType()==OP_SELL)
{
cur_profits_SELL=OrderProfit()+OrderSwap()+OrderCommission()。
如果(cur_profits_SELL<0)
{
no_profits_SELL+=cur_profits_SELL。
OrSell[so].OrProf = OrderProfit()-OrderSwap()-OrderCommission()。
OrSell[so].OrLot = OrderLots()。
OrSell[so].OrTiK = OrderTicket()。
so++;
Print(" SELL type: Profit - ",OrBuy[bo].OrProf," : Lot - ",OrBuy[bo].OrLot," : Ticket - ",OrBuy[bo].OrTiK)。
}
}
//===========================================================
如果(OrderType()==OP_BUY)
{
cur_profits_BUY=OrderProfit()+OrderSwap()+OrderCommission()。
如果(cur_profits_BUY<0)
{
no_profits_BUY+=cur_profits_BUY。
OrBuy[bo].OrProf = OrderProfit()-OrderSwap()-OrderCommission()。
OrBuy[bo].OrLot = OrderLots()。
OrBuy[bo].OrTiK = OrderTicket()。
bo++。
Print(" BUY type: Profit - ",OrBuy[bo].OrProf," : Lot - ",OrBuy[bo].OrLot," : Ticket - ",OrBuy[bo].OrTiK);
}
}
}
}
}
//+------------------------------------------------------------------+
//| 订单的初始结构。
//+------------------------------------------------------------------+
空白 InitStruct_Order(StructOrder &Masiv[])
{
int Size = ArrayRange(Masiv,0);
for(int i=0; i<Size; i++)
{
Masiv[i].OrProf = 0;
Masiv[i].OrLot = 0;
Masiv[i].OrTiK = 0。
}
}
你好。
你能告诉我如何为一个市场建立一个由mq4-文件和大量mqh-文件组成的项目?
朋友们,请帮助我通过iCustom在我的专家顾问中编制一个反转指标,它由一条线组成,但买入和卖出的颜色不同。它没有箭头。对于颜色,它似乎有三个缓冲区,但事实上,当用鼠标按住时,两种颜色只显示一个Value1。我既尝试了比较条形,也尝试了与零的比较,都没有用。如何对这种指标的逆转进行编程,谁知道呢?下面是指标缓冲区的初始设置和它的图片。它看起来像StepMA,但它不是。
朋友们,请帮助我通过iCustom在我的专家顾问中编制一个反转指标,它由一条线组成,但买入和卖出的颜色不同。它没有箭头。对于颜色,它似乎有三个缓冲区,但事实上,当用鼠标按住时,两种颜色只显示一个Value1。我既试过比较条形,又试过与零比较,都没有用。如何对这种指标的逆转进行编程,谁知道呢?下面是指标缓冲区的初始设置和它的图片。它看起来像StepMA,但它不是。
请插入代码,使用按钮
朋友们,请帮助我通过iCustom在我的专家顾问中编制一个反转指标,它由一条线组成,但买入和卖出的颜色不同。它没有箭头。对于颜色,它似乎有三个缓冲区,但事实上,当用鼠标按住时,两种颜色只显示一个Value1。我既尝试了比较条形,也尝试了与零的比较,都没有用。如何对这种指标的逆转进行编程,谁知道呢?下面是指标缓冲区的初始设置和它的图片。它看起来像StepMA,但它不是。
例子
基于DRAW_COLOR_LINE的指标。有两个指示器缓冲区--一个用于数值('ColorLineBuffer'),一个用于颜色('ColorLineColors')。
而专家顾问,从0号缓冲区('ColorLineBuffer')和1号缓冲区('ColorLineColors')复制数值。