Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
I am developing my first ea right now and I am having trouble with a trailing stop. I can initiate an instant buy or sell order but I do not know how to give it a trailing stop. Can anyone help me with this. I am currently using an
OrderSend function for the instant orders. If someone could please tell me how to add a trailing stop to this, I would really appreciate it. thank you
I am developing my first ea right now and I am having trouble with a trailing stop. I can initiate an instant buy or sell order but I do not know how to give it a trailing stop. Can anyone help me with this. I am currently using an
OrderSend function for the instant orders. If someone could please tell me how to add a trailing stop to this, I would really appreciate it. thank you
We have many thread about trailing stop. You may check some EAs and scripts which are doing this job: Trailing Stop EA
I am developing my first ea right now and I am having trouble with a trailing stop. I can initiate an instant buy or sell order but I do not know how to give it a trailing stop. Can anyone help me with this. I am currently using an
OrderSend function for the instant orders. If someone could please tell me how to add a trailing stop to this, I would really appreciate it. thank you
Did you find one that worked or create one yourself. I am looking for the same and with the same frustration. If you now have a TS Script that drags over to a graph, would you post it or send it to me at: fdiebold@sbcglobal.net
Plenty of examples of Trailing Stop code on this site - use 'Search' function
My example of TS:
*************************************
extern int TS = 30; //Trailing Stop
int start()
{
//----
OrderSelect(0, SELECT_BY_POS);
if (OrderType() == OP_BUY) {
if (OrderStopLoss() < Bid-Point*TS) OrderModify(OrderTicket(),0,Bid-Point*TS,OrderTakeProfit(),0,Red); }
if (OrderType() == OP_SELL) {
if (OrderStopLoss() > Bid+Point*TS) OrderModify(OrderTicket(),0,Bid+Point*TS,OrderTake Profit(),0,Red); }
//----
}
When I use this script as a script to just drag over a graph it does not reflect activation has taken place. If I use a modify script, and then right click the mouse and select modify or delete order, the modify script settings are reflected in the modify window. But if I use your trailing stop script it does not reflect in the right click mouse - trailing stop window. This is the problem - How do I know if the trailing stop is even activated??
Script to modify the order by mouse.
I tried it long time ago and it worked.
It is translation from Russian:
Code:
Instruction for installation:
1. Open script in MetaEditor and set your desirable default settings.
Default settings in the script are started and finished
by this line //+--------------------------+
2. In Metarader: go to Tools, Options, Expert Advosirs
and select "Allow external experts import".
3. Move script to the chart by mouse just near the order
which you want to modify.
4. Move all the lines to the necessary levels:
- Open_Price_Line (white color by default) -
price to open the order (for pending orders only);
- Stop_Loss_Line (red color) - stop loss level;
- Take_Profit_Line (green color) - take profit level;
- Expiration_Line (yellow) - for pending orders only.
To remove stop loss, take profit, expiration date
so just delete the lines on the chart (by mouse).
Move the lines by mouse on the chart to modify the order.
Explanation of the settings inside the script:
Code:
Order_Find_Radius = 10;
It is distance between the price to open the order and where you drop this sctipt. Default is 10. If you are sniper so you may set to zero. It does not affecting on anything a lot because you should open the order manually before. So it is affecting on the following: will this script recognize the order to modify or not. I prefer 10 or more. 20 for example. Because I am not a sniper by mouse
Code:
Take_Profit = 50;
int Stop_Loss = 50;
It is understandable: stop loss and take profit value. You may set it to 100 (both) to move easy after.
Code:
Slippage = 5;
Understabdable.
Code:
Expiration_Shift = 0;
It is for pending orders only. Value is in bas. For example, if you are attaching (moving) ther script to H4 chart and Expiration_Shift = 3 so it means that the order will be expired in 12 hours (3 bars x 4 H timeframe).
How to use this script:
1. Open the order.
2. Move this script by mouse to the place with order price on the chart. If you get the error so it means that you are not sniper and you moved the script far away from the order on the chart. Just increase Order_Find_Radius value in this case. I prefer 20 for example (20 pips target aroud the order open price on the chart).
3. Wait. Pop up window will be opened (see image attached). Ignore this pop-up window (do not click on "OK" or "Cancel", just ignore). If this pop-up window prevent you to see or move the lines on the chart so just move this window to somewhere by mouse.
4. You should see the lines. Just wait 2 or 3 seconds. To speed up this process, or if you do not see red/green stop loss and take profit lines so simple click on the chart by mouse in any place.
5. Move take profit line and stop loss line what ven distance you want (by mouse on the chart). How to move? Double mouse click on the line and move.
6. So, now only you may press "OK" in pop-up window. Afer that order will be modified.
7. If you want to modify once again so move this script to the "open order place" and repeat it.
It looks complicated but it is very simple. Just set your desirable Order_Find_Radius and use your mouse.
Last edited by newdigital; 06-14-2007 at 06:47 PM.
The code I provided (and most TS code that exists) works in EAs.
There are 2 ways to see the TS works - Red SL line on a chart, corresponding to TS level will be moving once your trade made profit of TS value and the Terminal 'S/L' value will be changing as well. EA will show a 'smiling face' icon in the right top corner of the chart.
There are many variations and options of TS code.
In general, scripts are meant to be used for a one-off execution, while TS needs to be reviewed on every tick.
I find the method explained by newdigital above awkward to use, but that is MQ4 limitation.