Hello friends. Can you please tell me how to get the indicator colour value from the previous candlestick and write it in a variable, e.g. if it is red then double col =1, if it is yellow then 2, if it is green then 3. I tried different variants, but it didn't work. I understand the value of colour depends on the availability of units in the buffer, but for some reason I can not get exactly the last fixed value, ie, the active candle, it constantly changes colour with the appearance of a new previous candle closes the last acting colour. How do I know it ?)
#property indicator_separate_window#property indicator_minimum 0#property indicator_maximum 1#property indicator_buffers 3#property indicator_color1 DarkGreen#property indicator_color2 Crimson#property indicator_color3 Yellow//---- indicator parameters externint RSI=8;
externint valeur1=55;
externint valeur2=45;
//---- indicator buffersdouble ExtBuffer1[];
double ExtBuffer2[];
double ExtBuffer3[];
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
//---- drawing settings
SetIndexStyle (0,DRAW_HISTOGRAM, EMPTY,4,DarkGreen);
SetIndexBuffer(0,ExtBuffer1);
SetIndexStyle (1,DRAW_HISTOGRAM, EMPTY,4,Crimson);
SetIndexBuffer(1,ExtBuffer2);
SetIndexStyle (2,DRAW_HISTOGRAM, EMPTY,4,Yellow);
SetIndexBuffer(2,ExtBuffer3);
//---- names
IndicatorShortName("RSI above/under 45/55");
SetIndexLabel(0,"RSI"+RSI +" is above 55");
SetIndexLabel(1,"RSI"+RSI +" is under 45");
SetIndexLabel(2,"RSI is in the mid zone ");
//---- initialization donereturn(0);
}
//+------------------------------------------------------------------+//| Moving Averages |//+------------------------------------------------------------------+int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recountedif(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1st bufferfor(int i=0; i<limit; i++)
if (iRSI(NULL,0,RSI,PRICE_CLOSE,i)<=valeur2)
{
ExtBuffer2[i]=1;
}
elseif (iRSI(NULL,0,RSI,PRICE_CLOSE,i)>=valeur1)
{
ExtBuffer1[i]=1;
}
else
ExtBuffer3[i]=1;
return(0);
}
Hello friends. Can you please tell me how to get the indicator colour value from the previous candlestick and write it in a variable, e.g. if it is red then double col =1, if it is yellow then 2, if it is green then 3. I tried different variants, but it didn't work. I understand the value of colour depends on the availability of units in the buffer, but for some reason I can not get exactly the last fixed value, ie, the active candle, it constantly changes colour with the appearance of a new previous candle closes the last acting colour. How do I know it ?)
int col;
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recountedif(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1st bufferfor(int i=0; i<limit; i++)
if (iRSI(NULL,0,RSI,PRICE_CLOSE,i)<=valeur2)
{
ExtBuffer2[i]=1;if(i=1)col =1;return;
}
elseif (iRSI(NULL,0,RSI,PRICE_CLOSE,i)>=valeur1)
{
ExtBuffer1[i]=1;if(i=1)col =3;return;
}
else
{
ExtBuffer3[i]=1;
if(i=1)col =2;
}
return(0);
}
like this - if the colours with the numbers are not mixed up
Everything is purely on my guess and only presumably:
int start() {
Comment(Info()); // Вывод какой-то информации на экранint KOL_BUY = order_total(0); // Подсчёт количества Buy-позицийint KOL_SELL = order_total(1); // Подсчёт количества Sell-позицийdouble l;
if (order_total()==0) { // Если количество ордеров равно нулю
open(0,Lot,0,TP); // Открываем Buy лотом Lot скорее всего без стопа, но с тейком
open(1,Lot,0,TP); // Открываем Sell лотом Lot скорее всего без стопа, но с тейком
}
if (KOL_BUY==0 && KOL_SELL!=0) { // Если нет Buy и есть Sell
open(0,Lot,0,TP); // Открываем Buy лотом Lot скорее всего без стопа, но с тейком
l=last_trade(1); // Берём лот прошлой Sell
open(1,l,0,0); // Открываем Sell лотом прошлой Sell скорее всего без стопа и тейка
modify_orders(1); // Что-то модифицируем в Sell (в какой и что - не понятно)
}
if (KOL_BUY!=0 && KOL_SELL==0) { // Если нет Sell и есть Buy
open(1,Lot,0,TP); // Открываем Sell лотом Lot скорее всего без стопа, но с тейком
l=last_trade(0); // Берём лот прошлой Buy
open(0,l,0,0); // Открываем Buy лотом прошлой Buy скорее всего без стопа и тейка
modify_orders(0); // Что-то модифицируем в Buy (в какой и что - не понятно)
}
return(0); // Выход из start()
}
I understand this is the deinit() function , I need to call it somehow. This is a quote from the tutorial:
"The special function deinit() is called for execution by the client terminal also when the client terminal is shut down, when the financial instrument window is closed, just before changing a financial instrument and/or chart period, when the program is successfully recompiled in the MetaEditor, when input parameters are changed, and when the account is changed. "
So I have to close the terminal manually, for example, for this function to be called?
I tried to call this function when a condition triggered, it was executed, but a new tick came and the start function was started again.
int deinit()
{
Alert("Закрываем программу");
return(0);
}
int start()
{
//код
..............
if (OrdersTotal()==0) deinit();
return(0);
}
This is the way to control...either the number of orders or just the first call to the function...
So there is more than one line like yours.
extern int SecondsAfterTheBar = 0; int start(){ ... if(NewBar() == TRUE){ ... } return(0); } bool NewBar(){ RefreshRates(); static bool initial = FALSE; static datetime stat_dtime = 0; if ((TimeCurrent() - stat_dtime >= Time[0] - Time[1] + SecondsAfterTheBar) == TRUE){ stat_dtime = Time[0]; if (initial == TRUE){ return(TRUE); }else{ initial = TRUE; } } return(FALSE); }I'm probably too late, but anyone can use my solution anyway:
Obviously I'm late, but my solution may be useful to someone anyway:
Thank you. More universally if
bool NewBar( datetime SecondsAfterTheBar = 0 )
Then you can specify the lag in seconds when calling it.
Hello friends. Can you please tell me how to get the indicator colour value from the previous candlestick and write it in a variable, e.g. if it is red then double col =1, if it is yellow then 2, if it is green then 3. I tried different variants, but it didn't work. I understand the value of colour depends on the availability of units in the buffer, but for some reason I can not get exactly the last fixed value, ie, the active candle, it constantly changes colour with the appearance of a new previous candle closes the last acting colour. How do I know it ?)
this colour:
Thanks for the reply.
Hello friends. Can you please tell me how to get the indicator colour value from the previous candlestick and write it in a variable, e.g. if it is red then double col =1, if it is yellow then 2, if it is green then 3. I tried different variants, but it didn't work. I understand the value of colour depends on the availability of units in the buffer, but for some reason I can not get exactly the last fixed value, ie, the active candle, it constantly changes colour with the appearance of a new previous candle closes the last acting colour. How do I know it ?)
Is this a condition for opening orders??? Do I understand it correctly?
Is this a condition for opening orders??? Do I understand it correctly?
This condition is for everything you need, because we can only guess what these user-defined functions do by their names
Hi all... Can you guys tell me what this says?
int start()
...
return(0);
Everything is purely on my guess and only presumably:
Good afternoon.
I need the EA to quit after a certain event.
I understand this is the deinit() function , I need to call it somehow. This is a quote from the tutorial:
"The special function deinit() is called for execution by the client terminal also when the client terminal is shut down, when the financial instrument window is closed, just before changing a financial instrument and/or chart period, when the program is successfully recompiled in the MetaEditor, when input parameters are changed, and when the account is changed. "
So I have to close the terminal manually, for example, for this function to be called?
I tried to call this function when a condition triggered, it was executed, but a new tick came and the start function was started again.
How do I still terminate the program?
Thank you.