Have an indicator I would like to convert to EA

Jake8055

New member
Hi, I have a very simple Indicator I want to open and close trades for me. I've spent the last few days making 1 line of code work and im frustrated.:confused: So I figure I'll ask for some help. The object of this indicator is to recognise a major 1 candle price move (currently set at 250 Points-not pips) and to set off an alarm and alert message. It works on whatever time frame your trading on. Its just an indicator right now but I'd like to make it an EA that will open at the peak of the spike in favor of the opposite direction, whichever that may be, and to Take Profit exactly 150 points on the retracement. Here is the code I have so far, any help is much appreciated:

//+------------------------------------------------------------------+
//| EURUSD Spike Alert.mq4 |
//| Copyright ? 2011, MetaQuotes Software Corp. |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2011, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
extern double Alert_Playcount=50;


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if(High[0]-Low[0]>250*Point)PlaySound("Alert.wav");
if(High[0]-Low[0]>250*Point)Alert("EURUSD");

//----

//----
return(0);
}
//+------------------------------------------------------------------+


Thank You!
 

stovedude

Active member
What exactly is not working? I see that it will continually alert on each tick, so you will need to add in your if function like this:

if (High[0]-Low[0]>250*Point && LastAlertTime!=Time[0]) {
PlaySound("Alert.wav"); // This is unnecessary, because the Alert function plays this sound anyway
Alert("EURUSD");
LastAlertTime=Time[0];
}

And then add this up above after the extern part:

datetime LastAlertTime=0;
 

mtuppers

Member
What exactly is not working? I see that it will continually alert on each tick, so you will need to add in your if function like this:

if (High[0]-Low[0]>250*Point && LastAlertTime!=Time[0]) {
PlaySound("Alert.wav"); // This is unnecessary, because the Alert function plays this sound anyway
Alert("EURUSD");
LastAlertTime=Time[0];
}

And then add this up above after the extern part:

datetime LastAlertTime=0;

he or she want an ea for this indicator. but... I don't think will work.
 

Jake8055

New member
Thanks for your reply.

Thanks for your reply.

Thanks for your reply Stovedude. The Indicator works PERFECT for being so simple. but I want an "EA" using the parameters of the Indicator that automatically places a trade at the end of the spike candle in favor of the opposite direction and then closes it after the spike retraces itself on the next candle. These spikes are very rare and extremely fast. Example: USDJPY spikes 300 points on 1 candle, EA places BUY/SELL order(Whichever is OPPOSITE OF THE CANDLE SPIKE). The next candle will retrace most if not all of this 300 point spike. So the EA automatically Takes Profit (set at 150 points) when the next candle retraces that 300 point spike. Do you understand? I appreciate any help anyone can offer. Thanks.
 

Aurix Exchange
Top