Problem with check last closed trade profit code
-
Hi there,
Getting code error for check last closed trade profit. I have attached a screen shot of mt4 (build 625).I was wondering if you could look into my project and see if I am doing anything wrong here?? please? Any help would be greatly appreciated


......
mt4 screenshot.jpg -
I checked this block, it looks fine. What do you have in it's parameters, and are you sure the problems comes from it? The problem is that somewhere something is not closed, missing ) or } probably, which leads to multiple error messages.
-
Sorry I should have explained myself better. I want to close a loser trade with 50pips or greater and put a opposite (buy/sell) of the closed trade. and put a trailing stop for only the trades that are stopped out at 50 or greater. can this be done? I tried to number the group of trades as 1 to specify but I might not understand group correctly.
-
ofcourse the trailing stop is going to be for the opposite trade/order after the 50pip loss trade.
-
I see code error here, this is not a logical error. Something is wrong in the output code, some ) or } (or other MQL4 part) is missing somewhere. Can you tell me which block causes this to happen? Also what if you use the same block, but as a new one (with all default parameters)?
-
The block is 'check last closed trade profit'. I tried using a new block and it gives the same error.
-
Well, I tested it (build 080) and I have no problems with it. Can you upload .mq4 file here? It can contain only this block and some other, there is no need to be a whole strategy.
-
sure. here it is. no changes made.. nothing special about this ea anyways lol hopefully the problem can be resolved. thank you.
......
nonlagma (91).mq4 -
It looks that this parameter http://prntscr.com/3e71yj is not ready to be used as an input parameter. Because it's not a value, it's a sign (< or > or == or something else) that is used directly in the code. Just uncheck it.
-
thank you very much. I will try it out. and also is there a way to group trades? For example Group#1 will have certain criteria and Group#2 will have certain criteria...like different trailing loss and stops depending on which group they belong to?
-
I choosed to group trades and orders using their magic number. There are no many options actually, the only parameters we can use for something like this are Magic Number and Comment, but the Comment should be available for the user so what remains is the Magic Number.
So yes, that Group number is connected in some way with the Magic Number and you can create trades with certain Group number and then use trailing stop set to trail only those trades with that Group number. Here is a little bit more about this topic, I hope you will understand it: https://fxdreema.com/documentation/proj ... d%20groups
-
ok so as i understand it... I will basically put a number in group# lets say 1 for buy/sell and then put the same number for different blocks with the same number for example the close trades group# will be 1 as well for that buy/sell trade. is that right?

......
screenshot1.jpg -
Yes
-
thankyou for all your hard work
and also I have seen that with some brokers the EA's do not work properly and on others they work perfectly fine. why is that? -
Well, by "Does not work properly" I understand that the problem can be everything. Define "Does not work properly"?
-
Well for instance one of the EA's was working fine for me for Oanda and Tenkofx. Proper execution of the all the trades and whatever logic or strategy is working. but then the other day I downloaded Octafx mt4 and on that it was putting way too many sells and buys and not working according to the logic or strategy but it was completely fine for the other two brokers.
-
I am guessing the problem here is not the EA itself but a problem with the broker platform.
-
Too many buys and sells sounds to me like logic issue. If we take the EA from the picture above, it depends on what timeframe it is added, and the result will be as many trades as many bars are created. Well, if the timeframe parameter in "Once per bar" blocks are set to "Current".
So, this EA creates new trades based on time. It does not care id there are some at the moment, it just works from time to time. This is not wrong normally, but if you don't want to do it that way and it is that way - then it's wrong. -
well no it's no for the EA above in the picture. That works completely fine on all brokers. It is when i try to put the blue blocks and then put buy and sell...those trades are executed every tick. Like so..

The logic is very simple. For example if the last closed trade was a buy with a loss of more than a certain pips amount then an opposite trade is executed. But when that trade is executed it is every tick. I tried to put the block 'No trade is running' and 'For each trade' but same result. even tried to put it on trade event still not working. But like i said...only for one broker it is behaving like this..for the other two it works fine.
......
screenshot2.jpg