Orders Execution
Indicators Used
0
Views
0
Downloads
0
Favorites
trailing_Alligator_v2
//+------------------------------------------------------------------+
//| traling_Alligator_v2.mq4 |
//| Copyright © 2009, Fibook.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Fibook.ru"
#property link "http://www.fibook.ru"
extern int ControlBar = 1, // Bar closes control
PeriodControl = 60; // Period Control
extern string CCC = "0-Control Green, 1-Control Red";
extern int CloseColorControl = 1; // Line Control
extern bool ControlBar5 = true;
double profit,result;
string Line;
int init()
{
result = 0;
// Comment ("");
return(0);
}
int start()
{
if (IsExpertEnabled())
{
Sleep (50);
RefreshRates();
for (int i=OrdersTotal();i>=1;i--)
{
OrderSelect (i-1,SELECT_BY_POS,MODE_TRADES);
{
if (OrderType()==OP_BUY && Symbol() == OrderSymbol())
{
double price = MarketInfo (OrderSymbol(),MODE_BID);
if (Close [ControlBar] < ColorControl (OrderSymbol())||
bar5 (OrderSymbol(),1)==true)
OrderClose (OrderTicket(),OrderLots(),price,3,0);
result = OrderProfit()+result;
}
if (OrderType()==OP_SELL && Symbol() == OrderSymbol())
{
price = MarketInfo (OrderSymbol(),MODE_ASK);
if (Close [ControlBar] > ColorControl (OrderSymbol())||
bar5 (OrderSymbol(),-1)==true)
OrderClose (OrderTicket(),OrderLots(),price,3,0);
result = OrderProfit()+result;
}
}
}
for (i=OrdersTotal();i>=1;i--)
{
OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES);
profit = OrderProfit()+OrderSwap()+profit;
}
for (i=OrdersTotal();i>=1;i--)
{
OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES);
if (OrdersTotal()!=0 && Symbol() == OrderSymbol())
Comment ("Traling on Alligator. Bar Control - ",ControlBar,". Line control - ",Line," ",ColorControl (OrderSymbol()),"\n",
"Total profit ", profit,"\n",
"Profit ",OrderSymbol(), " ",OrderProfit() + OrderSwap());
}
if (OrdersTotal()==0 && Symbol() == OrderSymbol())
{
Alert ("EA closes deal on the Alligator with result ", result);
result = 0;
}
profit =0;
}
//----
return(0);
}
//+------------------------------------------------------------------+
// Ðàññ÷åò Àëëèãàòîðà
//+------------------------------------------------------------------+
double ColorControl (string OS)
{
double AlligatorRed = NormalizeDouble(iAlligator(OS, PeriodControl, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, ControlBar),Digits);
double AlligatorGreen = NormalizeDouble(iAlligator(OS, PeriodControl, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORLIPS, ControlBar),Digits);
if (CloseColorControl == 0) {Line = "Green"; return (AlligatorGreen);}
if (CloseColorControl == 1) {Line = "Red"; return (AlligatorRed);}
}
bool bar5 (string OS, int t)
{if(ControlBar5 == true) return (false);
switch (t)
{
case 1:
{if (Close [1]>Close [2]&&
Close [2]>Close [3]&&
Close [3]>Close [4]&&
Close [4]>Close [5])return (true);
else return (false);}
case -1:
{if (Close [1]<Close [2]&&
Close [2]<Close [3]&&
Close [3]<Close [4]&&
Close [4]<Close [5])return (true);
else return (false);}
}
}
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
---