Forum

myposition.Stoploss() not giving new modified SL level

Hi guys, I'm still having problem with my trailing stops. The stoploss level is supposed to be changed only if the price minus the trailing stop point is greater than the existing stoploss point. But in my program, the stop loss is being adjusted as I can see it in the visual tester . The problem

Trailing Stop Error: Invalid Stops

Hi guys, I've been having this error the entire day while trying to figure out a way to place trailing stops to my positions. I'm getting an " invalid stops " error. I've read through some of the previous posts about the invalid stops but nothing seems to work. Appreciate if anyone can kindly look

How to implement a trailing stop

Hi guys, I've been using this tutorial as a template for my EAs because it's easy to read and add indicators and conditions to it: https://www.mql5.com/en/articles/100 But unfortunately, I couldn't add a trailing stop functionality to this code. I've tried to copy some code from other tutorials

How to get Position opening time?

Hi guys, I'm just wondering if there is a function to get the position opening time here in MQL5? I've read the various trade functions and the data structures but can't seem to locate this function. I'm intending to close a position based on a fixed time after being opened if the takeprofit and

EA to trade only on certain time periods

Hi guys, I want to make an EA only trade in certain time ranges? I can't seem to locate any tutorial on timers in the article section. I'm also confused regarding the time here in MQL5, what time does all our platforms follow? our individual local time, or is there a universal time being used

Backtesting Strategies in Alpari MT5

I've been encountering problems with backtesting in the metatrader 5 platform specifically entering Stoploss and take profit levels similar to the problems raised by some members before: https://www.mql5.com/en/forum/7012 I'm currently using Alpari's MT5 platform and couldn't backtest properly, some

WEIRD: Strategy Tester Results don't change even if parameters were changed

Hi guys, I've been exploring the strategy tester and playing with some EAs in the article and code base sections. When I backtest an EA for the first time and change the parameters for the second backtesting (e.g. stoploss,takeprofit,etc) the outcome does not change. Here's the screenshot of the

Different moving average value...

Hi guys, I've made a simple code to buy when the price is above the moving average and sell is the price is below the moving average everytime that there is no position open. I checked the backtest and saw that the code is not performing as I wanted and only performs buy trades. I printed the

Easier way to know if last trade was profitable...

Hi guys, I was thinking of using the profit or loss of the last trade as one of the conditions for buy and sell signals. I found out a way to get the profit/loss by using this function: AccountInfoDouble ( ACCOUNT_BALANCE ) and storing it in an array with 2 locations, one to store the past account

Unexpected token error

//+------------------------------------------------------------------+ //| MAENA.mq5 | //| Copyright 2010, MetaQuotes Software Corp. | //| http://www.mql5.com |