How to create objects on charts opened by a script

 

Hi,

I'm writing a script scanning all the market (symbols and timeframes). The script creates a new chart for each "opportunity" I find (based on a logic I created). So far I managed to do (thanks to the information I gathered in this forum of win API functions :)). Now I need to draw trend lines on those charts but the CreateObject function is only working on the chart on which I started (=ran/loaded) the script...How do I change the "focus" of the script to create the objects on the charts I opened during the script run ?

I know the answer should be using win API functions but it is all chinese for me. when answering, it would be great if you can add few words about the functions used and the meaning of the numbers/codes/parameters used).

BTW - similar question was asked here: https://www.mql5.com/en/forum/115782 but I was not able to find an answer.

Thank You !

 

Don't over complicate things. Change the script to an EA and have it look at the current chart only and draw the symbols on the chart. Put the EA on the charts you want.

When you find an "Opportunity" Send an alert. Let the human switch charts.

 

Thank you for your answer.

The issue is that my script scans all the symbols (I have ~150) and for each symbol all timeframes. I cannot tell beforehand which symbols/timeframes will be fetched by the script.

For your suggestion, i will need the EA to change both the symbol and timeframe on the one chart i'm using and then i can draw the lines with no issue (and also pop up alert). in such case, what is the PostMessageA format to do the symbol change (i know the way to change the timeframe, but not the symbol) ?

Also, it will work like a slideshow on that chart as usually my script finds 20-40 results, so ideally, if i could just know how to draw a trendline on a new chart, all my problems are solved :)

while further investigating this issue I saw that MQL5 supports this functionality easily... the create object function gets the chart ID as input parameter but I assume converting my code to MQL5 will be much more complicated

Reason: