Buttons do manage different functions via chart

 

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

 

Not a simple answer to this question fully.

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

 

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

br

John

 

"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);  
}
 

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

br,

John

Reason: