check Allow Live trading in the expert properties
thanks
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
//| fortune-fifty.mq4
//| total. total@bajzel.pl
//+------------------------------------------------------------------+
#property copyright "Copyright C 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
extern double Lots = 1;
extern int StopLost = 10;
#include <stdlib.mqh>
//+------------------------------------------------------------------+
//| script program start function
//+------------------------------------------------------------------+
int ticket;
double ema10 = 0, ema20 = 0;
int start()
{
while(true) {
MathSrand(LocalTime());
double rand = MathRand()/32767;
RefreshRates();
ema10 = iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,0);
ema20 = iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,0);
if( rand < 0.1 && ema10 < ema20 )
{
ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,4,Bid+StopLost*Point, Bid-StopLost*Point,"m",255, 0, CLR_NONE);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else
{
Print("Error opening SELL order : ",ErrorDescription(GetLastError()));
}
}
else if( rand < 0.1 && ema10 > ema20)
{
ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,4,Ask-StopLost*Point,Ask+StopLost*Point,"m",255, 0, CLR_NONE);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else
{
Print("Error opening BUY order : ",ErrorDescription(GetLastError()));
}
}
while (OrdersTotal() > 0)
{
Sleep(1000);
}
Sleep(10000);
}
return(0);
}
//+------------------------------------------------------------------+