Price Data Components
Orders Execution
Indicators Used
0
Views
0
Downloads
0
Favorites
Profitability Reports
GBP/USD
Oct 2024 - Jan 2025
0.00 %
Total Trades
0
Won Trades
0
Lost trades
0
Win Rate
0.0 %
Expected payoff
0.00
Gross Profit
0.00
Gross Loss
0.00
Total Net Profit
0.00
-100%
-50%
0%
50%
100%
20PRExp-3
//+------------------------------------------------------------------+
//| 20PRExp-3.mq4 |
//| Copyright © 2005-2007, Ñåðãåé (Sergey2005TR) |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#define MAGIC 20051214
// Âíåøíèå ïàðàìåòðû ñîâåòíèêà
extern string _Parameters_Trade = "----- Ïàðàìåòðû òîðãîâëè";
extern int TakeProfit = 20; // Ðàçìåð ôèêñèðîâàííîãî òýéêà
extern int TrailingStop = 10;
extern double ExtMaximumRisk = 0.05;
extern double Lots = 0.1; // Ðàçìåð òîðãóåìîãî ëîòà
extern string _Parameters_Expert = "----- Ïàðàìåòðû ñîâåòíèêà";
extern int zazor = 50;
extern color clOpenBuy = LightBlue; // Öâåò îòêðûòèÿ ïîêóïêè
extern color clOpenSell = LightCoral; // Öâåò îòêðûòèÿ ïðîäàæè
extern color clModifyBuy = Aqua; // Öâåò ìîäèôèêàöèè ïîêóïêè
extern color clModifySell = Tomato; // Öâåò ìîäèôèêàöèè ïðîäàæè
extern color clCloseBuy = Blue; // Öâåò çàêðûòèÿ ïîêóïêè
extern color clCloseSell = Red; // Öâåò çàêðûòèÿ ïðîäàæè
// Ãëîáàëüíûå ïåðåìåííûå ñîâåòíèêà
bool ft = true;
int total = 0;
double MidL = 0, MLP = 0, MLM = 0;
double canal;
int cnt;
string dw = " ";
// Ïîäêëþ÷åíèå âíåøíåãî ìîäóëÿ
#include <stdlib.mqh>
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
void start()
{
if((Hour()>6))
{
MLP = iHigh(NULL, PERIOD_D1, 0);
MLM = iLow(NULL, PERIOD_D1, 0);
MidL = NormalizeDouble((MLP + MLM) / 2, 4);
MoveHLine("MidL", Time[0], MidL, Time[0], MidL, Gold, 1, STYLE_DOT);
MoveHLine("MLP", Time[0], MLP, Time[0], MLP, Lime, 1, STYLE_DOT);
MoveHLine("MLM", Time[0], MLM, Time[0], MLM, Magenta, 1, STYLE_DOT);
canal=MathRound((MLP-MLM)/Point);
ft=true;
}
if(DayOfWeek() == 1)
dw = "Ïîíåäåëüíèê";
if(DayOfWeek() == 2)
dw = "Âòîðíèê";
if(DayOfWeek() == 3)
dw = "Ñðåäà";
if(DayOfWeek() == 4)
dw = "×åòâåðã";
if(DayOfWeek() == 5)
dw = "Ïÿòíèöà";
Comment("Data: ", Year(), ".", Month(), ".", Day(), " Day=", dw,
" Time ", Hour(), ":", Minute(), "\n", " Min=", MLM, " Max=",
MLP, " Pivot=", MidL);
OpenPosition(); //}
for(cnt = 0; cnt < OrdersTotal(); cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol())
{
if(OrderType() == OP_BUY) // long position is opened
{
if(iSAR(NULL, PERIOD_M5, 0.005, 0.01, 0) > Close[1])
{
// close position
OrderClose(OrderTicket(), OrderLots(), Bid, 3, Violet);
return(0); // exit
}// check for trailing stop
if(TrailingStop > 0)
{
if(Bid - OrderOpenPrice() > Point*TrailingStop)
{
if(OrderStopLoss() < Bid - Point*TrailingStop)
{
OrderModify(OrderTicket(), OrderOpenPrice(),
Bid - Point*TrailingStop,
Bid + Point*TrailingStop, 0, Green);
return(0);
}
}
}
}
else // go to short position
{
if(iSAR(NULL, PERIOD_M5, 0.005, 0.01, 0) < Close[1])
{
// close position
OrderClose(OrderTicket(), OrderLots(), Ask, 3, Lime);
return(0); // exit
}
// check for trailing stop
if(TrailingStop > 0)
{
if((OrderOpenPrice() - Ask) > (Point*TrailingStop))
{
if((OrderStopLoss() > (Ask+Point*TrailingStop)) ||
(OrderStopLoss() == 0))
{
OrderModify(OrderTicket(), OrderOpenPrice(),
Ask + Point*TrailingStop,
Ask - Point*TrailingStop, 0, Red);
return(0);
}
}
}
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Ôóíêöèè |
//+------------------------------------------------------------------+
void MoveHLine(string name, datetime time, double price, datetime time1,
double price1, int objcolor, int width, int style)
{
if(ObjectFind(name)==-1)
{
ObjectCreate(name, OBJ_HLINE, 0, time,price);
ObjectSet(name, OBJPROP_COLOR, objcolor);
ObjectSet(name, OBJPROP_WIDTH, width);
ObjectSet(name, OBJPROP_STYLE, style);
}
else
{
ObjectMove(name, 1, time1, price1);
}
}
//+------------------------------------------------------------------+
//| Îòêðûòèå ïîçèöèè |
//+------------------------------------------------------------------+
void OpenPosition()
{
double ldStop = 0, ldTake = 0;
int bs = GetTradeSignal();
for(cnt = OrdersTotal() - 1; cnt >= 0; cnt--)
{
OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol() != Symbol())
continue;
if(OrderType() == OP_BUY )
total++;
if(OrderType() == OP_SELL )
total++;
}
if(total < 1 &&Hour() > 6)
{
if(bs > 0)
{
if(TakeProfit != 0)
ldTake = Ask + TakeProfit*Point;
OrderSend(Symbol(), OP_BUY, Lots() ,Ask, 3, MLM, ldTake,
"Pipsover", 888, 0, Blue);
}
if(bs < 0)
{
if(TakeProfit != 0)
ldTake = Bid - TakeProfit*Point;
OrderSend(Symbol(), OP_SELL, Lots() ,Bid, 3, MLP,ldTake,
"Pipsover", 888, 0, Red);
}
}
total = 0;
}
//+------------------------------------------------------------------+
//| Âîçâðàùàåò òîðãîâûé ñèãíàë: |
//| 1 - ïîêóïàé |
//| 0 - ñèäè, êóðè áàìáóê |
//| -1 - ïðîäàâàé |
//+------------------------------------------------------------------+
int GetTradeSignal()
{
double spread = (Ask - Bid);
double vVolume = iVolume(NULL, PERIOD_M30, 0);
double pVolume = iVolume(NULL, PERIOD_M30, 1);
if( total < 1)
{
if(Bid - (spread) < MLM && (vVolume / pVolume) > 1.5 && canal > zazor)
{
return(-1);
}
if(Ask > MLP && (vVolume / pVolume) > 1.5 && canal > zazor)
{
return(1);
}
}
return(0);
}
//+------------------------------------------------------------------+
//| Îáüåì ëîòà |
//+------------------------------------------------------------------+
double Lots()
//--- extern variables
// 5% by default
{
double lot_min = MarketInfo(Symbol(), MODE_MINLOT);
double lot_max = MarketInfo(Symbol(), MODE_MAXLOT);
double lot_step= MarketInfo(Symbol(), MODE_LOTSTEP);
double contract= MarketInfo(Symbol(), MODE_LOTSIZE);
double vol;
//--- check data
if(lot_min < 0 || lot_max <= 0.0 || lot_step <= 0.0)
{
Print("CalculateVolume: invalid MarketInfo() results [", lot_min,
",", lot_max, ",", lot_step, "]");
return(0);
}
if(AccountLeverage() <= 0)
{
Print("CalculateVolume: invalid AccountLeverage() [", AccountLeverage(), "]");
return(0);
}
//--- basic formula
vol = NormalizeDouble(AccountFreeMargin()*ExtMaximumRisk*AccountLeverage() /
contract, 2);
//--- additional calculation
// ...
//--- check min, max and step
vol = NormalizeDouble(vol / lot_step, 0)*lot_step;
if(vol < lot_min)
vol = lot_min;
if(vol > lot_max)
vol = lot_max;
//---
return(vol);
}
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectsDeleteAll(WindowOnDropped());
//----
return(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
---