Forum

Simple way to avoid repetitive code?

Hi Everyone What is the simplest way to set variables in order to avoid the repetitiveness, please? (total means OrdersTotal) if (total== 1 && Bid-PriceS>HT){ ticket= OrderSend ( Symbol (),OP_SELL,Lots* 2 ,Bid, 5 , 0 ,TPS, "Original" , 0 , 0 ,Red); } if (total== 2 && Bid-PriceS>HT* 2 ){

How to code a dynamic trailingstop that decrements as profit rise?

Hi guys Most of the EA's that I've seen operate on a fixed pip trailingstop. For every pip the price go in your trade's direction, it adjusts the trailing stop by 1 pip. So, if your trailing stop gets triggered at say 10 pips and the stoploss trails behind by 200 pips, then you will basically break

Sell trailingstop doesn't work

Hi Everyone I'm brand new to MQL5. I've managed to migrate all my code from MQL4 and it seems to be fine, but as for my trailingstops, the buy TS works fine, but the sell TS doesn't work at all. Will someone please have a look at my code and let me know if there seems to be an obvious problem. Thank

How to increment lot size when Equity drops

Hi Everyone I'm stuck. I'm trying to write a simple EA that would increase the lot size incrementally by 1 microlot every time that the equity drops incrementally by $200. So if my starting equity is $1000 and it drops to $800, the lot size of the next trade should go from 0.01 to 0.02. Then if the

Best way to modify lot size of pending orders

Hi Guys Since there is no built in function to modify lot size of pending orders, I suppose the only way to do it is to delete the current pending orders and resend them with the increased lot size. I am storing the BUYSTOP and SELLSTOP price of the original order as a variable so that the same

How can I determine highest equity for last 10 candles?

Hi Ladies and gents I would like to set the highest equity for the last 10 candles. I was thinking that I can perhaps use Bars() or Time[] or TimeCurrent() to do this, but I do not know how. How can I get the EA to store the highest Equity and let the highest equity (if applicable) on the 10th

One function contingent to another condition

Hi, please help. What is the simplest and easiest way to call a function contingent to a once off trigger/ condition? For example say that the price hits a certain target and I want to call a function based on this trigger. What I have so far: void Trailing(){ //Some variables, For loop and

Change of direction code

Hi Everyone I'm trying to figure out how to code a direction in price. Lets say the price is rising, but then changes direction and I want to include both the initial rise and then the decrease. I think it would look something like this, but I cannot get it to work properly: void Stoploss(){ //For

Possible to have a trailing stop loss on losing trades?

Hi I have a trailing stop on my winning trades that works very well. Is it possible to have a similar trailing stop on losing trades rather than a hard stop loss . Can the stop loss be adjusted/ decreased as the price moves in my favor? Here is the code for my trailing stop loss on winning trades

How to place multiple trades X pips apart

Hi guys I'm struggling and hope that someone can please point me in the right direction. Once a trade is open, I would like to open another buy trade if the price moves 10 pips up or another sell trade once the price hits 10 pips below the OpenOrderPrice. For some reason my code isn't working. It