You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Yes the OnChartEvent() is the same for both languages.
Thanks a lot.
I have also found that many of the code that was written for MT5 now also works on MT4.
I know because i have tried many things in the past and things that did not work one year ago, do work now so this shows that they are still actively developing both languages.
I have also found that many of the code that was written for MT5 now also works on MT4.
I know because i have tried many things in the past and things that did not work one year ago, do work now so this shows that they are still actively developing both languages.
if ( Morning || Midnight )
{
// Do not turn on light just for today...
}
// I say Twice ' Do not turn... ' for ' switch ' operator - Q: Can I say ' Once '?
switch ( Today )
{
case Morning : // Do not turn on light just for today...
break;
case Midnight : // Do not turn on light just for today...
break;
} //---switch Close
I already read article and checked out some other people codes for ' CHARTEVENT_OBJECT_DRAG ' that how to used from it.
Just my purpose when I drag object ' Stop Loss, Take Profit, Pending Orders ' that could moves with that object. ( of course all of them could be separately )But unfortunately that is not make senses for me. Just now I am think I was waste my time for just useless things. Because their code style really different from mine.
( my code style just simple - like mql4 documentation code style - which is I am understanding a little a bit more )
Also I was seen one EA script for modify orders ( sl, tp etc. ) - and it works without ' CHARTEVENT_OBJECT_DRAG '... I hope you know that what I mean.
Now, I am really need help just with simple example for ' CHARTEVENT_OBJECT_DRAG ' with HLine or Trendline Object. Or clearly explanation or just something good ( / more clearly ) comment.
I already spent a lot of time and I still researching about that. I hope I will get answer soon.
All the best to you.
Thanks in advance.
if ( Morning || Midnight )
{
// Do not turn on light just for today...
}
This will be true Morning OR Midnight
switch ( Today )
{
case Morning : // Do not turn on light just for today...
break;
case Midnight : // Do not turn on light just for today...
break;
} //---switch Close
This has a separate case for Morning and a separate case for Midnight.
So those are two different things.
I already read article and checked out some other people codes for ' CHARTEVENT_OBJECT_DRAG ' that how to used from it.
Just my purpose when I drag object ' Stop Loss, Take Profit, Pending Orders ' that could moves with that object. ( of course all of them could be separately )But unfortunately that is not make senses for me. Just now I am think I was waste my time for just useless things. Because their code style really different from mine.
( my code style just simple - like mql4 documentation code style - which is I am understanding a little a bit more )
Also I was seen one EA script for modify orders ( sl, tp etc. ) - and it works without ' CHARTEVENT_OBJECT_DRAG '... I hope you know that what I mean.
Now, I am really need help just with simple example for ' CHARTEVENT_OBJECT_DRAG ' with HLine or Trendline Object. Or clearly explanation or just something good ( / more clearly ) comment.
I already spent a lot of time and I still researching about that. I hope I will get answer soon.
All the best to you.
Thanks in advance.
You can drag a line when
OBJPROP_SELECTED ==1
Both are true and you can simple read the values in by using \
In stead of
Almost I was not any idea how can I write code for Stop Loss and Take Profit Drags when I started to do that, thanks a lot man.
Now I feel I can do what I want after your great comment.
Market Closed
So, I already tried and now I can get ' OBJPROP_PRICE ' which one I want.
When I drags ' HLine ' object and then Print() updates once in a second. Because I use EventSetTimer( 1 ).
But I need Print() won't updates once in a second. I would like to Print() should updates after I stopped drags.
If you understand me please help me or give me advice.
All the best to you.
So you can store the value of OBJPROP_PRICE in a double and then compare them.
If they differ you know the dragging has been started, and then if they equal again you know the dragging has been stopped.
//| Drag Hline.mq4 |
//| Copyright 2017, Marco vd Heijden, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, Marco vd Heijden, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
double price; // price variable;
bool drag; // drag flag
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(1);
//--- create Hline
ObjectCreate(0,"line",OBJ_HLINE,0,0,Ask);
//--- store value
price=ObjectGetDouble(0,"line",OBJPROP_PRICE,0);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//--- compare values
if(price!=ObjectGetDouble(0,"line",OBJPROP_PRICE,0))
{
drag=1; // set drag flag
price=ObjectGetDouble(0,"line",OBJPROP_PRICE,0); //store new value
}
if(drag==1)
{
if(price==ObjectGetDouble(0,"line",OBJPROP_PRICE,0))
{
drag=0; //reset drag flag
Alert(" New value set: ", DoubleToString(price));
}
}
}
//+------------------------------------------------------------------+
Or you could start a counter once dragging has been detected there are many ways to do it.,