automatic stop placement

 

I would like to have a fixed stop order opened whenever I take a position.

For example, if I buy at "x", a stop order would automatically be generated at "x-y".

"x" is the entry price.

"y" is the number of pips I am prepared to risk on each trade.

If I sell at "x", a stop order would automatically be generated at "x+y".

Does this function already exist, or is there a script that I could import that would execute this function?

 

See OrderSend() or OrderModify()

Input the values you want.

If your trade is manual, scan open positions in code, and if the stoploss is 0, send OrderModify() to set stop.

 
phy wrote >>

See OrderSend() or OrderModify()

Input the values you want.

Are you indicating manual stop entry?

 
breman wrote >>

Are you indicating manual stop entry?

Phy,

Sorry, I only saw one line of your response and misunderstood your comment.

I had a look at OrderSend(), I am quite new to coding and I am afraid I will require your patience.

Thank you for your response.

I trade manually with tight stops. Sometimes I do not have time to modify the order with the appropriate stop and I would like to run a script that would execute the same stop calculation and execution each time I place an order. Is this what the OrderSend() does?

 

A script (or preferably, an EA) can run, continually monitoring all your open trades, and set initial stops or modify existing stops as you require.

 

Excellent.

Now please bear with me, this might be painful for you.

Is OrderSend() a script I need to import, or is it a function that already exists in the platform?

If I need to import, how do I do that?

 

OrderSend() and OrderModfy() are commands that would be a part of your Expert.

Some programming skills are required.

 

Ah yes, there is the problem.

I was hoping someone had already created such a program and I could just drop it into my files.

I am currently not able to write my own programs. However, I am interested in learning the programming language.

Do you have any recommendations for me?

 

In your MT4 is a sample script named close.mq4

View -- Navigator -- Scripts --

There is a script named "close"

right-click it, and select Modify.

The editor opens the source code for that script.

You are now in the development environment for MT4, which includes the language reference.

 

I opened the script.

It looks very nice. I don't have a clue what to do with it.

How would this script be applied?

 

I am currently not able to write my own programs. However, I am interested in learning the programming language.

Do you have any recommendations for me?

Well, that's how you get started...

Reason: