dDelta = OrderOpenPrice () - OrderClosePrice ()
These functions can not be used until you orderSelectfor(pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() ){ // and my pair.
if ( iTime_0 < iTime ( 0 , 0 , 0 ) )
You want != for several reasons.
double dAsk = MarketInfo ( Symbol () , MODE_ASK ) ; //< > double dBid = MarketInfo ( Symbol () , MODE_BID ) ;
Why not use the simple functions Time[0], Ask, Bid- Why don't you simply set a TP, and SL and be done. If you loose connection, the EA won't be able to close the trade and there goes your account.
return ( TRUE ) ; //< > return ( EMPTY ) ;
EMPTY is not a bool, use FALSE
Hello WHRoeder,
Sorry for the incomplete message. I was interrupted. The complete code does work but it is not at my dispolsal while I am at my regular 9 to 5 job. The few items that you DID mention, I will look into and correct.
Thank you. Big time. : D
But the real question or problem that I had in mind, is when this code is optimized. So as I am understanding how I have setup this code, though it is not perfect, the dTP and dSL are 'double' not 'int'? Yes/No. I do have them listed as 'double'. Within the code, their purpose ( dTP and dSL) are used as multipliers with the value of dATR. When I check the results against the entry and the exit of any trade, the results come out OK. Profits (dTP) are the value of 1*dATR, and all losses (dSL) have the value of 2*dATR. All is good. The problem is when I check the results after the code has been optimized. E.g. iPrior = 34, dTP = 1.8, and dSL =1.1. ( I bring this example out from memory.) I will post the result and dATR values after work tonight. The problem with the results show the loss values are much more than a 1.1*dATR.
Again sorry for the incomplete message. Results will be posted along with the dATR values for both dTP=1, dSL=2. (The results that I agree should look like.) and I will post the results with the suspect values.
Thank you for your prompt reply and info.
Regards Huckleberry
Hello WHRoeder
The problem is gone. Thank you for your help.
And I understand your other suggestion and will take heed. The structure of the EA has a trailing stop built into it. And if the EA is run as such, I can see how this would delete an account when the system is turned off and restarted on a daily basis. A set TP and SL is best if run as a robot.
Onto another suggestion,------return ( FALSE vs EMPTY vs TRUE vs 0) ; ------This has been brought up before in constructive conversation. This code must be unorthodox to the max. When ever I insert ( FALSE, false, TRUE, true, 0, or is left blank), the code does not perform. I truely do not know how to explain it. The code works fine in this form, but everyone has had the opinion that using the EMPTY, will not work. I will send it to you (the code) and you can backtest it for yourself. Maybe you can make sense of it. I have puzzled over this for 8 or 9 months. Yes this is my idea for a code, but the structure was built by another programmer. This programmer can not be reached. I have great respect for him. He was always there. But for nearly three months, I have not heard from him.
Regards
Huckleberry
- RaptorUK:nope SetIndexStyle() ObjectDeleteAll() others
Is EMPTY a hangover from MQL2 ? - Huckleberry:EMPTY = -1
ever I insert ( FALSE, false, TRUE, true, 0, or is left blank), the code does not perform.Boolean constants may have the value of true or false, numeric representation of them is 1 or 0 respectively. We canSo when you return(EMPTY) you are returning TRUE. Figure out why when you return false the code doesn't work correctly.
also use synonyms True and TRUE, False and FALSE.
That is interesting info. I will insert a -1 to see what happens. And get back. Thanks again. Really.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello to All,
Here I am with a code that works fine, but it is not closing properly. The closing strategy started with an idea for all positions to close if the price reached, 1*iATR, a signal for a profitable close.
And if the price moved agaisnt the trade by, 2*iATR, a signal for a StopLoss. As I said it works fine. But when the code is optimized, the closing is not proper.