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.
Help making Buttons and other input fields on chart
-
VirtualFM
- Trader
- Posts: 84
- Joined: Sat Apr 28, 2012 3:45 am
-
Lowphat
- Trader
- Posts: 121
- Joined: Fri Jun 27, 2014 12:20 am
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();
}
}
}
- milanese
- TechAdmin
- Posts: 3293
- Joined: Wed Jan 09, 2013 9:02 am
- Location: btr rdx, r8 +
Help making Buttons and other input fields on chart
you can too look into the HiddenPendingEA code it has some button functions...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.
Cheers
Tommaso
Global Prime is the official SHF broker 
Searching for Servers and Workstations with individual configuration?
Just PM
Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
Searching for Servers and Workstations with individual configuration?
Just PM
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
-
VirtualFM
- Trader
- Posts: 84
- Joined: Sat Apr 28, 2012 3:45 am
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!
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!