MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal

Source code library - Expert Advisors, Indicators and Scripts

Mercury FreeMercury Free Try product
Mercury Free
Author: nasdaq
Screenshot
EURUSD, H4
Real
Arrows&Curves Indicator
Arrows&Curves
Author: GODZILLA
The Use of the MQL5 Standard Trade Class libraries in writing an Expert Advisor The Use of the MQL5 Standard Trade Class libraries in... Subscribe to signal
Akderli1
44.22%, 133 765.82 USD
To post a new code, please log in or register

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2012.09.10 16:32
OpenSellPosition

OpenSellPosition [ru]

GODZILLA

Downloads:
695
Views:
1831
Rating:
votes: 8
Files:

Description:

OpenBuyPosition script is developed for buying with fixed Stop Loss and Take Profit values in points from the current price. The main advantage of this script is its ability to fix a deal volume, which depends on the entire deposit size, using MM (Money Management) script input parameter. This script determines a ratio between the amount of funds involved in the deal and all the funds of the deposit.


The script input parameters:

//+----------------------------------------------+
//| SCRIPT INPUT PARAMETERS                      |
//+----------------------------------------------+
input double  MM=0.1;       // Money Management
input int  DEVIATION=10;    // Price deviation
input int  STOPLOSS=300;    // Stop Loss in points from the current price
input int  TAKEPROFIT=800;  // Take Profit in points from the current price
input uint RTOTAL=4;        // Number of repeats in case of unsuccessful deals
input uint SLEEPTIME=1;     // Pause duration between repeats in seconds

Translated from Russian by MetaQuotes Software Corp.
Original code: http://www.mql5.com/ru/code/964

Last comments | Go to discussion (7)
onewithzachy
onewithzachy | 11 Sep 2012 at 01:52
nonor:

Hello

Could you also make a "closeall" script wich will close all open positions ?

Thank yu

Hi nonor,

If you want to close a sell position, the you should open a buy position with the same lot and vice versa. 

Do this : on your MetaTrader 5, open sell some symbol - say 1 lot of EURUSD. To close it, open buy 1 lot of EURUSD..

 

nonor
nonor | 11 Sep 2012 at 07:42
onewithzachy:

Hi nonor,

If you want to close a sell position, the you should open a buy position with the same lot and vice versa. 

Do this : on your MetaTrader 5, open sell some symbol - say 1 lot of EURUSD. To close it, open buy 1 lot of EURUSD..

 

yes, but in mt4, I have a script wich I call by keys, Alt+c, and then positions are closed, it a kind of emergency close...
onewithzachy
onewithzachy | 11 Sep 2012 at 07:49
nonor:
yes, but in mt4, I have a script wich I call by keys, Alt+c, and then positions are closed, it a kind of emergency close...

Hi nonor,

Yep, I also have that in MT4 :D. However, MT4 is ticket based trading while MT5 is position base trading. I think close all can be applied in MT5 too, it just like I said before that's the way to close any open position in MT5 :(.

 


noonehastherighttojudgeanother
serpentsnoir | 12 Sep 2012 at 03:38
lion999:

hi Nikolay

Was looking for a scrip like this great idea...tried using the scrip by attaching it to the chart but it immediately gets removed automatically fom the chart .

what do you think could be the problem 

 

It didn't work for me so I got the debugger to find out that on my broker this was not working.  See the line I commented out?  Try that. Extrem_Stop was always coming back zero - could be a bug.
bool StopCorrect(string symbol,int &Stop)
  {
//----
   int Extrem_Stop=int(SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL));
   //if(!Extrem_Stop) return(false);
   if(Stop<Extrem_Stop) Stop=Extrem_Stop;
//----
   return(true);
  }
gianca
gianca | 18 Jan 2013 at 14:48

The orders are placed, but no StropLoss and Takeprofit are set.  I tryed to check the code, failing.

What's wrong in the code for not setting those parameters ?

thanks