stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Help making Buttons and other input fields on chart
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4895
Page 1 of 1
Author:  VirtualFM [ Fri Sep 09, 2016 6:11 pm ]
Post subject:  Help making Buttons and other input fields on chart

Hello guys!

Sorry for not hanging around so much on the last couple years, been busy making my own stuff (some would say I am just wasting time, because sometimes I have those "brilliant ideas" and a while later I browse through the forum and understand someone had that idea some months/years ago!) (for example, a couple weeks ago i had this "brilliant" idea where i would close obviously loosing positions (after a bunch of rules going the bad way) as long as there was a positive profit for the day, so that psychologically there was no loss on that day but still keep closing crappy trades. So I would have to organize opened positions in arrays, something I never dealt with, and order them, and close those that would be in range, etc... That took almost a whole week of thinking, studying and experimenting, and then yesterday i found this, which has pretty similar ideas and would have helped me a lot
http://www.stevehopwoodforex.com/phpBB3 ... 57#p137367)

Anyway...

I wanted to put some buttons on the chart in order to quickly change some parameters, instead of open the EA properties and look for the input. And I realize that we can do this now, making buttons and some other fields, but everything I saw looked overcomplicated or just didn't work. For example, I followed this simple tutorial

http://automatedtradingsoftware.co.uk/h ... n-in-mql4/

and couldn't see anything happening anywhere!

So, for those in the know, do you know some examples, or could you point me to some where I could see an actual example of a working button, or a radio button, or a pull-down menu, if possible, or a field where we could input numbers? Or have you stumble upon some ea/indicator on this site that has such things?

Thank you so much.
Author:  Lowphat [ Fri Sep 09, 2016 8:07 pm ]
Post subject:  Help making Buttons and other input fields on chart

Code: Select all

//+------------------------------------------------------------------+
#include <ChartObjects\ChartObjectPanel.mqh>
#property strict
#property indicator_chart_window
CChartObjectButton ButtonA;
int a = 1;
void OnInit() {CreateButtonA(0);}
void OnDeinit(const int reason) { }
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
//----
   return(rates_total);
  }
bool CreateButtonA(const long chart_ID=0)
{ 
     ResetLastError();
     if(!ButtonA.Create(0,"ButtonA",0,10,25,75,15))
     {
         //--- display the error message in Experts journal
         Print(__FUNCTION__+", Error Code = ",GetLastError());
         return(false);
     }
     ButtonA.Description("Boobs");
     ButtonA.FontSize(10);
     ButtonA.Corner(CORNER_LEFT_LOWER);
     ButtonA.Anchor(ANCHOR_CENTER);
     ButtonA.State(false);
     return true;
} 
void OnChartEvent(const int id,
                    const long &lparam,
                    const double &dparam,
                    const string &sparam)
    {

     if(id==CHARTEVENT_OBJECT_CLICK)
       {  
           if (sparam=="ButtonA") 
           {
              if(ButtonA.State() == true)
              {
               a++;
                Comment ("TEST\n"+IntegerToString(a));
              }

              ChartRedraw();
           }
       }
    }
    
Author:  milanese [ Fri Sep 09, 2016 10:02 pm ]
Post subject:  Help making Buttons and other input fields on chart

VirtualFM ยป Fri Sep 09, 2016 6:11 pm wrote:Hello guys!

Sorry for not hanging around so much on the last couple years, been busy making my own stuff (some would say I am just wasting time, because sometimes I have those "brilliant ideas" and a while later I browse through the forum and understand someone had that idea some months/years ago!) (for example, a couple weeks ago i had this "brilliant" idea where i would close obviously loosing positions (after a bunch of rules going the bad way) as long as there was a positive profit for the day, so that psychologically there was no loss on that day but still keep closing crappy trades. So I would have to organize opened positions in arrays, something I never dealt with, and order them, and close those that would be in range, etc... That took almost a whole week of thinking, studying and experimenting, and then yesterday i found this, which has pretty similar ideas and would have helped me a lot
http://www.stevehopwoodforex.com/phpBB3 ... 57#p137367)

Anyway...

I wanted to put some buttons on the chart in order to quickly change some parameters, instead of open the EA properties and look for the input. And I realize that we can do this now, making buttons and some other fields, but everything I saw looked overcomplicated or just didn't work. For example, I followed this simple tutorial

http://automatedtradingsoftware.co.uk/h ... n-in-mql4/

and couldn't see anything happening anywhere!

So, for those in the know, do you know some examples, or could you point me to some where I could see an actual example of a working button, or a radio button, or a pull-down menu, if possible, or a field where we could input numbers? Or have you stumble upon some ea/indicator on this site that has such things?

Thank you so much.
you can too look into the HiddenPendingEA code it has some button functions...

Cheers :)

Tommaso
Author:  VirtualFM [ Sun Sep 11, 2016 5:21 pm ]
Post subject:  Help making Buttons and other input fields on chart

Hi Lowphat, thanks a lot for the code. It works, but even if it's really nice to stare at "Boobs" for a long time, I find this completely overcomplicated and counterintuitive. I went through "ChartObjectPanel.mqh" and "ChartObjectsTxtControls.mqh" and, boy, there is a ton of stuff I don't get over there!

Thank you as well, Milanese. Your example looks like you made "your own buttons" in a time when there were no button functionality available. And they look much more understandable than the official mumbo-jumbo. I will study them and try to make them clickable in a way that we see they are in a clicked state (which doesn't seem to be the case now, as you just want them to perform actions as soon as clicked).

Oh well, but not this weekend anymore.

Cheers!
All times are UTC Page 1 of 1