Download MetaTrader 5
To add comments, please log in or register
Looking for like-minded people? You will find lots of them on the Forum!
JohnQ07
11
JohnQ07 2016.06.11 11:22 

Dear community,

I am looking for a possibility to open/manage a trade via buttons on the chart.

Creating a button is not the problem but to link it with a function is a problem.

One example what  I want to programm is - if I push a button - call it BUY then should appear a field with different inputfields like SL,TP, Risk in %...

After one has filled the fields you and you push OK a long trade is opened...


An other questions is how can I change bool variables with a button on a chart

eg. in your ea is a trailingstopp included an you decide to use it or not - I would like to have a button TL-Stopp. If it is on the button shoud be green otherwise red...


Thank you for your response!

br,

John

Keith Watford
Moderator
7990
Keith Watford 2016.06.11 12:22  

Not a simple answer to this question fully.

Create OBJ_EDITs for your inputs, read the values with your code and send the order.

whroeder1
13641
whroeder1 2016.06.11 13:07  
JohnQ07
11
JohnQ07 2016.06.11 20:29  

Thank you for your answers - I will check the code of Money Manager...

br

John

Janek6191
29
Janek6191 2016.06.12 06:42  

"One example what  I want to programm is - if I push a button - call it BUY then should appear a field with different inputfields like SL,TP, Risk in %..."

This is possible but harder than just making ever-visible buttons to change the variables.

Here is how it could look with visible fields. (arrows are just buttons, in the middle are rect-labels for background and on them are normal labels to display values)


"An other questions is how can I change bool variables with a button on a chart"

Simply make a global bool variable - in OnTick function do some actions according to if(variable){...}.

And if you want to change it do it in OnChartEvent() function. Here is example from my program (where "ReverseOnStop" is the object name):

if(sparam=="ReverseOnStop"){
         if(reverseOnStop){
            rev="OFF";
            reverseOnStop=false;
         }
         else{
            rev="ON";
            reverseOnStop=true;
         }
         ObjectSetString(chart_ID,"ReverseOnStop",OBJPROP_TEXT,"REVERSE ON STOP - "+rev);  
}
JohnQ07
11
JohnQ07 2016.06.14 18:54  

Thanks a lot for your answers - now I have to do trial and error - speek the usual things...

br,

John

/
To add comments, please log in or register