EA coding help (from pseudo code)

//
Hi all.

I have traded manually for more than 2 months and now I want to write an alerting system (not really an EA that make real order) to alert me about important events.
I do not have strong programming background and also not so familiar with mql4 language.

Could you please help me translate my pseudo code to the mql4 code? Or if you don’t have much time, give me some examples how to write mql function of some lines in my pseudo code.
This is my ‘hello world’ mql program. I really appreciate any advice how to improve it

The program is intended to be used in current opening chart (1 pair, 1 time frame). The idea is to alert when some event happen in a specific scenario (market state). The only indicator used is Bollinger band(20,2).

int market_state = 0
int alert1 = 0
int time_interval = 15 //minutes
double percent = 0.03
double small_value = 0.01

//determine market state
while (current_bar close)
do
{
if (current_time - time_interval) / current_time > percent
{ if (current_time - 2 * time_interval) / current_time > 2* percent
market_state = 1 //trend market
}

if (current_time - time_interval) / current_time < small_value
{ if (current_time - 2 * time_interval) / current_time < small_value
   market_state = 2 //flat market
}

}

//alert correspond to market state

while (market_state = 1 )
do
{
if (openprice - MA(20))*(MA(20) - closeprice) >0 //price pass MA(20) string
alert1(messege1, sound1)
alert1 = 1
if (currentprice = MA + 1.5 StandardDeviation and alert1 = 1) OR (currentprice = MA - 1.5 StandardDeviation and alert1 = 1)
alert2(messege2, sound2)
alert1 = 0 //reset alert1
market _state =0 //reset market_state
}

while (market_state = 2 )
do
{
if (closing_price < bands(20) lower ) OR (closing_price > band(20) upper )
alert3(messege3, sound3)
market _state =0 //reset market_state
}

okay, I have made a step further. But I don’t know how to write full program or whether it is a good approach? I really appreciate any advice how to improve it.

static int market_state = 0;
static int alert1 = 0;
int interval = 3;
int signalBar = 0;
double percent = 0.03;
double small_value = 0.01;
double AverageValue = 0;
double SDValue = 0;

while (true)
do
{
//determine market state
if (Close[signalBar] - Close[signalBar - interval]) / Close[signalBar] > percent
{ if (Close[signalBar] - Close[signalBar - 2interval]) / Close[signalBar] > 2 percent
market_state = 1; //trend market
}

if (Close[signalBar] - Close[signalBar - interval]) / Close[signalBar] &lt; small_value
{ if (Close[signalBar] - 2 * Close[signalBar - interval]) / Close[signalBar] &lt; small_value
   market_state = 2; //flat market
}

//alert correspond to market state

if( market_state = 1)
{
AverageValue = iMA(NULL,0,20,0, MODE_SMA,PRICE_CLOSE,0);
SDValue = iStdDev(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0);

if (Open[signalBar] - AverageValue)*(AverageValue - Close[signalBar]) &gt;0 //price pass MA(20) string
	PlaySound("Alert1.wav");
	alert1 = 1;
if (currentprice = AverageValue + 1.5 SDValue AND alert1 = 1) 
OR (currentprice = AverageValue - 1.5 SDValue AND alert1 = 1) 
	PlaySound("Alert2.wav");
	alert1 = 0;  //reset alert1
	market_state = 0; //reset market_state
}

if( market_state = 2)
{
if  (Close[signalBar - 1] &lt; AverageValue - 2*SDValue )  OR (Close[signalBar - 1]  &gt; AverageValue + 2*SDValue )
	PlaySound("Alert3.wav");
	market_state =0; //reset market_state
}

}

Hallo,

To make it a full EA:


// Put your global variables here

int init()
{
return(0);
}

int deinit() 
{
return(0);
}

int start()
{
    //put your local variables here

    //put your main code here

    return (0)
}

Then save the file as <filename>.mq4 and put in experts folder

Cheers