Why drag EA to the main picture above, the EA will automatically under a single first?

 
void OnTick()
  {   
  static double prevbid=0;
  double curbid=NormalizeDouble(Bid,5);
  double TD=DoubleToStr(curbid/Point-prevbid/Point);
  if((TD)>=50*Point ) 
  if ( kaidan==0)  
       { 
          {     
             bool a=OrderSend(Symbol(),OP_BUY,0.01,Ask,10,Ask-100*Point,Ask+500*Point,"BUY" ,12345,Red);   
             kaidan=1;
          }       
       }       
   }
Why drag EA to the main picture above, the EA will automatically under a single first? This is where there is a problem? How should change?

 
wxn2014: Why drag EA to the main picture above, the EA will automatically under a single first? This is where there is a problem? How should change
  1. Your post is almost unintelligible. If you are using mechanical translation, you must use simple language structure.
    1. There is no picture in your post
    2. "Automatically under a single first" is non-sense.
    3. You haven't stated a problem, so we can't possibly know where.
    4. You haven't stated a problem, so we can't possibly know how.

  2.  double curbid=NormalizeDouble(Bid,5);
    Prices are already normalzed. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is usually wrong, as it is in this case.

  3. double TD=DoubleToStr(curbid/Point-prevbid/Point);
    if((TD)>=50*Point ) 
    1. Assuming cur/previous is 1.12346/1.12345 you compute 112346.0-112345.0 which is 1.0
    2. You then make it a string "1."
    3. You then make it a double 1.0 and assign it.
    4. You then compare 1.0 to 0.00050 which is always true for any uptick.

  4. bool a=OrderSend(Symbol(),OP_BUY,0.01,Ask,10,Ask-100*Point,Ask+500*Point,"BUY" ,12345,Red);
    1. You buy at the Ask and sell at the Bid.
      • Your buy order's TP/SL are triggered when the Bid reaches it. Not the Ask.
      • Your sell order's TP/SL will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
                  MODE_SPREAD (Paul) - MQL4 and MetaTrader 4 - MQL4 programming forum - Page 3
      • The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools -> Options {control-O} -> charts -> Show ask line.)
    2. Check your return codes for errors, and report them including GLE/LE. Don't look at it unless you have an error. Don't just silence the compiler, it is trying to help you.
                What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
                Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
      Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.
 
whroeder1:

Thank you very much! I need to spend some time to understand your message!


 
whroeder1:
  1. ..

  2. Prices are already normalzed. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is usually wrong, as it is in this case.
    ...

Forum on trading, automated trading systems and testing trading strategies

General rules and best practices of the Forum.

About NormalizeDouble().


Please do not mislead people with wrong or partially true/false statements. Usually there are a lot of ways to realize a coding task, nothing is black or white in coding.

You can have your opinion, of course, but please don't present it as a "law".

Thank you.


There is nothing wrong with NormalizeDouble() function, if used properly. This has been discussed and argued numerous times.


 
Alain Verleyen: but please don't present it as a "law"
You have to form your own opinion. Mine is : there is no problem with NormalizeDouble if properly used.

I have never presented anything as law, just my opinion. I have never seen a use of it that is correct and have given multiple examples of why it was wrong.

It is you that are misleading people, stating that they can use ND. So they do, wrongly 99% of the time. Yes it has been " discussed and argued numerous times." Not once have I seen a valid use!
  1. Is it OK ... or ... could be better ??? Not understanding double comparison and to what appropriate epsilon. Unneeded usage.
  2. Round Number. Only one of four roundings, and implicit assumed. Explicit functions self-document rounding type wanted and to what value (not hiding it as a digit.)
              MT4:NormalizeDouble - General - MQL5 programming forum
              How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum
  3. NormalizeDouble(Bid, Digits). Ticksize not Point. Wrong usage.
  4. ea work fine for all pairs exept on YEN pairs. You again say "There is no problem with NormalizeDouble(). It can be used, if done correctly. If you trade non-forex symbol it will not be sufficient to get a correct price." You show that is is wrong, depending on the symbol.
  5. Elementary Inquiry on Codes. "MathRound() and NormalizeDouble() are rounding in a different way," thus use is misleading. #2
  6. How do you solve the problem of invalid volume? Not rounding to lotstep, wrong usage.
  7. Help coding delete pending after Buy or Sell Execute. "there is nothing bad to use NormalizeDouble() is it suits your needs," No use in the thread.
  8. Storing 0.07 as a double - impossible??? Wrong use of ND, should use DoubleToString.
 

whroeder1:

Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it.

Never believe whroeder1 when he is babbling about NormalizeDouble().
If you say: "Be careful with normalizing Prices or Volumes by NormalizeDouble()" then you would be right. But if you say: " Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it." then you are just a clown.

 
whroeder1:

I have never presented anything as law, just my opinion. I have never seen a use of it that is correct and have given multiple examples of why it was wrong.

It is you that are misleading people, stating that they can use ND. So they do, wrongly 99% of the time. Yes it has been " discussed and argued numerous times." Not once have I seen a valid use!
  1. Is it OK ... or ... could be better ??? Not understanding double comparison and to what appropriate epsilon.
  2. Round Number. Only one of three roundings, and implicit assumed. Explicit functions self-document type type wanted.
              MT4:NormalizeDouble - General - MQL5 programming forum
              How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum
  3. NormalizeDouble(Bid, Digits).
  4. ea work fine for all pairs exept on YEN pairs.
  5. Elementary Inquiry on Codes.
  6. How do you solve the problem of invalid volume?
  7. Help coding delete pending after Buy or Sell Execute.
  8. Storing 0.07 as a double - impossible???
  9. x

The way you wrote it, with words in uppercase is like a law or whatever you want to name it.

Your way to present things is wrong and moderators will not let you continue to mislead people. That's it. I didn't expect you will understand, all has been said and still you can't see the obvious.

The only problem with NormalizeDouble() is that people use it to normalize volume or price, which is not the good way to do it.

 
Alain Verleyen: still you can't see the obvious.

The only problem with NormalizeDouble() is that people use it to normalize volume or price, which is not the good way to do it.

That is the obvious. Its use is always wrong. Reread #4 (I was still editing.) It is you that are misleading people. That's it.

Show me one use, just one valid use. When you can't, "you will understand," why I can't emphasize it ENOUGH.

 
whroeder1:

That is the obvious. Its use is always wrong. Reread #4 (I was still editing.) It is you that are misleading people. That's it.

Show me one use, just one valid use. When you can't, "you will understand," why I can't emphasize it ENOUGH.

I will not start a new discussion. You already asked that question, I already answered. The problem is not NormalizeDouble(), I used it all the time, as a lot of other coders. The problem is your way to say things, let's people thing by themself !

You said it's not a law but an opinion. Ok then you can be sure sure everyone here know your opinion, please stop flooding the forum with your opinion. We are talking about coding opinion doesn't matter, only facts.

Forum on trading, automated trading systems and testing trading strategies


OrderModify error 1 during back testing

angevoyageur: However NormalizeDouble() function can be used to compare double.

whroeder1, 2014.03.05 15:19

Sure, it can. But then

  1. you run into Can price != price ? - MQL4 forum and those problems.
  2. You get people normalizing to Digits when price must be normalized to tickValue (not necessary equal to Point=10**Digits) therefor generally wrong.
  3. You get people normalizing to 0.01 when lotsize must be normalized to lotStep (not necessary equal to a power of ten) therefor generally wrong.
  4. it's an expensive call. MathAbs( v1 - v2 ) < Point/2 (equality) and v1 - v2 > -Point/2 (>=) are efficient, and explicitly show the equality test.

Sure, it can, but I recommend never use it for any reason.

In the past, you even recognized NormalizeDouble() can be used. Why is it so hard for you to be more balanced in what you write now ?
NormalizeDouble - Conversion Functions - MQL4 Reference
NormalizeDouble - Conversion Functions - MQL4 Reference
  • docs.mql4.com
Calculated values of StopLoss, TakeProfit, and values of open prices for pending orders must be normalized with the accuracy, the value of which can be obtained by Digits(). Please note...
 
Alain Verleyen: In the past, you even recognized NormalizeDouble() can be used. Why is it so hard for you to be more balanced in what you write now ?

Why is it do hard for you to see. I said "Sure, it can. But then" <problems>... What is why it should never be used.

The fact is use it and you code will eventually break. The fact is, its use is usually wrong. The fact is, it rounds wrong. The fact is, you blindly encourage people to write bad code by stating that it's ok. The fact is you want to sensor me for my opinion that I back up with facts.

 
whroeder1:

Why is it do hard for you to see. I said "Sure, it can. But then" <problems>... What is why it should never be used.

The fact is use it and you code will eventually break. The fact is, its use is usually wrong. The fact is, it rounds wrong. The fact is, you blindly encourage people to write bad code by stating that it's ok. The fact is you want to sensor me for my opinion that I back up with facts.

Censor ? That's years I am trying to discuss with you. It was my last attempt for sure.

Your sentence about NormalizeDouble() will be considered as trolling, removed from new post and the author banned for not respecting moderator advice. The hundreds of old posts with your "opinion" will be left untouched, to demonstrate how you was censored.