Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 894

 
tuner:
Probably... there are built-in functions in MQl4 related to saving and loading templates: ChartSaveTemplate, ChartApplyTemplate
Got it, thanks!
 

I wanted to write a simple script to create a segment(trend line) on a chart with the beginning at the place where the script is thrown (no problem with that) and the end at the coordinates where the left mouse click will be made... This is where I stumbled... How to do it in an indicator or expert to catch this event is elementary, but how to do it in a script? How do I do it in Script?

 
Batman:

I wanted to write a simple script to create a segment (trend line) on a chart with the beginning at the place where the script is thrown (no problem with that) and the end at the coordinates where the left mouse click will be made... This is where I stumbled... How to do it in an indicator or expert to catch this event is elementary, but how to do it in a script? How do I do it in Script?

By looping the script.
 
tara:
By looping the script.

I've tried, say, a loop in OnStart is spinning by itself, butOnChartEvent is no longer running at that time...

Is there a practical example of how to prevent the script from terminating until it waits for a mouse click event?

 
Batman:

I've tried, say, a loop in OnStart is spinning by itself, but OnChartEvent is no longer running at that time...

Is there a practical example of a script that doesn't terminate until it waits for a mouse click event?

How about looping through a custom function which depends on OnChartEvent to return?

This is an impromptu. Not sure if it works, but if I had to do this, I would try this very solution.


zy. I guess I was too hasty with my opinion. The OnChartEvent event seems to be unavailable in the scripts
 
AlexeyVik:

And if you loop through a custom function whose return depends on OnChartEvent

This is an impromptu. I'm not sure it will work, but if I had to do it, I'd try this very solution.

And how would it look?)).

I somehow suspect that when organizing any loop in the script, event processing no longer takes place... If it is done at all when scripts are running - I already doubt it...

Does such a simple task have no solution, at least "without dancing with tambourines"?

 
Batman:

And what would that look like?))

I somehow suspect that when any loop is set up in a script, event processing no longer takes place... If it is done at all when running scripts - I already doubt it...

Does such a simple task have no solution, at least "without dancing with tambourines"?

Well, the loop through a user-defined function is simple. This function is called through while loop and depending on value returned repeat or break

But the presence of OnChartEvent in scripts is... is questionable.

Apparently, we must understand what is possible in the scripts and what is more expensive to put there. It seems to me the result may be unpredictable and depends on the user, not the programmer. Imagine what will happen if you don't press the "rat" in such a script... the loop won't terminate. And what can the user do next? Like a monkey with a grenade.

 
AlexeyVik:

Well the loop via a custom function is simple. The while loop calls this function and depending on the returned value, repeat or break

But the presence of OnChartEvent in the scripts... is questionable.

Apparently, we must understand what is possible in the scripts and what is more expensive to put there. It seems to me the result may be unpredictable and depends on the user, not the programmer. Imagine what will happen if you don't press the "rat" in such a script... the loop won't terminate. And what can the user do next? Like a monkey with a grenade.

Some nonsense about a monkey with a grenade...))) The script is dragged onto the chart with a mouse, then the user clicks at the right place of the chart (pending and intercepting events must be managed somehow...), a graphical object is created, the script completes its work. For the "forgetful", it is possible to terminate waiting after some time has elapsed. Even a "hanging" crooked script is removed from the chart by right-clicking, "Remove script".

Question - why is it not possible to handle button press events or the like in the script? What's forbidden here?

 
Batman:

Some nonsense about a monkey with a grenade...)) The script is dragged onto the chart with a mouse, then a quite natural click at the right place of the chart (assuming that the event waiting and capturing has been arranged somehow...), a graphical object is created, the script terminates. For the "forgetful", it is possible to terminate waiting after some time has elapsed. Even the "hanging" crooked script is removed from the chart by right-clicking, "Remove script".

Question - why is it not possible to handle button press events or the like in the script? What's forbidden here?

You won't believe it. I have one friend to whom I say "Close terminal"... What do you think he does? HE DOES... That's what I call "monkey with a grenade". You never know where he's gonna throw it. You'll never guess what such a user will do to your program.

Why the event processing is impossible is a question for MQ.

Try to solve it using the Expert Advisor that deletes the Expert Advisor from the chart using the function ExpertRemove()

 
AlexeyVik:

Try solving this through an advisor ...

In the EA it works, BUT... there is another problem - how to get rid of the pop-up window with parameters (which don't exist...)?