Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
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.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 07-11-2006, 02:29 AM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
Trailing stop initiation...

I notice that when trailing stops initiate it seems that they only increase when the price moves above the OrderOpenPrice()

I would like to get a trailing stop to start trailing from the current price regardless of where that is in relation to the OpenOrderPrice()

am I misinterpreting where it initiates?

Last edited by Aaragorn; 07-11-2006 at 02:32 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 07-11-2006, 04:39 AM
Senior Member
 
Join Date: Mar 2006
Posts: 793
Maji is on a distinguished road
Look for something similar to the following statement:
profit=NormalizeDouble((Bid-OrderOpenPrice())/Point,0);
if(profit<start)
continue;
basically, when the profit is higher than the start (an amount designated by you) the trailing stop starts. You can take the If... continue statement out and see what it does. Experiment with it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 07-11-2006, 02:09 PM
fxtraderguru's Avatar
Junior Member
 
Join Date: Jun 2006
Location: Virginia
Posts: 5
fxtraderguru is on a distinguished road
Trailing Stop

Are you asking about trailing stops with MT4? If so, the trailing stop feature only works when:

a) it's at XX plus 1
b) your computer is on or the trading platform is loaded on a server
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 07-11-2006, 04:45 PM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
Quote:
Originally Posted by Maji
Look for something similar to the following statement:
profit=NormalizeDouble((Bid-OrderOpenPrice())/Point,0);
if(profit<start)
continue;
basically, when the profit is higher than the start (an amount designated by you) the trailing stop starts. You can take the If... continue statement out and see what it does. Experiment with it.
you know your really are a genius and like most geniuses you leave just enough gaps in your suggestions to the common folk to leave us puzzling...

So the puzzlement is first...where do I look for this statement? the only place I see the profit variable is in this plain vanilla CloseOrder() that you made before...which I think I almost understand now btw. I wouldn't mind seeing a version of that function used to turn the trailing stop on or to tighten it in steps at specified times.

but getting back to this...the second puzzlement is the 'start' specifed...that would just be the current price level when the thing triggers. or would it? hum...

i like the idea of tightening the trailing near the lower tolerance extreme and letting it trail wider if it's away from the tolerance edge.

what function calls the current price? is that just point()? maybe something with the orderprofit()???hum

Last edited by Aaragorn; 07-11-2006 at 04:57 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 07-11-2006, 05:10 PM
Member
 
Join Date: Mar 2006
Posts: 49
pipeline is on a distinguished road
Quote:
Originally Posted by Aaragorn
what function calls the current price? is that just point()?
"Bid" and "Ask" give the current price. (By default, MT4 shows the Bid price on the chart).

"Point" (not "point()") is the value of 1 pip of a currency pair. For GBPUSD, Point=0.0001, for USDJPY it is 0.01 etc.
So if you want to do something, say, 50 pips below My_Price, you test:
if( Bid < MyPrice - 50*Point ) {...}

PS: price isn t updated within the start() function. if the start function takes a long time to implement (or if an OderSend failed due to requotes), at some point you may want to refresh the price by using the RefreshRates() function.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 07-11-2006, 06:55 PM
Senior Member
 
Join Date: Mar 2006
Posts: 793
Maji is on a distinguished road
Quote:
Originally Posted by Aaragorn
you know your really are a genius and like most geniuses you leave just enough gaps in your suggestions to the common folk to leave us puzzling...

So the puzzlement is first...where do I look for this statement? the only place I see the profit variable is in this plain vanilla CloseOrder() that you made before...which I think I almost understand now btw. I wouldn't mind seeing a version of that function used to turn the trailing stop on or to tighten it in steps at specified times.

but getting back to this...the second puzzlement is the 'start' specifed...that would just be the current price level when the thing triggers. or would it? hum...

i like the idea of tightening the trailing near the lower tolerance extreme and letting it trail wider if it's away from the tolerance edge.

what function calls the current price? is that just point()? maybe something with the orderprofit()???hum
I am not a genius by any stretch of imagination. I can as well modify a trailingstop routine and give it to you, but then you won't learn. My intention all along is to force you to learn. That is the way I learnt and that is the way I want to help others... really help themselves Remember the saying about giving a fish and showing how to fish?

You should check the code, not closeall, but your code where the trailingstop method is implemented. Study it and it will scream back to you on how to modify it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 07-11-2006, 07:58 PM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
Quote:
Originally Posted by Maji
I am not a genius by any stretch of imagination. I can as well modify a trailingstop routine and give it to you, but then you won't learn. My intention all along is to force you to learn. That is the way I learnt and that is the way I want to help others... really help themselves Remember the saying about giving a fish and showing how to fish?

You should check the code, not closeall, but your code where the trailingstop method is implemented. Study it and it will scream back to you on how to modify it.
Ok, you are a modest genius who likes to teach. Granted. The only thing I call into question in your methods is the assertion that I don't learn from you doing it. I will conceed that perhaps I might not learn on the same curve as if I am 'forced' to slog it out myself, but I maintain that I learn both ways. If I were of a mind to not apply any effort myself and totally not pay any attention I would agree but that is not the case.

Since your choice in how to teach is your option and not mine, I shall look for screaming code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 07-11-2006, 08:36 PM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
here is what I understand of the code...
PHP Code:
//Trailing stop
            
if(TrailingStopMode && TrailingStop 0) { 
trailing stop mode is the bool variable which if true = 1 would satisfy the condition alone being greater than zero && (odd use of &&?) trailing stop is whatever external user value defined. so this line asks if the trailing stop is being used or not basically as determined by >0. I assume that if this condion returns false that it proceed to the 'else' and moves on...

no screaming so far...next
PHP Code:
if(Bid OrderOpenPrice() > Point TrailingStop) { 
if the Bid (which is the current price to close a long position) minus the order open price...(which would scream 'profit' to me assuming the position is profitable) is > normalized trailing stop value.

so now we know the trailing stop is being used and that the price is currently higher than the trailing stop value to get an affirmative from this condition. I assume that if this condion returns false that it proceed to the 'else' and moves on...
next line..

PHP Code:
if(OrderStopLoss() < Bid Point TrailingStop) { 
if Orderstoploss() ok that's a new one...returns the value of the open order stop loss...< current price to close a long position - normalized external user defined trailing stop value. This says to me that it should close if this returns true. I assume that if this condion returns false that it proceed to the 'else' and moves on...I admit it this one confuses me. ok I get it...if the current stop loss value is less than what the current stop loss value shoud be now...

next
PHP Code:
OrderModify(OrderTicket(), OrderOpenPrice(), Bid Point TrailingStopOrderTakeProfit(), 0MediumSeaGreen); 
modifies the order to the current price to close a long position - the normalized trailing stop value...in other word the new stop loss level.


so I see one screamer there...you were right it did scream...

sooooo
PHP Code:
if(Bid OrderOpenPrice() < OrderOpenPrice Point trigger1
TrailingStop=T1; { 
should be saying

if the current value of the long position is less than the normalized user defined trigger value....assign trailing stop this value

that should get it assigned at the trigger level...now to get the modification done and the code in the right place with the rest....

so, the lines say..
1- if we are using the trailing stop...
2- if the position's current value is higher than the trailing stop now...
3- if the current stop loss is less than the trailing stop parameter setting...
4- modify the order to the present level trailing setting.

well I definitely see that line two is where change is needed...

what i did so far assigns the trailing stop a new value that I can define at a certain level...

but what happens to the logic of the sequence when I do that...

so, IF the lines say..
1- if we are using the trailing stop...
2- if the position's current value is less than I will allow it to be without a trailing stop.../*higher than the trailing stop now*/...give the trailing stop this value...
3- if the current stop loss is less than the trailing stop parameter setting...
4- modify the order to the present level trailing setting.

see there's a problem with this..
2- if the position's current value is less than I will allow it to be without a trailing stop.../*higher than the trailing stop now*/...give the trailing stop this value...


that will trigger it the first time but that will not continue to trail once the price rises above me set level......will it??
what happens the second time it askes 'is the current value < I will allow it to be without a trailingstop? ...and it says NO! and proceeds to the else clause...

oy

I don't want to destroy the functionality of the trailing I just want to control where it engages in relation to the openorderprice() and how tightly it engages in stepping levels in relation to the openorderprice()...

I've got to think this thru so more...how do I put this in the loop without destroying the loop?

Last edited by Aaragorn; 07-11-2006 at 09:38 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #9 (permalink)  
Old 07-11-2006, 09:36 PM
Senior Member
 
Join Date: Mar 2006
Posts: 793
Maji is on a distinguished road
First, what is the function of a trailing stop?

Second, what is the difference between a trailing stop and the initial stop loss?

Third, when does a trailing stop kick in?

See if you can figure these yourself. After you are done with that, then see how the program logic handles these three items. I see that you are forcing yourself to learn, and that is clearing things up in your own mind. Of course, there will be some confusion, but it will gradually clear up as you understand the functioning of the trailing stop system better.

Sorry for my brusque replies.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #10 (permalink)  
Old 07-11-2006, 09:47 PM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
Quote:
Originally Posted by Maji
First, what is the function of a trailing stop?

Second, what is the difference between a trailing stop and the initial stop loss?

Third, when does a trailing stop kick in?

See if you can figure these yourself. After you are done with that, then see how the program logic handles these three items. I see that you are forcing yourself to learn, and that is clearing things up in your own mind. Of course, there will be some confusion, but it will gradually clear up as you understand the functioning of the trailing stop system better.

Sorry for my brusque replies.
apology easily and happily accepted. I appreciate your apologizing. Really thankyou! If your brusque perhaps I am sometimes overly intent. Stay with me on this ok? I know I'm not always the best at explaining.
The function of a trailing stop is to establish a moving stop loss in tow with the increasing profitability of the position...

the difference between a trailing stop and an initial stop loss is that the trailing stop loss moves in response to the price movement keeping a specific distance from the current price whereas the initial stop loss is simply a fixed point below the openorderprice.

When does the trailing stop kick in? well that's my whole point here. based on the traditional trailing stop function it kicks in when the price is enough greater than the openorderprice to warrant changing the initial setting...

what I'm saying is that I want the thing to kick in WHEN I WANT IT TO.

It's initial setting keeps it to that range but I want it to end with a different range setting than it starts with. I also want it to start below what it's typical initial setting would be...I have see trailing stops modified to get smaller as time goes on but I want the reverse of that.

it's a little unconventional what I'm thinking of and I don't know how to do it. But I want to be able to trigger it off the price action rather than from a static initial level....the backcross of two moving averages isn't something I can exactly say is going to be this many pips below the open order price, it is whereever it is. once it triggers I don't want to allow it as much room to trail when it's at that extreme but as it goes more profitable I want to allow it a little more wiggle room. I don't know if I'm explaining this very well...

see the thing is that when I see the backcross of two moving averages I want to basically pull the last ditch effort to save the position. I want this to be the place at which the stop loss engages and says this is the most I will allow this trade to go bad....BUT...I want to salvage as much as possible of the trade at this point so I want it to trail not just sit there static on the outer limit.

Last edited by Aaragorn; 07-12-2006 at 12:51 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trailing Stop EA newdigital Expert Advisors - Metatrader 4 68 11-01-2009 09:32 AM
How to set a trailing stop??? theolive9 Metatrader 4 1 12-06-2006 12:12 AM
EA trailing stop JoZo Metatrader 4 6 11-10-2006 02:34 PM


All times are GMT. The time now is 05:28 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.