Trailing means that the stop has a maximum distance from current price.
If you have 20 pips trailing stop (SL) in a buy trade, and the price goes upward, the stop also goes upward 20 pips behind current price. If the price then goes down, the stop doesn't move anywhere and the SL can trigger.
Posts made by roar
-
RE: trailing stop/trailing profitposted in Questions & Answers
-
RE: CROSS ABOVE CROSS BELOWposted in Questions & Answers
just leave the width to 1.
https://fxdreema.com/shared/HiuKscOsd
^This closes your trades when price crosses 20 MAYou can make a shared copy of your project from Projects menu at top left
-
RE: Trailing Stop (for group of trades)posted in Questions & Answers
You would have to assign different weight on each trade - if you have 1.00 lot buy at price 1.000 and 0.01 lot buy at price 2.000, the midpoint is not price 1.500 but close to 1.000..
There could be a way to calculate this, with a million variables, but its not very simple
Well, MT5 does this automatically, everytime...
-
RE: Total profit reduces by x % then close everything.posted in Questions & Answers
Yeah, the core principle seems to be working, now its just about improving the ea as whole

-
RE: Total profit reduces by x % then close everything.posted in Questions & Answers
Hehe, 19000 trades - the spread costs could be pain in the ass in live trading

-
RE: Total profit reduces by x % then close everything.posted in Questions & Answers
Hmm, yeah, could work

If you just want to delay the ea after something happens, this is what I usually do:
- create variable barcount
- on each bar, modify variable barcount to barcount +1 , so the variable just increases every bar
then, if you want to wait 3 bars after opening a trade: - reset the barcount at buy or sell,
- put a condition: barcount > 3
-
RE: Total profit reduces by x % then close everything.posted in Questions & Answers
All right

There is certainly a way to make the ea as you said, excluding the losses from new positions. But I'm afraid it won't be very simple or elegant solution.You would need a variable for the modified profit.
Then find out how much loss a new trade causes, this could be done with some more variables, one variable should show the profit a few candles ago, so when a trade happens, the loss could be calculated. The loss would then be subtracted from the "modified profit" variable.
Then there should be another variable that keeps track of the losses caused by opening trades, a "loss bank" variable. That "loss bank" could then be slowly drained to the "modified profit", so the losses would be taken into account after some time, and "modified profit" would get closer to the real profit.Anyway, thats how I would do it, but I'm not sure if its worth the trouble

-
RE: Total profit reduces by x % then close everything.posted in Questions & Answers
So you want to exclude the new positions from the profit calculation?
I would go with the 30-min condition, why not?
Or set the ratio lower, 0.8 for example? -
RE: CONDITION for close trades.posted in Questions & Answers
The ea runs every tree, on every tick.
If you are using mt4, you can have both buy and sell trades open.
If you don't want that, use a "no trade is running" block, for example.In the close trades -block, you can filter the trade type, so it closes only buys, for example.
If you want to show exactly what you are doing, create a shared copy from the Projects-menu (top left).
-
RE: CONDITION for close trades.posted in Questions & Answers
CONDITION --> BUY--> CONDITION -- CLOSE TRADES
This would not be very great, because it always closes a new trade, because the closing can't happen without buying...
Just separate the "logic trees":
Condition -> buy
Another condition -> close -
RE: CLOSE BAR HELP!posted in Bug Reports
I'm not sure if the link works - did you mean this project?

-
RE: Trailing Stop (for group of trades)posted in Questions & Answers
Hmm.. If your trades have different lot sizes, measuring the total profit as pips becomes difficult.
Maybe just close the trades based on account equity, or account profit?This could help you:
https://fxdreema.com/forum/topic/4858/total-profit-reduces-by-x-then-close-everything/2?page=1 -
RE: CLOSE BAR HELP!posted in Bug Reports
Did you do it like this:
https://fxdreema.com/shared/1WVco5iZ -
RE: Total profit reduces by x % then close everything.posted in Questions & Answers
I think the trade statistics always looks at the whole history, so you wouldn't be able to focus on some x number of history positions
-
RE: Total profit reduces by x % then close everything.posted in Questions & Answers
I just realized the above is partial bullshit. Multiplying the profits doesnt work because we check it against average value. But its a start, at least
Dividing the currentprofit should work
-
RE: Total profit reduces by x % then close everything.posted in Questions & Answers
@timmyhanke
So the question is, how to get the loss values from history positions.I would store the current profit, to some variable currentprofit
Because you compare many trades to one trade, you need to multiply the currentprofit with the number of last trades before continuing - just use a formula. In the formula I would also multiply it with *-1, so it can be compared to a loss.
Then use the "check profit (average)" block, set to look at x number (number_of_positions) of history positions, and compare the average last profit to the currentprofit
https://fxdreema.com/shared/D382vaNlc
This is just a fast mockup, how I would do it, perhaps there is a better way. To be honest, I haven't used anything like this, because I try to avoid making decisions based on profits and losses, and rather focus on actual price data.
-
RE: Total profit reduces by x % then close everything.posted in Questions & Answers
Yeah, that would work

-
RE: Give my variables eternal lifeposted in Questions & Answers
Yeah, I went with the global variables, but it feels a bit clumsy solution, and makes a really weird interference in my backtest.
The file approach would be better, I guess its time to learn some actual MQL coding
-
RE: Total profit reduces by x % then close everything.posted in Questions & Answers
^This is exactly why I like to help

If you need further help, I'm usually bored enough to assist

-
RE: Total profit reduces by x % then close everything.posted in Questions & Answers
I downloaded your .ex4 and added 111 pips SL, heres what I got:
