need help with ea

 

Hi,

This ea opens/closes positions perfectly with forex pairs, but doesn't work with stocks, commodities and so on, i believe problem is digit number, can someone help with that?

 
Yes it's probably caused by a wrong digits value but without the source code (.mq4) there's no chance to fix it.
 
lippmaje:
Yes it's probably caused by a wrong digits value but without the source code (.mq4) there's no chance to fix it.

Here you are

 

Try this (line 87):

   if(dg==2 || dg==3 || dg==5){pt=Point*10;mt=10;}else{pt=Point;mt=1;}

I didn't check further. The whole EA looks a bit broken, and is built for a very old MT4 release. I'd ask a freelancer to polish it.

 
//|---------martingale initialization
  1. Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
              Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum 2015.02.11

    Why it won't work: Calculate Loss from Lot Pips - MQL5 programming forum 2017.07.11

  2. don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
    1. Terminal starts.
    2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
    3. OnInit is called.
    4. For indicators OnCalculate is called with any existing history.
    5. Human may have to enter password, connection to server begins.
    6. New history is received, OnCalculate called again.
    7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.

  3. Ignas Urbanas: but doesn't work with stocks, commodities and so on, i believe problem is digit number,

    Your belief is only partially correct.

    1. The existing code adjusts for 4/5 digit brokers, just extend it for non-fractional sizes.
         if(dg%2 != 0){pt=Point*10;mt=10;}else{pt=Point;mt=1;}
    2. When it was written there was only FX and ticksize was the same as point. Everywhere pt is used, must be changed to use ticksize. Likewise lotdigits, and NormalizeDouble
      NormalizeDouble, It's use is usually wrong, as it is in your case.
      1. Floating point has infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
                  Double-precision floating-point format - Wikipedia, the free encyclopedia

        See also The == operand. - MQL4 programming forum

      2. Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.

      3. SL/TP (stops) need to be normalized to tick size (not Point) — code fails on metals. (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 programming forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 programming forum

      4. Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 programming forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 programming forum

      5. Lot size must also be adjusted to a multiple of LotStep and check against min and max. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.

      6. MathRound() and NormalizeDouble() are rounding in a different way. Make it explicit.
                  MT4:NormalizeDouble - MQL5 programming forum
                  How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum

      7. Prices you get from the terminal are already normalized.

      8. PIP, Point, or Tick are all different in general.
                  What is a TICK? - MQL4 programming forum 2014.08.03

    3. The lot size starts with 0.1. That would have to be changed to your broker's minimum size for the symbol you want to trade.