Questions for CAppDialog and CSpinEdit

 

I am rewriting my EA to use MQL4 newer Graphic Controls and I am having difficulties getting the EA to respond the way I would like.

The first problem is I would like the CAppDialog to Align to the right side of the charts as that is where the price action is.

The Second issue is with CSpinEdit I would like it to use doubles so I can use it as a Lot picker.

Any help would be appreciated. Thank you.

Files:
 
No worries I didn't really think I would get any answers from here but I thought I'd give it a go
 
The Second issue is with CSpinEdit I would like it to use doubles so I can use it as a Lot picker.

The source code for CSpitEdit resides in Include\Controls\SpinEdit.mqh. It wouldn't take much doing for you to make your own version from this for doubles instead of ints. Of course, you'd have to write the logic to say what a single increment would mean. For example, do you want to increase by 0.10 lots or 0.01 lots? You could get clever in the code and read in the min lot size from the broker for that symbol.

 

Thanks Anthony,

That is something I hadn't thought of and save it as SpinEdit_Double.mqh or something so it doesn't get over written on a platform update.

Cheers

Rod

 

Hello Anthony,

I took your suggestion on board and changed a few lines in <SpinEdit.mqh> and saved it to <SpinEditDouble.mqh> works sort of OK but as the numbers spin up they go from 2 decimal places to many "fills the Edit Box" I have tried "DoubleToString" in numerous places but doesn't change the read out... Thanks for the idea.


I also had some success with positioning the App the the right hand side of the chart but when I reduce the chart size the edge of the chart hides the App any thoughts on that anyone ...

Rod

 
I have tried "DoubleToString" in numerous places but doesn't change the read out... 

Try:

m_edit.Text(StringFormat("%.2f",m_value));

Also, there is a FileWriteInteger() and FileReadInteger() in your code. I think you would want FileWriteDouble() and FIleReadDouble().

 
I also had some success with positioning the App the the right hand side of the chart but when I reduce the chart size the edge of the chart hides the App any thoughts on that anyone ...

You seem to be on the right path with getting the chart width and height in pixels. Once determined, delete the existing panel & controls, then re-create them at the new position.

 

Back again I made the corrections you mentioned now the SpinEdit Box is working perfect..Unreal a big thanks.

Also made some edits on the Dialog it moves with the right side chart but the App breaks apart and SpinEditBox disappears but it is getting closer I have most likely have the commands in the wrong order.

Files:
 

With my limited ability my final try at this App. It is not what I exactly want but it will do until I figure it out.

Comment if this helps any or comment if you can find another way.

The buttons are there to Shift the App Left and Right. Yep you can just drag the App to were you need it but at the moment that is the only way I can find out to Shift the App.

What I think it needs is a way of saving the current Chart Window width to a variable and comparing it with the new Chart Window width if greater than or less then send the difference to the Shift command. 

Use the updated SpinEditDouble.mqh file here.

Cheers

Rod

 

Right now, your positions are hard coded.

What I would try:

1. Have a global x and y for the position of the dialog. Call them g_x and g_y if you like.

2. Use constants for the width and height.

3. Move all your creation code to a separate function. Call it something like fCreatePanel(). The dialog and ALL controls on the dialog are relative to g_x and g_y.

4. In OnChartEvent(), when a chart change event occurs, you can measure the width and height of the chart. When that occurs, you can delete the panel and sub-controls:

cpInterface.Destroy() 

then re-create them at the new g_x and g_y you determined:

fCreatePanel()
 
Anthony Garot:

Right now, your positions are hard coded.

What I would try:

1. Have a global x and y for the position of the dialog. Call them g_x and g_y if you like.

2. Use constants for the width and height.

3. Move all your creation code to a separate function. Call it something like fCreatePanel(). The dialog and ALL controls on the dialog are relative to g_x and g_y.

4. In OnChartEvent(), when a chart change event occurs, you can measure the width and height of the chart. When that occurs, you can delete the panel and sub-controls:

then re-create them at the new g_x and g_y you determined:

Hi Anthony,

One problem, as soon as cpInterface.Destroy() is called the App "EA" shuts down and gets taken of the chart. 

Reason: