Page 1 of 2 12 LastLast
Results 1 to 10 of 12
 0 Attachment(s)    

Thread: Indicator Problem

  1. #1
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default Indicator Problem

    Hi all,

    I'm working an an EA which uses MACD+Stoch for entry signals.

    If i use the ea on 5 digits broker, signals are right and orders will be opened correctly.
    If i use the same code on 4 digits broker, no orders are executed.
    If i disable the MACD part (Stoch alone) on 4 digits broker, signals are right and orders will be opened (tp, sl settings are correct!)
    I have played with different MACD settings, but no orders opened at 4 digits broker

    Thx for any suggestions

    IX

    extern int KPeriod = 8;
    extern int DPeriod = 7;
    extern int Slowing = 21;
    extern int Method =MODE_SMMA;
    extern int Price =PRICE_CLOSE;

    extern int MACDFast = 12;
    extern int MACDSlow = 26;
    extern int MACDPeriod = 12;
    extern int MACDPrice = MODE_OPEN;

    Buy:
    if(iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPric e,MODE_MAIN,0)>
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_SIGNAL,0) &&
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_MAIN,1)>
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_SIGNAL,1) &&
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_MAIN,2)<
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_SIGNAL,2) &&
    MathAbs(NormalizeDouble(iMACD(0,0,MACDFast,MACDSlo w,MACDPeriod,MACDPrice,MODE_MAIN,0),4))>=5*Point &&
    iStochastic(0,0,KPeriod,DPeriod,Slowing,Method,Pri ce,MODE_MAIN,0)> 30 &&
    iStochastic(0,0,KPeriod,DPeriod,Slowing,Method,Pri ce,MODE_MAIN,0)< 70 &&
    iStochastic(0,0,KPeriod,DPeriod,Slowing,Method,Pri ce,MODE_MAIN,0)>
    iStochastic(0,0,KPeriod,DPeriod,Slowing,Method,Pri ce,MODE_SIGNAL,0))

    Sell:
    if(iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPric e,MODE_MAIN,0)<
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_SIGNAL,0) &&
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_MAIN,1)<
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_SIGNAL,1) &&
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_MAIN,2)>
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_SIGNAL,2) &&
    MathAbs(NormalizeDouble(iMACD(0,0,MACDFast,MACDSlo w,MACDPeriod,MACDPrice,MODE_MAIN,0),4))>=5*Point &&
    iStochastic(0,0,KPeriod,DPeriod,Slowing,Method,Pri ce,MODE_MAIN,0)< 70 &&
    iStochastic(0,0,KPeriod,DPeriod,Slowing,Method,Pri ce,MODE_MAIN,0)> 30 &&
    iStochastic(0,0,KPeriod,DPeriod,Slowing,Method,Pri ce,MODE_MAIN,0)<
    iStochastic(0,0,KPeriod,DPeriod,Slowing,Method,Pri ce,MODE_SIGNAL,0))

  2. #2

    Default

    Here's your problem line

    Code:
    MathAbs(NormalizeDouble(iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,MODE_MAIN,0),4))>=5*Point
    5 points on a 5 digit broker will be a significantly lesser value than it will be for a 4 digit broker (it becomes the equivalent of 50 points) and the condition is probably never being achieved which explains why it's not trading. I don't even understand what that line is meant to be doing within the rules, to be honest.

  3. #3
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default

    Quote Originally Posted by jezzer1961 View Post
    Here's your problem line

    Code:
    MathAbs(NormalizeDouble(iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,MODE_MAIN,0),4))>=5*Point
    5 points on a 5 digit broker will be a significantly lesser value than it will be for a 4 digit broker (it becomes the equivalent of 50 points) and the condition is probably never being achieved which explains why it's not trading. I don't even understand what that line is meant to be doing within the rules, to be honest.
    Thx Jezzer,

    you are right, for testing i was removing the 5 points code, but also no open trades

    no i was testing with the standard code and it works:

    if(iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)<i MACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0)

    and the original code:
    if(iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPric e,MODE_MAIN,0)>
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_SIGNAL,0) &&
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_MAIN,1)>
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_SIGNAL,1) &&
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_MAIN,2)<
    iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,M ODE_SIGNAL,2) &&
    MathAbs(NormalizeDouble(iMACD(0,0,MACDFast,MACDSlo w,MACDPeriod,MACDPrice,MODE_MAIN,0),4))>=5*Point )

    Can anyone explain me, where is the logical failure? I'm not a indi coding guy :-)

    Thx

    IX

  4. #4
    Junior Member
    Join Date
    May 2009
    Location
    UK, London
    Posts
    5

    Default

    I tested your signals and they are working. Probably you have some problem in other part of code.

  5. #5
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default

    Quote Originally Posted by marynarz15 View Post
    I tested your signals and they are working. Probably you have some problem in other part of code.
    Thx for your crosscheck, i'll review the code

  6. #6

    Default

    The logical failure is that there's not intended to be any correlation between the value returned by the MACD and the price. Instead, I believe you should just use a fixed value.

    Let's say you've got a Yen cross with 2 digits. As your code is currently written, your condition would then be that if MACD>0.05 you'd enter the market.

    If it were a Yen cross with 3 digits, it would be if MACD>0.005 instead. And so on ........

    Instead you should perhaps introduce an external variable - let's call it MACD_factor - and say:

    if (MACD>0.00001*MACD_factor) {Do This;}

    You could then optimise the variable to find the best level to enter the market.

    The other thing that I didn't understand was the logic in normalising the double and then taking its MathAbs. This will keep you out of the market when the MACD is close to its zero line, but it will mean that you could still find yourself going long with it below the zero and short with it above. Is that actually what you intended?
    Last edited by jezzer1961; 05-19-2009 at 11:57.

  7. #7

    Default

    If it's still not taking trades, why not debug it by creating a text string containing all of the values being returned for the different MACD values and show the string as a comment?

    For example:

    Code:
    string debug="Current MACD main: "+iMACD(0,0,MACDFast,MACDSlow,MACDPeriod,MACDPrice,MODE_MAIN,0+"\n";
    debug=debug+"Current MACD signal: "+iMACD(..................)+"\n";
    debug=debug+"................., etc
    
    Comment(debug);
    With it being a larger string it would probably be better to concatenate it instead, but it's the idea that I'm trying to get across.

    You will then be able to see what's going on inside the EA to check if it's the same as what you think should be happening.

    Edit: Your code also seems to be using 0 for its symbol. I haven't checked to confirm if that's a valid input or not, but shouldn't you be using either NULL or Symbol() instead of 0?
    Last edited by jezzer1961; 05-19-2009 at 11:59.

  8. #8
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default

    Thx jezzer, you are my hero for the day.

    you pointed me in the right direction:

    - 5 points, working on 5 digits, setting 0.5 for 4 digits = is now working!
    - debug coding, a learning session (i'm a IT dino, can code assembler, pascal, cobol, fortran, can read anything code, but not clearly c++, c#, its 20 years ago, when i was a small programmer)
    - yes you are right with your precise description, what the code should do


    thanks

    IX

    PS: thanks to marynarz too!
    Last edited by ixbone; 05-19-2009 at 11:17.

  9. #9
    Junior Member
    Join Date
    May 2009
    Location
    UK, London
    Posts
    5

    Default

    I'm not sure if we got it here...
    I debugged it with some settings and it was giving signals.
    I don't think MACD>value is issue here.
    You take Abs of it - this means that u avoid MACD beeing almost at zero line
    <-value..0..+value> is cut off from signal
    Usually u want MACD to be >value for long or <value for short and in that case u should not use MathAbs...
    Good luck.
    Rafal
    mqlservice.co.uk

  10. #10
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default

    Quote Originally Posted by marynarz15 View Post
    I'm not sure if we got it here...
    I debugged it with some settings and it was giving signals.
    I don't think MACD>value is issue here.
    You take Abs of it - this means that u avoid MACD beeing almost at zero line
    <-value..0..+value> is cut off from signal
    Usually u want MACD to be >value for long or <value for short and in that case u should not use MathAbs...
    Good luck.
    well i dont understand the logic completly well, but whatever, 5 for 5 digits, 0.5 for 4 digits broker, it works, thats the point :-) i'll keep your quote in my mind, if someday i need it.

Similar Threads

  1. Help- SL problem
    By shabeer.a100 in forum Softwares
    Replies: 1
    Last Post: 09-12-2013, 15:00
  2. Problem with an ea
    By stotzman in forum MQL programming
    Replies: 1
    Last Post: 07-08-2013, 12:57
  3. Help- SL problem
    By shabeer.a100 in forum Ideas for expert advisors
    Replies: 1
    Last Post: 11-22-2012, 03:07
  4. Help- SL problem
    By shabeer.a100 in forum Scripts and other tools
    Replies: 0
    Last Post: 11-21-2012, 13:57
  5. Custom indicator problem
    By scorch351 in forum Indicators
    Replies: 0
    Last Post: 06-21-2009, 11:50

Tags for this Thread

broker, coding, correlation, equation, indicator, macd, main, martingale, programmer, review, rsi, signal, signals, stoch, system, time, trading

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •