what error u get (i c u have writen 2 c the last error (Print("OrderSend sellstop failed with error #",GetLastError());))
what error u get (i c u have writen 2 c the last error (Print("OrderSend sellstop failed with error #",GetLastError());))
There is no error (it is showing Error - #0). Problem is that code is placing one BuyStop and endless SellStop orders. I haven't figured it out why.
Idea is to make code place one BuyStop and one SellStop order on previous bar High and Low.
try BUYLIMIT 2
something like this:
if(NewBar() == true) { ticket = OrderSend(Symbol(),OP_BUYSTOP,lot,h1,0,(h1-(h1-l1)),(h1+(h1-l1)),"Shadow buy",0,0); if (ticket == -1) { Print("OrderSend buystop failed with error #",GetLastError()); ticket=OrderSend(Symbol(),OP_BUYLIMIT,lot,h1,0,(h1-(h1-l1)),(h1+(h1-l1)),"Shadow buy",0,0); if (ticket == -1) { Print("OrderSend buystop failed with error #",GetLastError()); return(0); } } ticket = OrderSend(Symbol(),OP_SELLSTOP,lot,l1,0,(l1+(h1-l1)),(l1-(h1-l1)),"Shadow sell",0,0); if (ticket == -1) { Print("OrderSend sellstop failed with error #",GetLastError()); ticket = OrderSend(Symbol(),OP_SELLLIMIT,lot,l1,0,(l1+(h1-l1)),(l1-(h1-l1)),"Shadow sell",0,0); if (ticket == -1) { Print("OrderSend sellstop failed with error #",GetLastError()); return(0); } } }
regardless
(h1-(h1-l1)) == l1
(l1+(h1-l1)) == h1
Define a block for the if statement like so...
Before the if statement only referred to the line immediately following it.
u say the problem isn't BUYSTOP or BUYLIMIT
I deleted that message... U beat me to it.
Oops, didn't mean it was just a question, sorry
try BUYLIMIT 2
something like this:
Thank you! I got it working. Don't really understood what was different than I tried before posting my problem.
Also thanks for pointing at ..== l1 &..==h1!
I will start learning how to implement next trick for my EA.
Now, can anyone tell me how to get expiration dates in the ordersend() function?
Thanks!
datetime expire = D'2010.12.23 00:25'; OrderSend(Symbol(),OP_BUYLIMIT,0.1,Ask-1000*Point,3,Ask-2000*Point,Ask+2000*Point,"",12345,expire,Green);

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Please suggest what do I need to change on this code? Idea for code is to place at last bars one BuyStop at high and one SellStop at low. This code is just adding SellStops.