1. #1
    rookie_forawhile is offline Junior Member
    Join Date
    Jan 2013
    Posts
    23
    Points
    126
    Credits
    444
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    Can anyone help me with mapping an indicator into the EA?

    Hi Everyone!

    I have been struggling with this problem for a while. I used mql4 references and Googled so hard that actually some keypad came out of my keyboard.

    So what am I trying to achieve? I have this indicator SDX8 and EA from a template. SDX8 indicator draws lower and upper zones (max and lows in last 8 hours) and also draws entry signals.

    I want the EA to be able to map those variables via iCustom function but I've had no luck so far. I want the EA to go long when entrysignals are drawn on the Zone1Lower and go short when entrysignals are drawn on the Zone1Upper. I only want them to go long/short when there are 2 or more signals (circles) drawn on those max/low lines.
    I dont worry about the exit strategy because I will use fixed stop loss/ take profit and those should be pre-coded into the EA

    I tried to code it but I am a beginner and this is too big challenge for me. Thank you in advance for help.

    Attachment 149873Attachment 149874

    The indicator and the EA are attached.

  2. #2
    seekers is offline Senior Member
    Join Date
    Sep 2012
    Posts
    2,528
    Points
    2,859
    Credits
    51,534
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow
    rookie_forawhile, attachments are wrong (does not download anything)

  3. #3
    rookie_forawhile is offline Junior Member
    Join Date
    Jan 2013
    Posts
    23
    Points
    126
    Credits
    444
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    Sorry, I'll try again

    Here we go. Thanks for such a quick response.
    Attached Files

  4. #4
    cosmiclifeform is offline Senior Member
    Join Date
    Jun 2009
    Posts
    287
    Points
    383
    Credits
    2,436
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    SDX indicator - Add ALL Externs For iCustom

    Quote Originally Posted by rookie_forawhile View Post
    Here we go. Thanks for such a quick response.
    rookie_forawhile

    I took a quick look at the indicator SDX8.mq4...and it seems to have problems with the email function...which may be causing problems with your EA...

    That version SDX indicator also has many more "externs" than you have listed in your iCustom statements.

    They are listed at the top and are associated with the email function....and ALL "externs" have to be added to your iCustom statements.

    You can either add ALL the "externs" to your EA iCustom...or you can blank the email extern's out with // (right slashes) in the indicator.

    You may need to go through the code and blank out all the other email stuff as well.

    Also to help debugging...add Print and Comments to your EA's to make sure you are getting and displaying all the values you want.

    I did find the original SDX version without the email mod's - SDX-ZoneBreakout2.mq4.

    It is attached for your use.
    SDX-ZoneBreakout2.mq4

    Hope this helps you,
    Robert

  5. #5
    rookie_forawhile is offline Junior Member
    Join Date
    Jan 2013
    Posts
    23
    Points
    126
    Credits
    444
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    Externs

    Thank you very much.

    I added that email and push functions to the indicator, because you only get a few signals per day and I found the xpMail to attach screenshots to emails.

    But now I figured an EA might be a better solution.

    The idea behind the indicator works most of the times especially when there are Zone1Lower and upper and the price hits one of the zones more than once. iN that case there is a solid probability of a new trend.

    So basically what you are saying is that I have to map all externs that are associated with the "if" statement, which takes care of alerts, right?

    I'll start with the original indicator and I'll give your suggestions a try. Thank you again. Do you think that those iCustom statements that I put to the EA are correct from the syntax point of view? And that the logic behind those "if" statements to either buy or sell is correct?

    The EA is pre-coded in such a way that I have to write some if statement with conditions when to buy/sell and then if it is true it should set Order=SIGNAL_BUY or Order=SIGNAL_SELL. Then the EA should take care of the rest (processing the order), right?

    Thank you very much for answers.

    -Robert

  6. #6
    cosmiclifeform is offline Senior Member
    Join Date
    Jun 2009
    Posts
    287
    Points
    383
    Credits
    2,436
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    SDX indicator - Add ALL Externs For iCustom

    Quote Originally Posted by rookie_forawhile View Post
    Thank you very much.

    I added that email and push functions to the indicator, because you only get a few signals per day and I found the xpMail to attach screenshots to emails.

    But now I figured an EA might be a better solution.

    The idea behind the indicator works most of the times especially when there are Zone1Lower and upper and the price hits one of the zones more than once. iN that case there is a solid probability of a new trend.

    So basically what you are saying is that I have to map all externs that are associated with the "if" statement, which takes care of alerts, right?

    I'll start with the original indicator and I'll give your suggestions a try. Thank you again. Do you think that those iCustom statements that I put to the EA are correct from the syntax point of view?

    And that the logic behind those "if" statements to either buy or sell is correct?

    The EA is pre-coded in such a way that I have to write some if statement with conditions when to buy/sell and then if it is true it should set Order=SIGNAL_BUY or Order=SIGNAL_SELL. Then the EA should take care of the rest (processing the order), right?
    Hi rookie,

    Just to be clear - The indicator externs are associated with the iCustom statements...not the "if" statements..."

    You get your iCustom values first and then use the values in your "if" statements...
    --------

    Check other available EA's and study their iCustom syntax's and see the common syntax they all have.

    iCustoms include all the # of externs, the buffer, and the bar shift...

    Your iCustom only has 1 extern, the buffer, and bar shift.
    double Zone1Upper = iCustom(NULL,0,"SDX8",0.0,0,0);

    But...Your indicator has 3 externs...if you don't include the email externs...

    Also look at your indicator externs for what "type" of variables you need in your iCustoms...then add the buffer and the bar shift.

    Hint...one extern is a bool...not an integer or double...

    SDX8 Indicator:

    extern bool DoEntryAlerts= true;
    extern int TimeZoneOfData= 1; // time zone of metatrader charts
    extern int PipsForEntry= 5;
    -------

    I didn't check the Buy/Sell Trades part of the code...but that EA is a basic Expert Builder Template so I would assume if it hasn't been changed...it should work fine.

    Again...add Comments to make sure you can see you are getting your iCustom values ok...

    Hope that helps,
    Robert

  7. #7
    rookie_forawhile is offline Junior Member
    Join Date
    Jan 2013
    Posts
    23
    Points
    126
    Credits
    444
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    iCustom

    Hi Robert,

    ok, so i am using the original indicator now. so i have only 3 externs, which should be passed via iCustom. one of my mapped iCustoms should look like this:

    1) double Zone1Upper = iCustom(NULL,0,"SDX-ZoneBreakout2",bool DoEntryAlerts,int TimeZoneOfData,int PipsForEntry,0,0);

    or this:


    2) double Zone1Upper = iCustom(NULL,0,"SDX-ZoneBreakout2",true,0,5,0,0);

    this second one is considered as ok by the compiler, but it doesnt make any sense, right? I want those values to passed from the indicator to the EA (IN that case i don't want exact values in the iCustom). But when I use the first syntax then it says "variable not defined". Should I define it? Something like:
    #define bool DoEntryAlerts etc.? Does it make sense to have it twice? Once in the indicator and then in the EA?

    Thank you :-).

    P.S.: I will add comments, but I have to google for it. Patience, please :-)

  8. #8
    Tzuman's Avatar
    Tzuman is offline Senior Member
    Join Date
    Jun 2009
    Posts
    318
    Points
    417
    Credits
    2,570
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    1
    Following
    0
    Follow
    Hi Rookie,

    iCustom only allows values to be passed into it to set the indicator it is running. So in this case, your number 2 example is correct.

    You cannot pass out values for variables used and possibly changed by iCustom. The only way to get information out of iCustom is to specify the indicator buffer and time period in the last 2 parameters of iCustom. if you need two or three variables, you must call iCustom 2 or 3 times. Please be aware that this means each iCustom call runs your indicator separately, so 3 calls means it runs three times plus if it is on your chart, that is another time.

    Tzuman

  9. #9
    cosmiclifeform is offline Senior Member
    Join Date
    Jun 2009
    Posts
    287
    Points
    383
    Credits
    2,436
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow
    Quote Originally Posted by rookie_forawhile View Post
    Hi Robert,

    ok, so i am using the original indicator now. so i have only 3 externs, which should be passed via iCustom. one of my mapped iCustoms should look like this:

    1) double Zone1Upper = iCustom(NULL,0,"SDX-ZoneBreakout2",bool DoEntryAlerts,int TimeZoneOfData,int PipsForEntry,0,0);

    or this:


    2) double Zone1Upper = iCustom(NULL,0,"SDX-ZoneBreakout2",true,0,5,0,0);

    this second one is considered as ok by the compiler, but it doesnt make any sense, right? I want those values to passed from the indicator to the EA (IN that case i don't want exact values in the iCustom). But when I use the first syntax then it says "variable not defined". Should I define it? Something like:
    #define bool DoEntryAlerts etc.? Does it make sense to have it twice? Once in the indicator and then in the EA?

    Thank you :-).

    P.S.: I will add comments, but I have to google for it. Patience, please :-)
    Hi Rookie,

    Yes #2 is the correct one (thanks to Tzuman)...

    You are now ready to get values from the indicator.

    And it would help you...if you thought of the externs as "settings" in the iCustoms...not variables (not values).

    The externs "set" the indicator parameters...and then you get the values from the buffers directly based on that particular set of parameters...

    And Yes to your last question - you need to define the variables to be used in the iCustom in BOTH the EA and the indicator. They can be the same named or different..but whatever names you use have to be defined first.

    Looks like you are moving forward nicely... Good job so far...

    Hope this helps,
    Robert

  10. #10
    rookie_forawhile is offline Junior Member
    Join Date
    Jan 2013
    Posts
    23
    Points
    126
    Credits
    444
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    iCustom

    Hi Cosmiclifeform and Tzuman,
    thanks. I hope I am making some progress but I am still missing some C++ basics :-(


    I will use the original SDX for the EA and my edited version with emails for confirmation.

    ok I think I get it now. So the externs must be in the exact order like in the indicator, right?

    So no I added this code to the EA:

    To define:

    double Zone1Upper[];
    double Zone2Upper[];
    double Zone1Lower[];
    double Zone2Lower[];
    double EntrySignalsBuffer[];

    To map:
    //BEGIN ---- MAP CUSTOM INDICATOR VARIABLE //
    double Zone1Upper = iCustom(NULL,0,"SDX-ZoneBreakout2",true,0,5,0,0);
    double Zone1Lower = iCustom(NULL,0,"SDX-ZoneBreakout2",true,0,5,0,0);
    double Zone2Upper = iCustom(NULL,0,"SDX-ZoneBreakout2",true,0,5,0,0);
    double Zone2Lower = iCustom(NULL,0,"SDX-ZoneBreakout2",true,0,5,0,0);
    double EntrySignalsBuffer = iCustom(NULL,0,"SDX-ZoneBreakout2",true,0,5,0,0);
    //END ---- MAP CUSTOM INDICATOR VARIABLE //


    To convert indicator signals into EA's signals to buy/sell:


    // BUY ORDER- when the dot is on Zone1Lower line and also Zone1Lower is lower that Zone1Upper then Order value should be set equal to SIGNAL_BUY value (is this logic ok?)

    if (Zone1Lower == EntrySignalsBuffer && Zone1Lower < Zone1Upper ) Order = SIGNAL_BUY;

    // SELL ORDER- when the dot is on Zone1Upper line and also Zone1Upper is higher that Zone1Lower then Order value should be set equal to SIGNAL_SELL value (is this logic ok?)



    if (Zone1Upper == EntrySignalsBuffer && Zone1Lower > Zone1Upper ) Order = SIGNAL_SELL;

    Then the EA should handle it? I get no errors in the compiler and when I use strategy tester I get Entry Signals in the Journal but the EA doesnt make any orders. I think that I am missing something basic. Would you mind to take a look?

    Thank you very much.
    -Robert
    Attached Files



» Rankings

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. can anyone help me with leverage?
    By antone in forum General Discussion
    Replies: 31
    Last Post: 12-02-2012, 10:20 AM
  2. Help needed with Forex Freeway indicator please.
    By handlep in forum Metatrader 4
    Replies: 6
    Last Post: 04-21-2007, 01:16 PM
  3. Can anyone help me to make an EA?
    By gmos in forum Metatrader 4
    Replies: 8
    Last Post: 10-18-2006, 01:35 AM
  4. can anyone help program firebird trailing stop
    By chad in forum Metatrader 4
    Replies: 0
    Last Post: 10-10-2006, 12:50 PM
  5. Any body can help me with this exit indicator?
    By shiningstar in forum Metatrader 4
    Replies: 1
    Last Post: 05-18-2006, 04:56 AM

Posting Permissions

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