A friend of mine told me about this site. She toled me they have the best mql programmers.
Here's one:
If I set a code, for example....to buy at a 15:30(most of the news time), I checked the economic calendar.
if (Hour()==15)
{
if (Minute()>=30)
{
if (Seconds()>=00)
[/PHP]
After this, something like this goes:
[PHP]
OrderSend(Symbol().......................
Everyone writes it different,hehe.
Why can't it be the same?
Okay, here's the deal. For the above code, I want the OrderSend........and the continuing part to create a BuyStop 30 pips above the price at 15:30:00, and a SellStop 25 pips underneath the price at 15:30:00.
I asked my best friend, and she said to ask you guys. So, I really hope you guys are a big help.
I've spent weeks trying to figure out this code. I'm not kidding. So, will anybody that does coding in mql4 help me?
int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)
symbol - Symbol for trading.
cmd - Operation type. It can be any of the Trade operation enumeration.
volume - Number of lots.
price - Preferred price of the trade.
slippage - Maximum price slippage for buy or sell orders.
stoploss - Stop loss level.
takeprofit - Take profit level.
comment - Order comment text. Last part of the comment may be changed by server.
magic - Order magic number. May be used as user defined identifier.
expiration - Order expiration time (for pending orders only).
arrow_color - Color of the opening arrow on the chart. If parameter is missing or has CLR_NONE value opening arrow is not drawn on the chart.
Please note: your broker (most likely) will not accept new orders on 15:30, don't even dream about it. Yes, it will work on demo but not on real account - not any time sooner than 5 minutes before the news and no less than 3 minutes after the news.
Asked & Answered
Hi all,
I thought I had my answers with the following code:
double range[5];
for(int i=1;i<5;i++)
{
range={High-Low};
int Max=ArrayBsearch(range,10,WHOLE_ARRAY,1,MODE_ASCEND);
double MaxRange=(High[Max]-Low[Max])/Point;
}
Print("Max Range: ",MaxRange," found at index: ",Max);
But it still just returns the last index not the largest range index.
Any further help would be appreciated.
SaxMan
Error Fixed
Hi all,
I thought I had my answers with the following code:
double range[5];
for(int i=1;i<5;i++)
{
range={High-Low};
int Max=ArrayBsearch(range,10,WHOLE_ARRAY,1,MODE_ASCEND);
double MaxRange=(High[Max]-Low[Max])/Point;
}
Print("Max Range: ",MaxRange," found at index: ",Max);
[/code]
But it still just returns the last index not the largest range index.
Any further help would be appreciated.
SaxManHere's the fix:
[code]
double range[5];
for(int i=1;i<5;i++)
{
range={High-Low};
int Max=ArrayMaximum(range);
double MaxRange=(High[Max]-Low[Max])/Point;
}
Print("Max Range: ",MaxRange," found at index: ",Max);This could be used to get the highest/lowest(using ArrayMinimum(range)) of the array to compare any variables.
Hope this helps,
SaxMan
Same Code with additions
Added:
* Minimum range
* Vertical Lines to highlight Max and Min range bars:
for(int i=1;i<2000;i++)
{
range={High-Low};
int Max=ArrayMaximum(range,WHOLE_ARRAY,1);
int Min=ArrayMinimum(range,WHOLE_ARRAY,1);
double MaxRange=(High[Max]-Low[Max])/Point;
double MinRange=(High[Min]-Low[Min])/Point;
}
Print("Max Range: ",MaxRange," pips found at index: ",Max);
Print("Min Range: ",MinRange," pips found at index: ",Min);
int time1=Time[Max];
int time2=Time[Min];
ObjectCreate("stats1",OBJ_VLINE,0,0,0);
ObjectSet("stats1", OBJPROP_TIME1, time1);
ObjectSet("stats1", OBJPROP_COLOR, Red);
ObjectSet("stats1", OBJPROP_WIDTH, 1);
ObjectCreate("stats2",OBJ_VLINE,0,0,0);
ObjectSet("stats2", OBJPROP_TIME1, time2);
ObjectSet("stats2", OBJPROP_COLOR, Blue);
ObjectSet("stats2", OBJPROP_WIDTH, 1);Code complies, but does not display value
extern Bool Direction_Up=true;
if(Direction_Up==true) Dir="UP"; ///////////This is wrong conversion - How do I convert it to the proper syntax????
ObjectCreate("Dir", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Dir", 10, "Arial", White);///////////This is wrong - How do I get it to display UP on the screen????
ObjectSet("Dir", OBJPROP_CORNER, 1);
ObjectSet("Dir", OBJPROP_XDISTANCE, 36);
ObjectSet("Dir", OBJPROP_YDISTANCE, 120);///
Hi,
{
int i;
if ((Year() >= X) && (Month() >= Y))
{
Comment("===========",expired,"===========");
return(0);
}
GetPosition = StrToTime(StrGetPosition);
StartOrderTime = StrToTime(StrStartOrderTime);
EndOrderTime = StrToTime(StrEndOrderTime);
return(0);
My Question is :
is GetPosition, StartOrderTime, EndOrderTime will be executed?
Cheers
Questions
Hi,
A friend of mine told me about this site. She toled me they have the best mql programmers.
Here's one:
If I set a code, for example....to buy at a 15:30(most of the news time), I checked the economic calendar.
if (Hour()==15)
{
if (Minute()>=30)
{
if (Seconds()>=00)
[/PHP]
After this, something like this goes:
[PHP]
OrderSend(Symbol().......................
Everyone writes it different,hehe.
Why can't it be the same?
Okay, here's the deal. For the above code, I want the OrderSend........and the continuing part to create a BuyStop 30 pips above the price at 15:30:00, and a SellStop 25 pips underneath the price at 15:30:00.
I asked my best friend, and she said to ask you guys. So, I really hope you guys are a big help.
I've spent weeks trying to figure out this code. I'm not kidding. So, will anybody that does coding in mql4 help me?
---Julia---
extern Bool Direction_Up=true;
if(Direction_Up==true) Dir="UP"; ///////////This is wrong conversion - How do I convert it to the proper syntax????
ObjectCreate("Dir", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Dir", 10, "Arial", White);///////////This is wrong - How do I get it to display UP on the screen????
ObjectSet("Dir", OBJPROP_CORNER, 1);
ObjectSet("Dir", OBJPROP_XDISTANCE, 36);
ObjectSet("Dir", OBJPROP_YDISTANCE, 120);///
Hi Iscuba11,
see code for fix & explanation
string Dir; //-- Dir has to be declared as a string
if(Direction_Up==true) Dir="UP";
ObjectCreate("Dir", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Dir",Dir, 10, "Arial", White); // -- you left out the text to print - you named the object only.
ObjectSet("Dir", OBJPROP_CORNER, 1);
ObjectSet("Dir", OBJPROP_XDISTANCE, 36);
ObjectSet("Dir", OBJPROP_YDISTANCE, 120);Hope this helps,
SaxMan
Weeks?!
MQL4: automated forex trading, strategy tester and custom indicators with MetaTrader
search for OrderSend() - docs
Quote
OrderSend - MQL4 Documentation
int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)
symbol - Symbol for trading.
cmd - Operation type. It can be any of the Trade operation enumeration.
volume - Number of lots.
price - Preferred price of the trade.
slippage - Maximum price slippage for buy or sell orders.
stoploss - Stop loss level.
takeprofit - Take profit level.
comment - Order comment text. Last part of the comment may be changed by server.
magic - Order magic number. May be used as user defined identifier.
expiration - Order expiration time (for pending orders only).
arrow_color - Color of the opening arrow on the chart. If parameter is missing or has CLR_NONE value opening arrow is not drawn on the chart.
So in our case we have this:
That is it!
No stoploss, no takeprofit.
Please note: your broker (most likely) will not accept new orders on 15:30, don't even dream about it. Yes, it will work on demo but not on real account - not any time sooner than 5 minutes before the news and no less than 3 minutes after the news.
Use search engines
Google
Yahoo!
and others.
PS:
if you want me to write an EA for you, PM me.
You made my day and weekend with the code correction. Thanks ever so much!
Sincerely,
Dave
<<<How can use ObjectCreate on an indicator-separate-window versus the chart-window???? This would be handy!