Orders Execution
Indicators Used
0
Views
0
Downloads
0
Favorites
EURUSD Negative Breakout v0.1
//+-----------------------------------------------------------+
//| EURUSD Negative Breakout EA |
//| version 0.1 |
//| Original idea from mushy999 |
//| EA conversion by Azmel |
//| Copyright © Forex-TSD.com |
//+-----------------------------------------------------------+
//| INSTRUCTIONS: Attach the EA to EURUSD M5 chart. |
//+-----------------------------------------------------------+
//| VERSION HISTORY |
//| 0.1 - Initial release. |
//+-----------------------------------------------------------+
#include <stdlib.mqh>
//EXTERNAL VARIABLES
extern int Magic=327697;
extern double Lots=0.01;
extern int TakeProfit=80;
extern int StopLoss=1000;
extern int HighCount=65;
extern int FirstMAP=50;
extern int SecondMAP=166;
extern int FirstMAType0to4=2;
extern int SecondMAType0to4=2;
extern int FirstPriceType0to6=3;
extern int SecondPriceType0to6=0;
extern int PeriodsTillClose=310000;
int counter;
int counter2=0;
double Low100;
double High100;
int i;
int slippage=5;
int ticket;
double FirstMA;
double SecondMA;
double Price[2];
int start()
{
int iOrders=OrdersTotal()-1;
counter2++;
FirstMA=iMA(Symbol(),0,FirstMAP,1,FirstMAType0to4,FirstPriceType0to6,1);
SecondMA=iMA(Symbol(),0,SecondMAP,1,SecondMAType0to4,SecondPriceType0to6,1);
if(counter2 > PeriodsTillClose)
{
for(i=iOrders; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderType()<=OP_SELL) && GetMarketInfo() && !OrderClose(OrderTicket(),OrderLots(),Price[1-OrderType()],slippage)) Print(OrderError());
}
counter2=0;
}
High100=0;
for(i=1;i<=HighCount;i++)
{
High100=MathMax(High100,High[i]);
}
if(Ask>High100+1*Point && CountTrades()<=20 && DayOfWeek()!=5 && FirstMA < SecondMA)
{
Lots=AccountBalance() / 400000;
counter2=0;
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,"GBPUSD Breakout",Magic,0,Blue);
}
return(0);
}
int CountTrades()
{
counter=0;
for(i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==Magic)
{
counter++;
}
}
return(counter);
}
//+------------------------------------------------------------------+
//| Function..: OrderError |
//+------------------------------------------------------------------+
string OrderError() {
int iError=GetLastError();
return(StringConcatenate("Order:",OrderTicket()," GetLastError()=",iError," ",ErrorDescription(iError)));
}
//+------------------------------------------------------------------+
//| Function..: GetMarketInfo |
//| Returns...: bool Success. |
//+------------------------------------------------------------------+
bool GetMarketInfo() {
RefreshRates();
Price[0]=MarketInfo(OrderSymbol(),MODE_ASK);
Price[1]=MarketInfo(OrderSymbol(),MODE_BID);
double dPoint=MarketInfo(OrderSymbol(),MODE_POINT);
if(dPoint==0) return(false);
//giSlippage=(Price[0]-Price[1])/dPoint;
return(Price[0]>0.0 && Price[1]>0.0);
}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---