oswoil: pls what do you think is the cause of this?
Play videoPlease edit your post.
For large amounts of code, attach it.
- What do you think the value of i is after those statements?
int i ; i = 0< i <10 ;
if ( High[0]-Open[0] == enterpip * Point ) // enter buy if up trend
The == operand. - MQL4 forum

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have been trying to program a News Trading EA for some time now. Below is a copy of what i have gotten so far. How the EA was supposed to work was that I would plug in the time to enter a trade and the amount of movement in a particle direction with which it would enter the trade and then close the trade when there is a 5pip movement in the negative direction. I ran this EA in my MT4 terminal bit was'nt opening any positions even if the specified time was hit. pls what do you think is the cause of this?
#property copyright "Oswald James"
//---------------------------------------------------------------------------------------
// defined time for news release
extern int enterpip;
extern datetime NewsTime1;
extern datetime NewsTime2;
extern datetime NewsTime3;
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
//--------------------------------------------------------------------------------------------------------
int start()
{
int i ;
double HIGH ;
double LOW;
i = 0< i <10 ;
int tries = 0;
while ( tries < 3)
{
if ( NewsTime1== Time[0] || NewsTime2 == Time[0] || NewsTime3 == Time[0])
// at time of news release
{ Order(); }
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------
if ( High [0] > High[i] )
{HIGH = High[0];} else
if (High[0]< High[i])
{HIGH = High[i];}
if ( Low[0]< Low[i])
{LOW = Low[0];} else
if (Low[0] > Low[i])
{LOW = Low[i];}
//--------------------------------------------------------------------------------------------------------------------------------
if ( HIGH -Bid==Point*5 || Bid-LOW==Point*5)
{ Close_All();
Alert ("orders closed! / Open Price = " , OrderOpenPrice(), " and Closing Price = ", OrderClosePrice() );
RefreshRates();
}
//close open orders
return ;
}
//+----------------------------------------------------------------------------------------------------------------------------------
void Order()
{
if ( High[0]-Open[0] == enterpip * Point ) // enter buy if up trend
{
Order_Buy();
Alert("Order Entered! Type = Buy ------- Open Price = " , OrderOpenPrice()) ;
RefreshRates();
} // buy order
if ( Open[0]-Low[0]==enterpip * Point ) //enter sell if downtrend
{ Order_Sell();
Alert("Order Entered! Type = Sell ---- Open Price = " , OrderOpenPrice()) ;
RefreshRates();
} //sell order
RefreshRates();
}
//+---------------------------------------------------------------------------------------------------
void Order_Buy()
{ while( OrdersTotal()<10)
{
OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0.0,0.0 );
}
}
void Order_Sell()
{ while(OrdersTotal()<10 )
{
OrderSend(Symbol(),OP_SELL,0.01,Ask,3,0.0,0.0);
}
}
void Close_All()
{
while(OrdersTotal()>0)
{
OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
switch ( OrderType())
{
case OP_BUY: OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(),MODE_BID), 5, Purple); break;
case OP_SELL: OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(),MODE_ASK), 5, Purple); break;
}
}
}