print a counting number over candle max price

 

Hi,

I am very new to MetatTrade programming.

I have the following problem: I want to create an indicator that when counts 5 candles in a row with close > close t-1 print a 5 over the max of the candle and a 6, 7 etc for each subsequent candle (if it is the case).

It is just an simplified example but it gives you an idea of what I need :-)

The problem I have found is that it seems relatively easy to print an arrow or a symbol from Wingsdings, but difficult to print a number or a string.

The only way I found is using ObjectCreate which does the job but on the other hand it leaves the problem of deleting all those numbers (objects) when I remove indicator from a chart (numbers got stuck in the chart forever)

Is there any simple way to do that? Is there a way to add numbers to the Wingsdings table maybe?

Sorry if the question is trivial but I have been stuck for long now...


Thanks

Enrico

 
Enrico Michelotti:

Hi,

I am very new to MetatTrade programming.

I have the following problem: I want to create an indicator that when counts 5 candles in a row with close > close t-1 print a 5 over the max of the candle and a 6, 7 etc for each subsequent candle (if it is the case).

It is just an simplified example but it gives you an idea of what I need :-)

The problem I have found is that it seems relatively easy to print an arrow or a symbol from Wingsdings, but difficult to print a number or a string.

The only way I found is using ObjectCreate which does the job but on the other hand it leaves the problem of deleting all those numbers (objects) when I remove indicator from a chart (numbers got stuck in the chart forever)

Is there any simple way to do that? Is there a way to add numbers to the Wingsdings table maybe?

Sorry if the question is trivial but I have been stuck for long now...


Thanks

Enrico

Have you tried searching with google? 

https://www.mql5.com/en/forum/137397

Display some text on top of each bar on chart
Display some text on top of each bar on chart
  • 2012.01.07
  • www.mql5.com
Hi, Can someone please tell how to put some text vertically or diagnolly starting from the High of each bar on the current chart I tried below code...
 
leaves the problem of deleting all those numbers (objects) when I remove indicator from a chart (numbers got stuck in the chart forever)

Is there any simple way to do that?

Try https://www.mql5.com/en/docs/objects/objectdeleteall

int  ObjectsDeleteAll(
   long           chart_id,      // chart ID
   const string   prefix,        // prefix in object name
   int            sub_window=-1, // window index
   int            object_type=-1 // object type
   );

Just name everything with the same prefix and Bob's your uncle.

 
Anthony Garot:

Try https://www.mql5.com/en/docs/objects/objectdeleteall

Just name everything with the same prefix and Bob's your uncle.

I tried that solution too. But not sure where should I put that piece of code in order to be triggered when I delete an indicator from a chart (I manage to get it right when I modify time-frame for instance, but when i delete indicator all text objects remain on the chart).

So my problem stands

 
Fernando Morales:

Have you tried searching with google? 

https://www.mql5.com/en/forum/137397

yes of course. this was the solution I found. BUT all those objects remains in the chart when I remove indicator from the chart itself.

So my problem remains :-(

 
Enrico Michelotti:

I tried that solution too. But not sure where should I put that piece of code in order to be triggered when I delete an indicator from a chart (I manage to get it right when I modify time-frame for instance, but when i delete indicator all text objects remain on the chart).

So my problem stands

OnDeinit() didn't work for you?
 
Anthony Garot:
OnDeinit() didn't work for you?

i tried to put it there. but it was not working when I was deleting the indicator from a chart.

I read in documentation that OnDeinit() is called in specific cases but apparently not when you remove an indicator from a chart...

 
Anthony Garot:
OnDeinit() didn't work for you?

I think I understood what I was doing wrong. It was not working in debugging (because of course it was killing the debug process) but it is working in production.

So thank you very much and sorry for the 'silly' question

Enrico

 
Enrico Michelotti:

I think I understood what I was doing wrong. It was not working in debugging (because of course it was killing the debug process) but it is working in production.

So thank you very much and sorry for the 'silly' question

Enrico

Don't be sorry for asking after trying to resolve it by yourself. Often we get blinded by trying to solve the issue and fail considering a broader POV