- Search Metals Mine
-
Kefada replied Jan 10, 2022Pending Order Placement Function To place pending orders, we'll need to pass parameters for the pending order price as well as the order expiration time. The PendingPrice and Expiration arguments will be added to the function. We'll assume that the ...
Random Useful MQL4 Functions
-
Kefada replied Jan 10, 2022Order Placement Function We are specifying the order symbol using the Symbol argument, instead of simply using the current chart symbol. This way, if you decide to place an order on another symbol, you can do so easily. Instead of using the ...
Random Useful MQL4 Functions
-
Kefada replied Jan 10, 2022Lot Size Verification Function The LotSize variable is from the above function double VerifyLotSize(double LotSize) { if(LotSize < MarketInfo(Symbol(),MODE_MINLOT)) { LotSize = MarketInfo(Symbol(),MODE_MINLOT); } else if(LotSize > ...
Random Useful MQL4 Functions
-
Kefada replied Jan 9, 2022Lot Sizing Function Note that DynamicLotSize, EquityPercent, FixedLotSize and StopLoss are external variables double CalcLotSize(bool DynamicLotSize, double EquityPercent, double StopLoss, double FixedLotSize) { if(DynamicLotSize == true) { double ...
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022These are simply the most common methods of determining a stop loss or take profit price. Other methods can be developed using your knowledge of technical analysis or your imagination.
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022An example using an indicator. Let's say we have a moving average, and we want to use the moving average line as our stop loss. We'll use the variable MA to represent the moving average value for the current bar. All you need to do is assign the ...
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022If you wanted to calculate a stop loss for a sell order using this method, the iHighest() function works the same way. Referencing the example above, you would use MODE_HIGH for your series array parameter.
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022Suppose your system requires you to place your stop loss at the lowest low of the last x number of bars. There's a function built into MetaTrader just for that: iLowest() returns the shift value indicating the bar with the lowest value in a ...
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022Lets say that we are using a system that places the SL 2 pips below the low of the current bar. We shall use the predefined price array Low[] to retrieve the low of the bar. Low[0] is the low of the current bar Low[1] is the low of the previous bar ...
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022Alternative Stop Loss methods In the above methods, SL is set using a predefined amount of points/pips. But there are other methods of placing SL e.g A previous high or Low, or an indicator value. Lets see how we can code this in the next posts
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022Calculating Take Profit Calculating the tp price is similar to calculating sl, except we'll be reversing addition and subtraction. For a buy order, the tp price will be above the order opening price, and for a sell order, the tp price will be below ...
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022For pending orders, the stop loss will be calculated relative to the pending order price. In this case, use the variable OpenPrice to store the pending order price instead of the current market price. The logic will be identical to the examples ...
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022Here's our buy order stop loss calculation from, with the UsePoint (refer #post5 )variable added. Note that we've assigned the Ask price to the OpenPrice variable: double OpenPrice = Ask; if(StopLoss > 0) double BuyStopLoss = OpenPrice – (StopLoss * ...
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022No, using Symbol() you can create just one EA or Indicator / script for every pair...the issue comes up if your EA is trying to open a trade for a currency other than the one for the window it is attached to. NB: These are just small simple code ...
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022Since these values will never change during program execution(values in the 2 previously posted codes), we'll calculate these values in the init() function. We'll assume that the external integer variable for Slippage and points is already present: ...
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022Similar to the Above Code but converts slippage points. Also assumes there is an external variable for slippage int GetSlippage(string Currency, int SlippagePips) { int CalcDigits = MarketInfo(Currency,MODE_DIGITS); if(CalcDigits == 2 || CalcDigits ...
Random Useful MQL4 Functions
-
Kefada replied Jan 7, 2022Code for converting Points to Pips irrespective of what type of quotes the broker uses(Digits after decimal) and also what Currency you are using(The typical diff btn JPY quotes and USD quotes). Useful when using OrderSend() to avoid errors if a ...
Random Useful MQL4 Functions
-
Random Useful MQL4 Functions
Started Jan 7, 2022|Platform Tech|36 replies
This thread is for posting useful user defined MQL4 functions, operators and also code blocks ...