If you don't mind, can I have a few words about my mistakes? It's just that I was looking at the help on the website, and the documentation only has a description of the functions themselves, and the examples below which function is after which are not there
If you don't mind, can I have a few words about my mistakes? Just I was looking at the help on the website and the documentation only has a description of the functions themselves, and there are no examples below which function is after which there
I want to try to write a function to remember losing orders by profit, lot and ticket. I have never worked with arrays before, I have done it by example and by reference.
Friends, please help me to program a reversal indicator in my Expert Advisor through iCustom, which consists of one line, but with different colours for buy and sell. It has no arrows. For colour it seems to have three buffers, but in fact when held with mouse it shows only one Value1 for both colours. I tried both to compare bars and to compare with zero, it doesn't help. How to program reversals of such indicators, who knows? Here are the initial settings of indicator buffers and its picture. It looks like StepMA, but it is not:
Friends, please help me to program a reversal indicator in my Expert Advisor through iCustom, which consists of one line, but with different colours for buy and sell. It has no arrows. For colour it seems to have three buffers, but in fact when held with mouse it shows only one Value1 for both colours. I tried both to compare bars and to compare to zero, it doesn't help. How to program reversals of such indicators, who knows? Here are the initial settings of indicator buffers and its picture. It looks like StepMA but it is not:
Friends, please help me to program a reversal indicator in my Expert Advisor through iCustom, which consists of one line, but with different colours for buy and sell. It has no arrows. For colour there seem to be three buffers, but in fact when held with mouse it shows only one Value1 for both colours. I tried both to compare bars and to compare to zero, it doesn't help. How to program reversals of such indicators, who knows? Here are the initial settings of indicator buffers and its picture. It looks like StepMA but it is not:
Example
The indicator based on DRAW_COLOR_LINE. There are two indicator buffers - one for values ('ColorLineBuffer') and another one for colours (' ColorLineColors').
//+------------------------------------------------------------------+ //| 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);
}
//+------------------------------------------------------------------+
And the Expert Advisor, copies values from buffer number '0' ('ColorLineBuffer') and number '1' ('ColorLineColors').
В своей статье я сделал достаточно убедительные тесты, доказывающие тот факт, что далеко не каждый вызов пользовательского или даже технического индикатора в коде - это самый оптимальный вариант для обработки им промежуточных расчетов в разрабатываемом индикаторе. Итоговый результат по скорости своего исполнения может оказаться значительно...
Thank you! What if for commercial purposes ?
For Market in the sense of ?
then you have to build your own GUI library in your own image :-(
MQL is not intended for complex GUI. It is intended for counting and trading.
That is, it can be done, but it is excruciatingly stupid.
Decided to study CCanvas library
Can't figure it out - no errors (or rather, the compiler doesn't give any), and nothing on the screen either. I want to draw a red triangle ...
And here's the result
Decided to explore the CCanvas library
Thank you for the ready-made example
If you don't mind, can I have a few words about my mistakes? It's just that I was looking at the help on the website, and the documentation only has a description of the functions themselves, and the examples below which function is after which are not there
Thank you for the ready-made example
If you don't mind, can I have a few words about my mistakes? Just I was looking at the help on the website and the documentation only has a description of the functions themselves, and there are no examples below which function is after which there
read the articles, there are many ready-made exampleshttps://www.mql5.com/ru/search#!keyword=Canvas&module=mql5_module_articles
Good afternoon!!!
I want to try to write a function to remember losing orders by profit, lot and ticket.
I have never worked with arrays before, I have done it by example and by reference.
I do not know where and how to specify the array size.
Please check and correct if possible.
======
struct StructOrder
{
double OrProf;
double OrLot;
int OrTiK;
};
StructOrder OrBuy[];
StructOrder OrSell[];
====
void 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--)
{
if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)==false)
break;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
{
if(OrderType()==OP_SELL)
{
profit_SELL+=OrderProfit()+OrderSwap()+OrderCommission();
}
if(OrderType()==OP_BUY)
{
profit_BUY+=OrderProfit()+OrderSwap()+OrderCommission();
}
//===========================================================
if(OrderType()==OP_SELL)
{
cur_profits_SELL=OrderProfit()+OrderSwap()+OrderCommission();
if(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);
}
}
//===========================================================
if(OrderType()==OP_BUY)
{
cur_profits_BUY=OrderProfit()+OrderSwap()+OrderCommission();
if(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);
}
}
}
}
}
//+------------------------------------------------------------------+
//| Init Struct for orders |
//+------------------------------------------------------------------+
void 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;
}
}
Hi,
Could you please tell me how to build a project consisting of an mq4-file and a lot of mqh-files into one, for a marketplace ?
Friends, please help me to program a reversal indicator in my Expert Advisor through iCustom, which consists of one line, but with different colours for buy and sell. It has no arrows. For colour it seems to have three buffers, but in fact when held with mouse it shows only one Value1 for both colours. I tried both to compare bars and to compare with zero, it doesn't help. How to program reversals of such indicators, who knows? Here are the initial settings of indicator buffers and its picture. It looks like StepMA, but it is not:
Friends, please help me to program a reversal indicator in my Expert Advisor through iCustom, which consists of one line, but with different colours for buy and sell. It has no arrows. For colour it seems to have three buffers, but in fact when held with mouse it shows only one Value1 for both colours. I tried both to compare bars and to compare to zero, it doesn't help. How to program reversals of such indicators, who knows? Here are the initial settings of indicator buffers and its picture. It looks like StepMA but it is not:
Insert code, please, using the button
Friends, please help me to program a reversal indicator in my Expert Advisor through iCustom, which consists of one line, but with different colours for buy and sell. It has no arrows. For colour there seem to be three buffers, but in fact when held with mouse it shows only one Value1 for both colours. I tried both to compare bars and to compare to zero, it doesn't help. How to program reversals of such indicators, who knows? Here are the initial settings of indicator buffers and its picture. It looks like StepMA but it is not:
Example
The indicator based on DRAW_COLOR_LINE. There are two indicator buffers - one for values ('ColorLineBuffer') and another one for colours (' ColorLineColors').
And the Expert Advisor, copies values from buffer number '0' ('ColorLineBuffer') and number '1' ('ColorLineColors').