another quiz about what could be the sourcecode ....
Right! Thank you for your response Meikel!
The sourcecode that folows below is the code of a default script from MQ4, called "Trade". That messages in the Daily I described previously was about this script:
//+------------------------------------------------------------------+
//| trade.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#include <stdlib.mqh>
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| script "trading for all money" |
//+------------------------------------------------------------------+
int start()
{
//----
if(MessageBox("Do you really want to BUY 1.00 "+Symbol()+" at ASK price? ",
"Script",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);
//----
int ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,"expert comment",255,0,CLR_NONE);
if(ticket<1)
{
int error=GetLastError();
Print("Error = ",ErrorDescription(error));
return;
}
//----
OrderPrint();
return(0);
}
//+------------------------------------------------------------------+
Right! Thank you for your response Meikel!
The sourcecode that folows below is the code of a default script from MQ4, called "Trade". That messages in the Daily I described previously was about this script:
//+------------------------------------------------------------------+
//| trade.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net//"
#include <stdlib.mqh>
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| script "trading for all money" |
//+------------------------------------------------------------------+
int start()
{
//----
if(MessageBox("Do you really want to BUY 1.00 "+Symbol()+" at ASK price? ",
"Script",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);
//----
int ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,"expert comment",255,0,CLR_NONE);
if(ticket<1)
{
int error=GetLastError();
Print("Error = ",ErrorDescription(error));
return;
}
//----
OrderPrint();
return(0);
}
//+------------------------------------------------------------------+
at the first glance....
both isnt used ... and therefore not necessary...
#include <stdlib.mqh>
#include <WinUser32.mqh>
makes no sense:
if(MessageBox("Do you really want to BUY 1.00 "+Symbol()+" at ASK price? ",
"Script",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);
if you drag and drop a script to buy on a chart why do you need a second confirmation ?
and why do you return (1) if answer is no ? makes no sense... this return value is never been checked...
i have to admit, that i never written scripts and therefore dont know the behavior of scripts.
i know EA's and Indicators, but havent used scripts til now.
its late, maybe another coder find the answer, i am tired... good night
Did you enable Trading for Scripts at all?
Dear Fx1.net,
Thank you for your response.
I think I enabled trading for Scripts when I Selected "Tools" --> "Options" --> "Expert Advisor" --> Enable Expert Avisor.
Am I Right?
Thanks
Rafael
at the first glance....
both isnt used ... and therefore not necessary...
#include <stdlib.mqh>
#include <WinUser32.mqh>
makes no sense:
if(MessageBox("Do you really want to BUY 1.00 "+Symbol()+" at ASK price? ",
"Script",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);
if you drag and drop a script to buy on a chart why do you need a second confirmation ?
and why do you return (1) if answer is no ? makes no sense... this return value is never been checked...
i have to admit, that i never written scripts and therefore dont know the behavior of scripts.
i know EA's and Indicators, but havent used scripts til now.
its late, maybe another coder find the answer, i am tired... good night
Hello Meikel,
Thanks for your help!
Let me explain a thing to you:
I'm begginer at Forex Trading. But I want open a buy order at a price, for example, and, when the price reaches certain value (that I want to define), I want the position being closed by one robot.
Until now, I must close the orders manually.
My problem actually, is that I don't know what kind of Robot I must use to do it for me (EA or Script).
Do you think I can solve this with an EA?
Once more, thank you
Regards
Rafael
script runs once
an EA after attached to a chart runs every tick - details in the manual
the only way to open and close orders over a longer time without interaction is therefore an EA
script runs once
an EA after attached to a chart runs every tick - details in the manual
the only way to open and close orders over a longer time without interaction is therefore an EA
All Right!
Thank you for these information!
Cordially
Rafael.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Everybody!
I'm looking for someone's help because I don't know if the scripts I have created does not work in DEMO mode of trading at MQ4.
I just know that, when I load an "open order" script, for example, the daily returns two messages:
First that my script was removed and
after "called functions are not allowed"
Thank you everybody!
Regards
Rafael Elias Grígolo.