//+------------------------------------------------------------------+//| Enum Lor or Risk |//+------------------------------------------------------------------+enum ENUM_LOT_OR_RISK
{
lots=0, // Constant lot
risk=1, // Risk in percent
};
//+------------------------------------------------------------------+
inputdouble MaximumRisk = 0.01; // Maximum Risk in percentageinputdouble DecreaseFactor = 3; // Descrease factorinput ENUM_LOT_OR_RISK InpLotOrRisk = lots; // Money management: Lot OR Risk
//+------------------------------------------------------------------+//| Calculate optimal lot size |//+------------------------------------------------------------------+double TradeSizeOptimized(void)
{
double price=0.0;
double margin=0.0;
//--- select lot sizeif(!SymbolInfoDouble(_Symbol,SYMBOL_ASK,price))
return(0.0);
if(!OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,1.0,price,margin))
return(0.0);
if(margin<=0.0)
return(0.0);
double lot=0;
//---switch(InpLotOrRisk)
{
case lots:
lot=MaximumRisk;
break;
case risk:
lot=NormalizeDouble(AccountInfoDouble(ACCOUNT_MARGIN_FREE)*MaximumRisk/margin,2);
default:
break;
}
//--- calculate number of losses orders without a breakif(DecreaseFactor>0)
{
//--- select history for accessHistorySelect(0,TimeCurrent());
//---int orders=HistoryDealsTotal(); // total history dealsint losses=0; // number of losses orders without a breakfor(int i=orders-1; i>=0; i--)
{
ulong ticket=HistoryDealGetTicket(i);
if(ticket==0)
{
Print("HistoryDealGetTicket failed, no trade history");
break;
}
//--- check symbolif(HistoryDealGetString(ticket,DEAL_SYMBOL)!=_Symbol)
continue;
//--- check Expert Magic numberif(HistoryDealGetInteger(ticket,DEAL_MAGIC)!=Magic_Number)
continue;
//--- check profitdouble profit=HistoryDealGetDouble(ticket,DEAL_PROFIT);
if(profit>0.0)
break;
if(profit<0.0)
losses++;
}
//---if(losses>1)
lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
}
//--- normalize and check limitsdouble stepvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
lot=stepvol*NormalizeDouble(lot/stepvol,0);
double minvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
if(lot<minvol)
lot=minvol;
double maxvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
if(lot>maxvol)
lot=maxvol;
//--- return trading volumereturn(lot);
}
//+------------------------------------------------------------------+
where lot - insertTradeSizeOptimized()
I need to correct it in Expert Advisor - otherwise it is not correct there
1 possibility : line 1 will open line 4 at a given distance, line 2 will open line 3 at a given distance.
2nd possibility: line 7 will open a line 10 at a given distance, which moves behind the price and when the price touches it, a command will trigger. line 8 will open a line 9 at a given distance, - the same action as for 7 and 10.
#property version "1.01"
There is another option -line 1 will open 4 and 9.line 2 will open 3 and 10.
line 7 will open 10 and 3 .line 8 will open 9 and4
It turned out to be another possibility -line 1 will open 4 and 9. line 2 will open 3 and 10.
line 7 will open 10 and 3 . line 8 will open 9 and 4
to open the positions in reverse and do not touch the settingsObj: command:
there is a reversal -
i have now started the test - i will not do anything till the end of the month, i wonder what will happen. - lot, i have set it to risk - it will somehow calculate
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
figured out how to correctly prescribe the risk
where lot - insertTradeSizeOptimized()
I need to correct it in Expert Advisor - otherwise it is not correct there
renamed - expert completed. all errors corrected. Title < Horse move ><Horse move
Added to the previous Expert, two methods for the Horizontal line.
1 possibility : line 1 will open line 4 at a given distance, line 2 will open line 3 at a given distance.
2nd possibility: line 7 will open a line 10 at a given distance, which moves behind the price and when the price touches it, a command will trigger. line 8 will open a line 9 at a given distance, - the same action as for 7 and 10.
#property version "1.01"
There is another option -line 1 will open 4 and 9.line 2 will open 3 and 10.
line 7 will open 10 and 3 .line 8 will open 9 and4
to open the positions on the reverse and do not touch the settingsObj: command:
there is a reversal -
#property version "1.01"
It turned out to be another possibility -line 1 will open 4 and 9. line 2 will open 3 and 10.
line 7 will open 10 and 3 . line 8 will open 9 and 4
to open the positions in reverse and do not touch the settingsObj: command:
there is a reversal -
i have now started the test - i will not do anything till the end of the month, i wonder what will happen. - lot, i have set it to risk - it will somehow calculate
Not bad! Slowly - but it's getting better
Yes! It's going straight to the top.
renamed - expert completed. all errors corrected. Title < Horse move ><Horse move
Interesting Expert Advisor.
setinput double TargetProfit = 30000.00;// Target profit
probably not enough - should have been more. now we need to wait again, entry points and set the TargetProfit = 35000.00;// Target Profit
opens positions from the indicator pivot lines timezone.mq5 from the line R2 - down S2 - up
the indicator may not be deleted - its lines are updated the next day
the indicator is below - now I will search the website for the link to the indicatorhttps://www.mql5.com/ru/code/1114
setinput double TargetProfit = 30000.00; // Target profit
probably not enough - should have been more. now we need to wait again, entry points and set the TargetProfit = 35000.00; // Target Profit
opens positions from the indicator pivot lines timezone.mq5 from the line R2 - down S2 - up
the indicator may not be deleted - its lines are updated the next day
the indicator below - now searching on the website for the link to the indicatorhttps://www.mql5.com/ru/code/1114
this is one of the options. but there are a million options
I forgot to say about the lot - set to risk input ENUM_LOT_OR_RISK InpLotOrRisk = lots;// Money management: Lot OR Risk
(expert information in .log) which warnings are issued https://www.mql5.com/ru/docs/event_handlers/ondeinit#property version "1.02"
found another way for the buttons
here we select
on position opening - stop loss is set immediately (yellow horizontal line)
adjusted here -input double InpStopLoss = 55;// Obj: Stop Loss, in pips (1.00045-1.00055=1 pips)
deactivate set 0