Hey all,
I was very happy with the help I received last time I posted in this forum, so I'm back with another n00b question.
How can I make my EA open a trade when an indicator running on a chart (say the EURUSD) gives an alert?
Specifically, I have an indicator that will put a little blue circle under a new candle when it says to open a BUY, and puts a little pink circle above a new candle when it says to SELL. It has proven to be a very effective indicator, however I am not always able to be at my computer when I receive these alerts/see the circles, so I want to integrate the indicator into an EA that will open the trades for me. I can provide the code for the indicator if the answer isn't blantantly obvious to someone out there. I was hoping it would be. Thanks again for the support!
Attach the code, without the code, you and us are just guessing.
In the indicator find the code that generate the alert, then use iCustom (https://docs.mql4.com/indicators/iCustom), replicate that code in EA.
Got that ?
Here is the code to the indicator. Near the bottom I have the two Alert and Notifications lines where it will pop up an alert on the computer and notify me by phone. I basically want to make an EA that will open the corresponding trades too. I have a basic EA layout that I can sub in the different buy and sell conditions easily, just need to know what to put. IE, the iCustom line I can utilize somehow? Thank you for the quick responses.
For some reason I couldn't get the "code" button to work so I apologize for the formatting. Thanks all.
#property copyright "Copyright © 2005, MetaQuotes Software Corp." extern int RISK=4; SetIndexStyle(1,DRAW_ARROW,EMPTY); int start()
if (TrueCount>=1) if (Table_value2[i+i1][1]>x1) } |
---|
Here is the code to the indicator. Near the bottom I have the two Alert and Notifications lines where it will pop up an alert on the computer and notify me by phone. I basically want to make an EA that will open the corresponding trades too. I have a basic EA layout that I can sub in the different buy and sell conditions easily, just need to know what to put. IE, the iCustom line I can utilize somehow? Thank you for the quick responses.
For some reason I couldn't get the "code" button to work so I apologize for the formatting. Thanks all.
I recently wrote about iCuatom https://www.mql5.com/en/forum/142102/page2#717112, and please read again documentation about iCustom (https://docs.mql4.com/indicators/iCustom).
Let me write partial of the code :
double buffer_1, buffer_2; buffer_1 = iCustom (... , 0, 1); buffer_2 = iCustom (... , 1, 1); if (buffer_1 != EMPTY_VALUE) { //--- buy } if (buffer_2 != EMPTY_VALUE) { //--- sell }
One thing to remember about your CI, you should open immediately right after the alert. I see from your other topic that you are using EA Builder, well, I don't know much about it but you have to make it open position immediately after it gets the signal.
Thanks for the response. I have reviewed both links you sent me. I am still unclear about what you put above. Why is the mode of buffer_1 set to 0 and the mode of buffer_2 set to 1? I am still new to mql4 programming so these concepts are still alien to me and I would love a full explanation as the references above don't shed much detail. Thanks for the help!
Thanks for the response. I have reviewed both links you sent me. I am still unclear about what you put above. Why is the mode of buffer_1 set to 0 and the mode of buffer_2 set to 1? I am still new to mql4 programming so these concepts are still alien to me and I would love a full explanation as the references above don't shed much detail. Thanks for the help!
This might help: https://book.mql4.com/samples/icustom
Thanks for the response. I have reviewed both links you sent me. I am still unclear about what you put above. Why is the mode of buffer_1 set to 0 and the mode of buffer_2 set to 1? I am still new to mql4 programming so these concepts are still alien to me and I would love a full explanation as the references above don't shed much detail. Thanks for the help!
Thank you for the reference material. I have read them, but I still have no idea what I'm looking at. I understand now that a buffer is essentially a numeric "name" for a certain aspect of an indicator.
Now, when creating my EA, I have entered this after my int start():
double buffer_1, buffer_2;
buffer_1 = iCustom(NULL, 0, "PerkyAsctrend1.mq4",0,0,0);
buffer_2 = iCustom(NULL, 0, "PerkyAsctrend1.mq4",0,1,0);
Am I correct so far? Recall from the indicator file (entitled PerkyAsctrend1.mq4):
//---- indicators
SetIndexStyle(0,DRAW_ARROW,EMPTY);
SetIndexArrow(0,108);
SetIndexBuffer(0, val1buffer);
SetIndexStyle(1,DRAW_ARROW,EMPTY);
SetIndexArrow(1,108);
SetIndexBuffer(1, val2buffer);
return(0);
So I have the buffers lined up. Basically, the 0 buffer is the sell alert, and the 1 buffer is the buy alert. Do I need to do anything with the "..." parameters section of the iCustom line? If not, can I just do what phi.nuts put above and just have my trade conditions start when there is not an empty value in those buffers? Sorry to be a pain, I just hate not understanding. Thanks!
Thank you for the reference material. I have read them, but I still have no idea what I'm looking at. I understand now that a buffer is essentially a numeric "name" for a certain aspect of an indicator.
Now, when creating my EA, I have entered this after my int start():
double buffer_1, buffer_2;
buffer_1 = iCustom(NULL, 0, "PerkyAsctrend1.mq4",0,0,0);
buffer_2 = iCustom(NULL, 0, "PerkyAsctrend1.mq4",0,1,0);
Am I correct so far? Recall from the indicator file (entitled PerkyAsctrend1.mq4):
//---- indicators
SetIndexStyle(0,DRAW_ARROW,EMPTY);
SetIndexArrow(0,108);
SetIndexBuffer(0, val1buffer);
SetIndexStyle(1,DRAW_ARROW,EMPTY);
SetIndexArrow(1,108);
SetIndexBuffer(1, val2buffer);
return(0);
So I have the buffers lined up. Basically, the 0 buffer is the sell alert, and the 1 buffer is the buy alert. Do I need to do anything with the "..." parameters section of the iCustom line? If not, can I just do what phi.nuts put above and just have my trade conditions start when there is not an empty value in those buffers? Sorry to be a pain, I just hate not understanding. Thanks!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey all,
I was very happy with the help I received last time I posted in this forum, so I'm back with another n00b question.
How can I make my EA open a trade when an indicator running on a chart (say the EURUSD) gives an alert?
Specifically, I have an indicator that will put a little blue circle under a new candle when it says to open a BUY, and puts a little pink circle above a new candle when it says to SELL. It has proven to be a very effective indicator, however I am not always able to be at my computer when I receive these alerts/see the circles, so I want to integrate the indicator into an EA that will open the trades for me. I can provide the code for the indicator if the answer isn't blantantly obvious to someone out there. I was hoping it would be. Thanks again for the support!