Price Data Components
Orders Execution
Indicators Used
0
Views
0
Downloads
0
Favorites
Profitability Reports
AUD/USD
Oct 2024 - Jan 2025
14.00 %
Total Trades
4
Won Trades
0
Lost trades
0
Win Rate
0.00 %
Expected payoff
-1223.75
Gross Profit
773.30
Gross Loss
-5668.30
Total Net Profit
-4895.00
-100%
-50%
0%
50%
100%
GBP/USD
Oct 2024 - Jan 2025
0.00 %
Total Trades
3
Won Trades
1
Lost trades
2
Win Rate
0.33 %
Expected payoff
-2846.80
Gross Profit
12.10
Gross Loss
-8552.50
Total Net Profit
-8540.40
-100%
-50%
0%
50%
100%
NZD/USD
Oct 2024 - Jan 2025
8.00 %
Total Trades
3
Won Trades
2
Lost trades
1
Win Rate
0.67 %
Expected payoff
-1691.80
Gross Profit
458.70
Gross Loss
-5534.10
Total Net Profit
-5075.40
-100%
-50%
0%
50%
100%
MA v.3.0. #150 only for EURUSD M1
//+------------------------------------------------------------------+
//| Moving Average.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Moving Average v.3.0. #150 only for EURUSD M1. 08.2006-12.2006"
#property link "http://automated-trading.narod.ru/"
#define MAGICMA 150
//óñòàíîâëåíû ëó÷øåå ïàðàìåòðû ïðè îïòèìèçàöèè
extern double Lots = 0.1; //ñòàíäàðòíûå óñòàíîâêè 0.1
extern double LotMax = 1000; //óñòàíîâêà ìàêñèìàëüíîãî ëîòà
extern double MaximumRisk = 0.105; //ñòàíäàðòíûå óñòàíîâêè 0.02, ðàáîòàåò íîðìàëüíî ïðè 0.2 è 0.5, îñîáåííî ïðè 0.6, íî î÷åíü ðèñêîâàíî
extern double DecreaseFactor = 3; //ñòàíäàðòíûå óñòàíîâêè 3
extern double MovingPeriod = 13; //ñòàíäàðòíûå óñòàíîâêè 12, ðàáîòàåò èíîãäà ëó÷øå íà 13 è îñîáåííî ïðè 1, åñëè MaximumRisk=0.6 íà M5
extern double MovingShift = 15; //ñòàíäàðòíûå óñòàíîâêè 6
extern int MODE_Op_Buy = 1; //Ìåòîä âû÷èñëåíèÿ ñêîëüçÿùåãî ñðåäíåãî (Moving Average)...
extern int MODE_Cl_Buy = 1; //...& 0-MODE_SMA, 1-MODE_EMA, 2-MODE_SMMA, 3-MODE_LWMA...
extern int MODE_Op_Sell = 2; //...& MODE_SMA-Ïðîñòîå ñêîëüçÿùåå ñðåäíåå, MODE_EMA-Ýêñïîíåíöèàëüíîå ñêîëüçÿùåå ñðåäíåå, MODE_SMMA-Ñãëàæåííîå ñêîëüçÿùåå ñðåäíåå, MODE_LWMA-Ëèíåéíî-âçâåøåííîå ñêîëüçÿùåå ñðåäíåå
extern int MODE_Cl_Sell = 0; //---||---...& ---||---
extern int PriceConstantMAofOp_Buy = 0; //Öåíîâûå êîíñòàíòû-öåíà äëÿ ðàñ÷¸òà èíäèêàòîðîâ...
extern int PriceConstantMAofCl_Buy = 0; //...& 0-PRICE_CLOSE, 1-PRICE_OPEN, 2-PRICE_HIGH, 3-PRICE_LOW, 4-PRICE_MEDIAN, 5-PRICE_TYPICAL, 6-PRICE_WEIGHTED
extern int PriceConstantMAofOp_Sell = 0; //...& PRICE_CLOSE-Öåíà çàêðûòèÿ, PRICE_OPEN-Öåíà îòêðûòèÿ, PRICE_HIGH-Ìàêñèìàëüíàÿ öåíà, PRICE_LOW-Ìèíèìàëüíàÿ öåíà, PRICE_MEDIAN-Ñðåäíÿÿ öåíà, (high+low)/2, PRICE_TYPICAL-Òèïè÷íàÿ öåíà, (high+low+close)/3, PRICE_WEIGHTED-Âçâåøåííàÿ öåíà çàêðûòèÿ, (high+low+close+close)/4
extern int PriceConstantMAofCl_Sell = 4; //---||---...& ---||---
extern int Buy = 1; //0-íå îòêðûâàòü ïîçèöèþ Buy (ëþáîå ïîëîæèòåëüíîå ÷èñëî îòêðûâàòü ïîçèöèþ)
extern int Sell = 1; //0-íå îòêðûâàòü ïîçèöèþ Sell (ëþáîå ïîëîæèòåëüíîå ÷èñëî îòêðûâàòü ïîçèöèþ)
extern int MinAccountBalance = 1; //0-ïîçèöèè íå îòêðûâàþòüñÿ è ïðè 0 õîðîøèå ðåçóëüòàòû. Òîëüêî äëÿ áàëàíñà â USD. Îòêðûâàåò ïðîòèâîïîëîæíóþ ïîçèöèþ ïðè êðèòè÷åñêîì çàíà÷åíèè FreeMargin. MinAccountBalance-ýòî çíà÷åíèå FreeMargin ïðè îòêðûòîé ïîçèöèè è ïðîòèâîïîëîæíî îòêðûòîé ïîçèöèè.
extern int VolumeLot = 100000; //Îáúåì ëîòà äëÿ äàííîãî èíñòðóìåíòà â ÷àñòíîñòè EURUSD.
extern int ConsiderPricelosingOrder = 1; //To consider the price of closing of the order-ó÷èòûâàòü öåíó çàêðûòèÿ îðäåðà (0-íå ó÷èòûâàòü, áîëüøå 0-ó÷èòûâàòü)
extern int ToOpenOrdersWithEqualLots = 1; //Îòêðûâàòü îðäåðà ñ ðàâíûìè ëîòàìè
//+------------------------------------------------------------------+
//| Calculate optimal lot size |
//+------------------------------------------------------------------+
double LotsOptimized()
{
double lot=Lots;
int orders=HistoryTotal(); // history orders total
int losses=0; // number of losses orders without a break
//---- select lot size
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//---- calcuulate number of losses orders without a break
if(DecreaseFactor>0)
{
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
//----
if(OrderProfit()>0) break;
if(OrderProfit()<0) losses++;
}
if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
if(lot<0.1) lot=0.1;
}
//---- return lot size
if(lot>LotMax) lot=LotMax;
if(OrderSelect(SELECT_BY_POS,MODE_TRADES)==true)
{
if(ToOpenOrdersWithEqualLots>0 && (OrderLots()>lot || OrderLots()<lot))
{
lot=OrderLots();
}
}
return(lot);
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
double ma;
int res;
double ocp1;
double ocp2;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
//open Sell
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_Op_Sell,PriceConstantMAofOp_Sell,0);
//---- sell conditions
int sells=0;
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
{
if(OrderType()==OP_SELL) sells++;
}
}
//ó÷èòûâàòü öåíó çàêðûòèÿ îðäåðà
if(sells==0)
{
if(OrderSelect(HistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY)==true)
{
ocp2=OrderClosePrice();
}
}
//---- sell conditions
if(((ocp2<=Bid && ConsiderPricelosingOrder>=1)==true && Open[1]>ma && Close[1]<ma && sells<1 && Sell>=1) || (ConsiderPricelosingOrder<=0 && Open[1]>ma && Close[1]<ma && sells<1 && Sell>=1))
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);
return;
}
//open Buy
if(Volume[0]>1) return;
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_Op_Buy,PriceConstantMAofOp_Buy,0);
//---- sell conditions
int buys=0;
//----
for(int i2=0;i2<OrdersTotal();i2++)
{
if(OrderSelect(i2,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
{
if(OrderType()==OP_BUY) buys++;
}
}
//ó÷èòûâàòü öåíó çàêðûòèÿ îðäåðà
if(buys==0)
{
if(OrderSelect(HistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY)==true)
{
ocp1=OrderClosePrice();
}
}
//---- buy conditions
if((((ocp1>=Ask || ocp1==0) && ConsiderPricelosingOrder>=1)==true && Open[1]<ma && Close[1]>ma && buys<1 && Buy>=1) || (ConsiderPricelosingOrder<=0 && Open[1]<ma && Close[1]>ma && buys<1 && Buy>=1))
{
res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,"",MAGICMA,0,Blue);
return;
}
if(MinAccountBalance>0)
{
if(OrderSelect(SELECT_BY_POS,MODE_TRADES)==true)
{
if(sells<1 && OrderType()==OP_BUY==true && OrderType()==OP_SELL==false && Bid*VolumeLot/AccountLeverage()*OrderLots()+MinAccountBalance>=AccountFreeMargin())
{
OrderSend(Symbol(),OP_SELL,OrderLots(),Bid,3,0,0,"",MAGICMA,0,DarkOrchid);
Print("Sell ïðè êðèòè÷åñêîì çàíà÷åíèè FreeMargin ðàâíîì ",AccountFreeMargin(),", # ",MAGICMA,", Ticket# ",OrderTicket());
}
}
if(OrderSelect(SELECT_BY_POS,MODE_TRADES)==true)
{
if(buys<1 && OrderType()==OP_BUY==false && OrderType()==OP_SELL==true && Ask*VolumeLot/AccountLeverage()*OrderLots()+MinAccountBalance>=AccountFreeMargin())
{
OrderSend(Symbol(),OP_BUY,OrderLots(),Ask,3,0,0,"",MAGICMA,0,Orange);
Print("Buy ïðè êðèòè÷åñêîì çàíà÷åíèè FreeMargin ðàâíîì ",AccountFreeMargin(),", # ",MAGICMA,", Ticket# ",OrderTicket());
}
}
}
//----
}
//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose()
{
//Close Buy
double ma;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_Cl_Buy,PriceConstantMAofCl_Buy,0);
//----
for(int i2=0;i2<OrdersTotal();i2++)
{
if(OrderSelect(i2,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//---- check order type
if(OrderType()==OP_BUY)
{
int Fa1;
while(Fa1<1)
{
if (Open[1]>ma && Close[1]<ma && OrderProfit()>=0) OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
}
}
//Close Sell
if(Volume[0]>1) return;
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_Cl_Sell,PriceConstantMAofCl_Sell,0);
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//---- check order type
if(OrderType()==OP_SELL)
{
int Fa2;
while(Fa2<1)
{
if (Open[1]<ma && Close[1]>ma && OrderProfit()>=0) OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
break;
}
}
}
//----
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;
CheckForOpen();
CheckForClose();
//----
}
//+------------------------------------------------------------------+
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
---