Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 548

 

Hi all, could you please give me a detailed example of code for an EA that can change the background colour of a chart when the price passes a certain level? I know it's done with ChartRedraw, ChartApplyTemplate functions,

I can't get it to work (for 3 days), I guess I don't understand something somewhere. Maybe there is a more simple solution. Thank you in advance.

 
VasiliKolchanov:

Hi all, could you please give me a detailed example of code for an EA that can change the background colour of a chart when the price passes a certain level? I know it's done with ChartRedraw, ChartApplyTemplate functions,

I can't get it to work like that (for 3 days now), I guess I don't understand something somewhere. Maybe there is a more simple solution. Thank you in advance.

Where's your code? And what does it have to do with the above functions?
 
VasiliKolchanov:

Hi all, could you please give me a detailed example of code for an EA that can change the background colour of a chart when the price passes a certain level? I know it's done with ChartRedraw, ChartApplyTemplate functions,

I can't get it to work (for 3 days), I guess I don't understand something somewhere. Maybe there is a more simple solution. Thanks in advance.

Open the Help:

  • CHART_COLOR_BACKGROUND - the background colour of the chart.
//+------------------------------------------------------------------+ 
//| Функция получает цвет фона графика.                              | 
//+------------------------------------------------------------------+ 
color ChartBackColorGet(const long chart_ID=0) 
  { 
//--- подготовим переменную для получения цвета 
   long result=clrNONE; 
//--- сбросим значение ошибки 
   ResetLastError(); 
//--- получим цвет фона графика 
   if(!ChartGetInteger(chart_ID,CHART_COLOR_BACKGROUND,0,result)) 
     { 
      //--- выведем сообщение об ошибке в журнал "Эксперты" 
      Print(__FUNCTION__+", Error Code = ",GetLastError()); 
     } 
//--- вернем значение свойства графика 
   return((color)result); 
  } 
//+------------------------------------------------------------------+ 
//| Функция устанавливает цвет фона графика.                         | 
//+------------------------------------------------------------------+ 
bool ChartBackColorSet(const color clr,const long chart_ID=0) 
  { 
//--- сбросим значение ошибки 
   ResetLastError(); 
//--- установим цвет фона графика 
   if(!ChartSetInteger(chart_ID,CHART_COLOR_BACKGROUND,clr)) 
     { 
      //--- выведем сообщение об ошибке в журнал "Эксперты" 
      Print(__FUNCTION__+", Error Code = ",GetLastError()); 
      return(false); 
     } 
//--- успешное выполнение 
   return(true); 
  }

 

Questions on the marketplace:


1. Bought a robot. Activated it on one PC. Can I install the Expert Advisor on other terminals on the same PC by simply copying a file in the directory of another MT4? (I was told that the file is not displayed in another copy).

2. I have bought an indicator on the Market, I want to embed it as a resource in an EA and place the EA for sale in the Market. I want to put it as a resource on the EA and post it on the Market. Is this possible?

3. I have a couple of users who buy one EA for five, then they give each other a password from their account and put the EA on other PCs. How can we protect against this? Is this allowed by Market rules?

 
Sergey Likho: 3. Users buy one EA for five people, then give each other the password to the account and put the EA on other PCs. Is there any way to protect against this? Is it allowed by Market Rules?

Is it really necessary? The more activations they eat. The faster they will buy it again (if the product is worth it). Secondly. On your product, each of those who installed it can earn money by using it to buy a version for personal use, so they do not have to depend on anyone.
So the stick has two ends. Maybe you should not be greedy

 
Can you give me a hint?

1) how to add to the opening of an order, "if it was not opened due to an error so-and-so, display this error in the tab - experts, say


 
Artyom Trishkin:
Where's your code? And what does this have to do with the above functions?
Thanks for the answer, but I can not install these functions and codes, not offered by Taras (I am a novice). If you can explain in detail or suggest a site with a step-by-step on the subject. Thank you. The code attached.
Files:
g3.mq4  5 kb
 
Tigerfreerun:
Can you give me a hint?

1) how to add to the order opening, "if it was not opened due to error so-and-so, display this error in the tab - experts, for example


int ticket;

ticket=OrderSend(.....);

if (ticket<0) {

   int err=GetLastError();

    PrintFormat("OrderSend failed with code %d : %s",err,ErrorDecriptions(err) ); // или Alert("Косяк блин"); чтобы всплыло со звоном и треском

}

 
How, programmatically, do I add an instrument to the market overview?
 
lil_lil:
How can I programmatically add an instrument to the Market Watch?

SYMBOL_SELECT

An indication that the symbol is selected in Market Watch.

Some symbols may not appear on Market Watch, but still be selected.

bool

SYMBOL_VISIBLE

Indicates that the selected symbol is displayed on Market Watch.

Some symbols (usually cross rates, which are necessary for calculating margin requirements and profit in the deposit currency) are selected automatically, but usually are not displayed in Market Watch. To display such symbols, you should select them explicitly.

bool

Reason: