Suppose you want to set the profit target to 30 pips, then do the following:
Look up this line in the buy routine,
ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,Ask-20*Point,0,"expert comment",255,0,CLR_NONE);
and make it look like this:
ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,Ask-20*Point,Bid+30*Point,"expert comment",255,0,CLR_NONE);
Thanks. I'll try it out. Could you tell me what changes I would need to do the same for a sell order?
I think you owe it to yourself to study MQL if you are going to to use it. Otherwise depending on others is too dangerous.
Study the code I gave you and see WHAT changes and WHERE the changes I made. That should give you clues on what to change in the sell routine.
Good luck.
Thanks for the advice. I've been slowly learning the language through the mql course, but as i have no programming experience, it has been a slow process. Just wanted to get started trading in the meantime.
Okay, you should try to understand the code better. I think if you had spent some time, your definitely would have understood how the buy/sell ordersend functions work.
For the sell, assuming you want 30 pips of stop loss,
change
ticket=OrderSend(Symbol(),OP_SELL,1.0,Bid,3,Bid+20*Point,0,"expert comment",255,0,CLR_NONE);
to
ticket=OrderSend(Symbol(),OP_SELL,1.0,Bid,3,Bid+20*Point,Ask - 30*Point,"expert comment",255,0,CLR_NONE);
Edit:- I had an error that I corrected. Thanks for pointing it out.
excite...
doesn't it feel good to figure it out yourself?
I did have an error in my code that I corrected.
Thanks.
Yeah. I'll look forward to the day when I can build an EA from scratch! Thanks.
Buy/sell EA
Hello all,
I probably already now what is gonna happen when I ask this question, but I will go ahead and re-ask it again. Previously I asked about an EA that could buy and sell at the same time. Execution for the buy and sell is simultaneously put in at the same time. Newdigital had moved my thread to another thread. I have tried the "timed based EA", and is not what I am looking for. There seems to be something wrong with it. When I check the experts tab on the bottom of Metatrader, this is what it says about the EA "2008.01.29 18:29:04 TimeBasedEA USDCHF,H1: uninit reason 3", "2008.01.29 18:31:26 TimeBasedEA USDCHF,M30: uninit reason 4, "2008.01.29 18:25:24 TimeBasedEA USDCHF,H1: uninit reason 5"!
I truly do apologize for hassling you folks. I have googled and dogpiled about such EA and came to a conclusion that this is my only hope. So, I was wondering if you can direct me to another EA that has the same concept!
Very Respectfully,
Benjamin Kirwin
Just quick review.
TimeBreakExpert_v1: idea development thread and this one as well:
- version #1 is here.
- version #1.1 is here.
WNV EA: this EA buys and/or sells at a certain time of day.
TimeBasedEA: buy and sell specific currency pair at specific time based on MACD_Sample EA is here.
ScheduleTrader EA is here.
Some links are from elite section so sorry.
But I think you know most of those EAs.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Does anyone have a simple script (not an EA) that will buy/sell orders
with a stop and a target profit input?
OR
The attached buy/sell scripts don't have a target profit
parameter. If someone could please add target profits to the attached scripts that would also work.
Either scenario would be appreciated.
Thanks.