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
int start()
{
int ticket;
int i;
for (i = 0; i=20000; i++)
{
ticket = OrderSend(Symbol(),OP_SELL,0.1,Bid,3,Bid+i*Point,0,"SHORT",0,0,Red);
if (ticket > 0)
Print("Way hey, it worked for a stoplevel of ",i," pips";
}
return(0);
}
:-)
CB
Hello olosta
Good, Digits sorted out the MarketInfo() results.
I really don't understand at all :$.
???
.
int ticket=OrderSend("EURUSD",OP_SELL,1,Bid,3,1.50,1.30,"SHORT",0,0,Red);
1.50, 1.30?
this is not the way to use system - even for test. Is not real and would never be used so why attempt using values like that...
.
olosta, your best option is to read REF.1 below.
You really must understand how to use Tradng Functions and how to program with MQL4.
It is no good getting one line to work, then another goes wrong - all because of limited understanding.
REF.1: Order Characteristics and Rules for Making Trades https://book.mql4.com/trading/orders
REF.2: Requirements and Limitations in Making Trades https://book.mql4.com/appendix/limits
.
Make efforts to follow The MQL4 Book which has many examples which are explained line by line.
.
I have nothing else which I can offer - is up to you to study and learn.
Good luck on your journey.
Hello olosta
Good, Digits sorted out the MarketInfo() results.
I really don't understand at all :$.
???
.
int ticket=OrderSend("EURUSD",OP_SELL,1,Bid,3,1.50,1.30,"SHORT",0,0,Red);
1.50, 1.30?
this is not the way to use system - even for test. Is not real and would never be used so why attempt using values like that...
.
olosta, your best option is to read REF.1 below.
You really must understand how to use Tradng Functions and how to program with MQL4.
It is no good getting one line to work, then another goes wrong - all because of limited understanding.
REF.1: Order Characteristics and Rules for Making Trades https://book.mql4.com/trading/orders
REF.2: Requirements and Limitations in Making Trades https://book.mql4.com/appendix/limits
.
Make efforts to follow The MQL4 Book which has many examples which are explained line by line.
.
I have nothing else which I can offer - is up to you to study and learn.
Good luck on your journey.
Are we worried that MODE_STOPLEVEL returns zero?
I can't recall if this means that stops are disabled or if it means that there is no limit on stops.
CB
okay I am going to read your links because I have not enough knowledge about it.
I made a mistake when I said I could not modify the PT and SL from a open position market order. It is very strange : when I specify a 1.50 SL and a 1.30 PT in the ordersend(), it doesn't work, but if I put an ordersend() without PT and SL, it send a market order to the market, and then I directly modify the open order by putting the SL 1.50 and the 1.30 PT value, it works.
To be continued...
PS : (In my previous message, :$ is a "confused smiley" :) )
Hi all,
I read all the links, but nothing that helps me...
Just for info, I use this for now, but it is a little stupid!
int ticket=OrderSend("EURUSD",OP_SELL,0.1,Bid,3,0,0,"SHORT",0,0,Red);
OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
OrderModify(OrderTicket(),OrderOpenPrice(),1.50,1.30,0,Blue);
I send the order first, and I put the SL and PT in second way.
It is ridiculous, but if it is the only way... hum.
Now I can write the real program.
If I find the solution I will put it, but don't hesitate if you find it ;)
Some brokers don't allow you to set Stops when you send the order, only in an order modify.
Now, because of the new NFA FIFO rules, some brokers won't let you use Stops at all...
You need to talk to your broker about how they process orders. This doesn't sound like a programming problem - assuming you tried it the way CB said...
- Tovan
Hi tovan,
ok but why can I put limit orders and stop orders with PT and SL, and not with the market orders ?
Hi tovan,
ok but why can I put limit orders and stop orders with PT and SL, and not with the market orders ?
That's a good question.
As was suggested earlier in this thread, you should try using Print statements just to make sure that your code is doing what you think it is. Pre-define your Price, Stop-Loss, and Take-Profit variables and Print them just before your OrderSend command. That way you will see what is going to the server and you can check it against your STOPLEVEL and FREEZELEVEL for your broker. You can find those values something like this:
You can't place a StopLoss (I believe a TakeProfit as well) any closer than StopLevel to the order entry price in an OrderSend command and you can't modify anything with an OrderModify if you are closer than FreezeLevel to the current price.
----
Here's a test. for a Long order:
I've been hunting for a new broker lately and in trying my EA's on different brokers I'm learning that, despite the common platform, there are a lot of differences in execution from one broker to the next. So the moral of the story is - there isn't one set of rules to follow. You have to figure out how your broker processes trades and what their rules are and make your EA work with that.
Another thing you can try is entering an order manually from the console. Try placing a Stop-Loss and Take-Profit when you place an order there. If it takes those values at the manual order placement then that's a good indication that there's something wrong in your code.
Good Luck.
Tovan
Hello,
I understand that you all want me to put print(), but I know that it is not the problem because I tried all the values possible. I think the problem is more like you said and like I said previously : the broker FXCM don't allow me to put SL and PT only on a market order ( may be because of some people that had problems with it open price too close to the SL/PT etc...), but it allows on the limit order and stop order. I sent a mail to them, I will put the answer.
"Another thing you can try is entering an order manually from the console. Try placing a Stop-Loss and Take-Profit when you place an order there. If it takes those values at the manual order placement then that's a good indication that there's something wrong in your code."
That's exactly what I think : I cannot put manually the SL/PT in a market order, only in stop and limit order, exactly like in MQL4. So I think my code is good. By saying that, you confirm what I think.
Thanks
Hello everybody,
I would like to translate the answer of the company that just answered to me ( I sent my mail two weeks ago, hum...)
"Hello Wilson Dos santos,
I received your mail concerning MT4.
The company Boston Technologies which we work with the plateform MT4, don't allow you for now to define a stop loss and a limit order when you trade. You effectivly have to open a market order first, and put this Stop loss and limit order after.
Regards,
Mlle DANH - FXCM"
That confirm what I was thinking...
Thank to you all, for your help