Orders Execution
Miscellaneous
0
Views
0
Downloads
0
Favorites
MoneyManagement_v1_1
//+------------------------------------------------------------------+
//| Money Management.mq4 |
//| iPhoks |
//| |
//+------------------------------------------------------------------+
#property copyright "iPhoks 2012"
#property link "ÖÖÖ.Gdetovseti.sru :D"
#property indicator_chart_window
extern int Percent2=2; //Îïðåäåëÿåìûé ðèñê ïðè êàæäîé ñäåëêå
extern int Percent6=6; //Îáùèé ìåñÿ÷íûé ðèñê ïî äåïîçèòó
extern double Lot=0.01; //Îáúåì, êîòîðûì îñóùåñòâëÿåòñÿ èëè ïëàíèðóåòñÿ òîðãîâëÿ
extern color UpKeepLine=White; //Öâåò âåðõíåé çàïðåòíîé ëèíèè
extern color DownKeepLine=White; //Öâåò íèæíåé çàïðåòíîé ëèíèè
extern int DrawType=4; //Òèï îòîáðàæåíèÿ ëèíèé
extern bool CountingByOrder=false; //false-ðàñ÷åò Percent2 ïî îòíàøåíèþ ê Bid, true-îíîñèòåëüíî çàäàííîé öåíû
extern double CountingPrice=0; //Öåíà äëÿ ðàñ÷åòà Percent2 ïðè CountingByOrder=true
extern double BeginningDeposit=0; //Íà÷àëüíûé äåïîçèò, åñëè íîëü ïðèìåò çà íà÷àëüíûé òåêóùèèé äåïîçèò
extern bool CurrentRiskOption=false;
double PUp,PDown;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("PUp");
ObjectDelete("PDown");
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
if (AccountBalance()>BeginningDeposit) BeginningDeposit=AccountBalance();
double P6=(BeginningDeposit*Percent6/100)-(BeginningDeposit-AccountBalance());
double PricePips=MarketInfo(Symbol(),MODE_TICKVALUE);
double SumProfit=0;
if (CurrentRiskOption==true)
{
if (OrdersTotal()>0)
{
for (int i=1; i<=OrdersTotal();i++)
{
OrderSelect(i-1,SELECT_BY_POS);
SumProfit=SumProfit+(OrderProfit()+OrderCommission()+OrderSwap());
}
double CurrentRisk=SumProfit*100/AccountBalance();
string FR="Current Risk = "+DoubleToStr(CurrentRisk,3)+"%";
}
else
FR="Current Risk = 0%";
}
else
FR="Full Risk Option - Off";
Comment("1 Pips Price = "+DoubleToStr(PricePips*Lot,2)+"$"
+"\n"+"Rezerve of 6% = "+DoubleToStr(P6,2)+"$"
+"\n"+"Current Lot = "+DoubleToStr(Lot,2)
+"\n"+FR);
if (CountingByOrder==false)
{
PUp=Bid+((AccountFreeMargin()*Percent2/100)/(PricePips*Lot)*Point);
PDown=Ask-((AccountFreeMargin()*Percent2/100)/(PricePips*Lot)*Point);
}
else
{
PUp=CountingPrice+((AccountFreeMargin()*Percent2/100)/(PricePips*Lot)*Point);
PDown=CountingPrice-((AccountFreeMargin()*Percent2/100)/(PricePips*Lot)*Point);
}
ObjectCreate("PUp",OBJ_HLINE,0,0,PUp);
ObjectSet("PUp",OBJPROP_PRICE1,PUp);
ObjectSet("PUp",OBJPROP_COLOR,UpKeepLine);
ObjectSet("PUp",OBJPROP_STYLE,DrawType);
ObjectCreate("PDown",OBJ_HLINE,0,0,PDown);
ObjectSet("PDown",OBJPROP_PRICE1,PDown);
ObjectSet("PDown",OBJPROP_COLOR,DownKeepLine);
ObjectSet("PDown",OBJPROP_STYLE,DrawType);
if (P6<=0) Alert("Loss more than 6%");
//----
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
---