I'll say the same thing. You are not good at logic. What is the problem to immediately calculate the initial lot, based on available funds and the value of risk (I think it was written about 3%)? Why do you have to do everything in one place?
Take the value of the free margin, multiply by the risk, divide by 100 and the value of the margin for 1 lot - here is the simplest formula for calculating the lot with a specified percentage of the free margin. Also, you need to take into account the step of lot change and prevent exceeding the min/max lot size, permitted by brokerage company:
I told you that the EA trades in a small interval of time in which there is a probability that 9 consecutive opposite orders overlapping each other will open and each next order is multiplied by 2, so the margin may not hold and the last pending order may not open, and therefore we have to calculate from the last maximum possible lot. I figured the best number of orders in 5-10 min interval is 9. In general I need to calculate a margin in case all the orders will be opened and on the basis of these data in reverse order to calculate the first lot.
Where did I spell it wrong? I think I took it from an example, could you please tell me how to spell it correctly so the order would close
on reverse buy conditions? I'm racking my brains.
If the order is selected on the ticket, you don't need an action in the loop. If you wantto correct the code, use the SRC button topaste the code into the message.
#property copyright"Copyright 2017, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"#property strict//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+int ticketB,ticketS;
voidOnTick()
//------------------------------------------------------------------------------------------------
{
double p = iClose("EURUSD",PERIOD_M15,0); //показание текущей цены double r = iRSI ("EURUSD",PERIOD_M15,21,PRICE_CLOSE,0); //значение индюка RSIdouble m = iMA ("EURUSD",PERIOD_M15,89,0,MODE_EMA,PRICE_CLOSE,0); //значение индюка МАint OrderCount = 1;
//---------------ПОДСЧЕТ ОРДЕРОВ------------------------------------------------------------------if(OrdersTotal() >= OrderCount)
{
return;
}
//-------------ОТКРЫТИЕ ОРДЕРА НА ПОКУПКУ--------------------------------------------------------------------/*if(r > 50 && p > m) //условия открытия ордера на покупку
{
ticketB = OrderSend(Symbol(),OP_BUY,0.1,Ask,5,0,0,"",111,0,Green);
}
//------------ЗАКРЫТИЕ ОРДЕРА НА ПРОДАЖУ--------------------------------------------------------
if(r<50 && p<m)
{
for(int i=1; i<=OrdersTotal(); i++)
{
if(OrderSelect(ticketB,SELECT_BY_TICKET)==true)
{
if(OrderType()==OP_BUY)
{
ticketB = OrderClose(OrderTicket(),0.1,Bid,5,Red);
}
}
}
}*///------------------ОТКРЫТИЕ ОРДЕРА НА ПРОДАЖУ---------------------------------------------------------if(r < 50 && p < m) //условия открытия ордера на продажу
{
ticketS = OrderSend(Symbol(),OP_SELL,0.1,Bid,5,0,0,"",111,0,Blue);
}
//---------------------ЗАКРЫТИЕ ОРДЕРА НА ПРОДАЖУ---------------------------------------------------------if(r>50 && p>m)
{
for(int i=1; i<=OrdersTotal(); i++)
{
if(OrderSelect(ticketS,SELECT_BY_TICKET)==true)
{
if(OrderType()==OP_SELL)
{
ticketS = OrderClose(OrderTicket(),0.1,Ask,5,Red);
}
}
}
}
}
//+------------------------------------------------------------------+
Thanks for the SRC), this is what it looks like, ts looks like this, sell should happen when candle closed below the wop and rsi below 50, and close the order at opposite conditions, and simultaneously after close buy should happen and after close, then one order and no more and so on cyclically ... but now I have one order open and that's it, and stops are not working ...
funnyrain8: Thanks for the SRC), this is what it looks like, ts looks like this, sell should happen when candle closed below the wrist and rsi below 50, and close the order at the opposite conditions, and at the same time after closing should happen buying and after closing, then one order and no more and so on cyclically ... but now I open one order and all, and stops do not work ...
I have rewritten it in my own style, I hope you understand, if something is unclear, do not hesitate to ask
rewritten in my own style, hope you understand, if you don't understand anything ask
...
oh, i thought i wrote almost everything except the closing and i still have a lot to learn...thanks a lot now at least i have an example to go on from...tin, thanks again)
Hello. I have downloaded Metatrader 5 software. I signed up for 2 signals. My account balance is positive 20$. I am trying to install virtual hosting and nothing works. I press navigator, connect to trading account, I even have no such tab in the table virtual hosting. I am sending you screenshots. How do I connect to the shared hosting?
Жанна Платонова: Hello. I have downloaded Metatrader 5 software. I signed up for 2 signals. My account balance is positive 20$. I am trying to install virtual hosting and nothing works. I press navigator, connect to trading account, I even have no such tab in the table virtual hosting. I am sending you screenshots. How do I connect to the shared hosting?
Hello. I have a question - on the mac (sierra) in all delivered (through wine) from different companies platforms mt4 the same glitch - the terminal if you release it from its normal place at the bottom to move it as a free window - it shrinks and work through it is completely impossible. Disabling the auto-arranger does not work. To return the terminal on the former place absolutely impossible - i.e. it simply does not attach and does not open any more. I have a question - can anyone know a shortcut or button to return the entire interface to its original place. Sincerely.
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.
I'll say the same thing. You are not good at logic. What is the problem to immediately calculate the initial lot, based on available funds and the value of risk (I think it was written about 3%)? Why do you have to do everything in one place?
Take the value of the free margin, multiply by the risk, divide by 100 and the value of the margin for 1 lot - here is the simplest formula for calculating the lot with a specified percentage of the free margin. Also, you need to take into account the step of lot change and prevent exceeding the min/max lot size, permitted by brokerage company:
I told you that the EA trades in a small interval of time in which there is a probability that 9 consecutive opposite orders overlapping each other will open and each next order is multiplied by 2, so the margin may not hold and the last pending order may not open, and therefore we have to calculate from the last maximum possible lot. I figured the best number of orders in 5-10 min interval is 9. In general I need to calculate a margin in case all the orders will be opened and on the basis of these data in reverse order to calculate the first lot.
}
Where did I spell it wrong? I think I took it from an example, could you please tell me how to spell it correctly so the order would close
on reverse buy conditions? I'm racking my brains.
}
Where did I spell it wrong? I think I took it from an example, could you please tell me how to spell it correctly so the order would close
on reverse buy conditions? I'm racking my brains.
Like this
}
Where did I spell it wrong? I think I took it from an example, could you please tell me how to spell it correctly so the order would close
on reverse buy conditions? I'm racking my brains.
If the order is selected on the ticket, you don't need an action in the loop. If you wantto correct the code, use the SRC button topaste the code into the message.
Thanks for the SRC), this is what it looks like, ts looks like this, sell should happen when candle closed below the wrist and rsi below 50, and close the order at the opposite conditions, and at the same time after closing should happen buying and after closing, then one order and no more and so on cyclically ... but now I open one order and all, and stops do not work ...
I have rewritten it in my own style, I hope you understand, if something is unclear, do not hesitate to ask
...
rewritten in my own style, hope you understand, if you don't understand anything ask
...
oh, i thought i wrote almost everything except the closing and i still have a lot to learn...thanks a lot now at least i have an example to go on from...tin, thanks again)
Hello. I have downloaded Metatrader 5 software. I signed up for 2 signals. My account balance is positive 20$. I am trying to install virtual hosting and nothing works. I press navigator, connect to trading account, I even have no such tab in the table virtual hosting. I am sending you screenshots. How do I connect to the shared hosting?
Click help in the main menu.