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
1. ...
2. You also have error 4062 - which is 'string parameter expected'. That happen because OrderSend() function has 11 input parameters (4 of them is default) and yet you only write 9 of them. Either write all of its 11 parameter of just (11 - 4) 7 of them.
further to the previous qn, is there something wrong with my expiration time for the below?
OrderSend (Symbol(),OP_SELLSTOP, lots, Bid,0, max+ (SL)*Point, Bid-(max-min),12:00,CLR_NONE);
Yes. You cannot set a SELLSTOP at the current Bid price.
You are omitting parameters at random from the OrderSend. You can stop putting in parameters at any time in sequence. You can't stop for a while then start up again. If you need to go up to the expiration time you need to supply all the earlier parameters. There is no need to supply later parameters.
You datetime constant is badly formed. Should be like this
https://docs.mql4.com/basis/types/datetime
These are absolute times and not what you are looking for. I assume you want to expire the order at 12:00 on the same day as the order was placed. You are going to have to put some more code in there to make that happen. It won't happen as easily as you hope.
These are absolute times and not what you are looking for. I assume you want to expire the order at 12:00 on the same day as the order was placed.
Ah yes, a neat piece of code :-)
I might write it as ...
Hi raptor,
sorry for the late reply.
what does SRC means?
anyway
1) at 6am, it looks at the past 5 bars to find the max and min
2) I am looking at the H1 chart, sorry please ignore the comments
3) there is a {, but also a }. i thought it will be good to put everything inside a {}
Thanks.
Hi WHRoeder, dabbler,
apologies, i changed to
if (Hour() ==6 && Minute()==0 && Seconds() ==0)
max= iHighest(NULL,0,MODE_HIGH,5,1);
min = iLowest(NULL,0,MODE_LOW,5,1);
maxvalue = iHigh (NULL,0,max);
minvalue = iLow (NULL,0,min);
if(LOS==-1)
OrderSend (Symbol(),OP_SELLSTOP, lots, minvalue-20*Point,0, maxvalue+ (SL)*Point, minvalue -(maxvalue-minvalue),0,0,(TimeCurrent() + 5*60*60),CLR_NONE);
but still, it seem to put pending orders at each of the next 6 bars. which is not what i want.
any suggestion? Thanks.
Hi raptor,
sorry for the late reply.
1. what does SRC means?
anyway
2) at 6am, it looks at the past 5 bars to find the max and min
3) I am looking at the H1 chart, sorry please ignore the comments
4) there is a {, but also a }. i thought it will be good to put everything inside a {}
Thanks.
2. No at 6am it does the first line, at any other time it does the other lines . . .
4. Use braces { } when you need to . . . a Function, a loop, a bunch of code to be executed as a result of an if test . . . this is related to 2.
3) there is a {, but also a }. i thought it will be good to put everything inside a {}
You do not put braces (curly brackets) in code for the reason "I thought it will be good".
This code ..
is read by the compiler as
When the if statement is true the following line is executed. That is not what you want. ALL the code you want to be executed as a result of the if statement being true is put into a BLOCK defined by the braces.
Now this can get a bit confusing since there are many ways of indenting the text and positioning the braces. BUT the compiler doesn't care. You could (and some people do) format the same code in weird ways.
The compiler doesn't care. It is us hoomins that have to read and understand the code.