Urgent help about a simple code

 

Hi;

Could you please kindly help me about the code of open and close a trade at a specific time that I will choose. In example I would like to buy (100000 units) Eur\Usd at 1.00 pm and close it 3.00 pm.

Thanks many...

 
thanks but I'm kind of a beginner about programming so could you please give whole code about the example I give above ...
 

I really need your help folks, and asking kindly for your help about the code of :

I would like to buy 1 lot Eur\Usd at 1.00 pm and close at 2.00 pm

Regards.

 

Ozc - are you planning on learning programming with MQL? If so, you're welcome to remain on the forum.


CB

 

Yeah, that's the thing Ozc.. We're here to help and point you in the right direction. But nobody here will do you work for you if you're not even trying.
Come back with some code/effort and we'll keep helping you. Otherwise, you can pay a hired programmer to do it for you.

Jon

 

here is the part of a code, as a beginner I need your advice .

Will this code help me to buy Eur\ Usd at 1.30 pm ?

int Hour(),Minute();

if(Hour()=01 && Minute()=30)
{
ticket=OrderSend(EUR\USD,OP_BUY,1,Ask,3,"My order #2",16384,0,Green);

}

 
Ozc wrote >>

here is the part of a code, as a beginner I need your advice .

Will this code help me to buy Eur\ Usd at 1.30 pm ?

int Hour(),Minute();

if(Hour()=01 && Minute()=30)
{
ticket=OrderSend(EUR\USD,OP_BUY,1,Ask,3,"My order #2",16384,0,Green);

}

There's a few mistakes in there.

1. Hour() and Minute() are functions that return values. They are not variables. Use them to store the values in one of your variables.

2. In your "if" condition, it will always be true because you are assigning value with '=' instead of comparing them with '=='.

3. Your symbol, needs to be a string. either use Symbol() or "EURUSD" (yes, with the quotes).

4. I believe you're missing the takeprofit parameter in your OrderSend() function and going straight to the comment.

Jon

 

Other than that - great. ;-)

Here's a tip. The only way you are going to achieve your aim is:

a) Learn how to do it

b) Pay someone else to do it


On the assumption that you pick option a, you need to modify your approach from what you are doing right now. Picking little bits of code (and crap code at that - harsh but true) and trying to staple them together will not get you anywhere. Here are the steps:

1) Read the book and consult the documentation to appraise yourself of the structure of an EA - variable types, syntax, init() & start() functions and what they do

2) Take one of the sample mq4 files

3) Open the documentation and consult it as you ...

4) Annotate every line in the mq4 file to explain to yourself what it is doing

5) When you are confident that you know enough to structure a simple EA ...

6) Write down your trading strategy - try to structure it as a flowchart or pseudocode

7) Create the skeleton structure of your EA - deciding what to put in the init() function, what to put in the start() function and what discrete functions of your own you will call

8) Code

9) Perform unit test (repeating step 8 as necessary with Print() statements to tell you the contents of variables and to monitor logic flow)

10) Perform backtests, forward walk analysis and optimization


This may seem to you like a long-winded approach, but its really not that bad - even for a beginner. Once you get half way through step 4, you'll agree that you are doing the right thing.


CB

Reason: