if (MA5>MA20)
{
Signal=1;
}
if(Signal>TradeLevel) // TradeLevel установлен в 0.
{
ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Ask-SL*Point,Bid+TP*Point,"Optim",16384,0,Blue);
}
Please advise why this logic does not work? (mql4) The trades do not open
(everything else, variables, everything is described - standard owl template in MT, no compilation errors)
So is the logic not working or are the EA positions not opening?
It is a good habit to look at the "Experts" magazine first - there is a lot to write about. And I would also like to check the "Journal".
templ(T)class CData{
public:CData(){};~CData(){};
T Total(T &mas[] ,int y){return(ArraySize(mas));}
T Total(T &mas[][],int y){return(ArraySize(mas));}}
Question how to callTotal() function, I want to call it for example in OnInit(), guys please don't be rude, I'm a jackass, I don't understand the help? Do I need to delete the memory of the class, and if so, where and how?
TASK: Calculate the lot size for an allowable risk per trade of $250 for any instrument (including forex, mullions, CFDs).
MY REALIZATION (for BUY, snippet of function code):
//valSL - размер стопа//price - цена открытия ордера//iLots - размер лота
SL_punkt=(price-valSL)/MarketInfo(currencySelect,MODE_POINT); //Переводим денежное выражение в пунктыdouble pricePunkt=NormalizeDouble(iLots*MarketInfo(symb,MODE_TICKVALUE)*SL_punkt,MarketInfo(symb,MODE_DIGITS)); //Вычисляем уровень убытка при заданном размере лота
THE PROBLEM: This code correctly calculates losses for all assets, including currency pairs (including crosses), gold, oil, BUT INDEXes, nq100, EXAMPLE,DOES NOT CALCULATE correctly. Namely, my script data (potential deal losses) is consistently 10 times LESS THAN what the MT4 STRATEGY Tester reads!
SOME NOTES:
1. testing was conducted in Alpari terminal.
2. According to the terminal, the way of profit calculation for XAUUSD, BRN (oil) and NQ100 is "CFD", for currency pairs, respectively, "forex".
I think the problem is in the contract size, which I do not take into account (for oil - 1000, for XAUUSD - 100, for NQ100 - 10). But then why XAUUSD, BRN are counting correctly (and currency pairs too), but NQ100 isn't? Maybe, in spite of the fact that in the properties of the Alpari terminal symbol the profit calculation method is "CFD", but in reality it is counted as "Forex"? Is this even possible?
In general, I would appreciate it if somebody would explain me my script error and how to fix it.
This does not solve the problem, unfortunately. I have
MODE_TICKVALUE равно MODE_POINT и равно MODE_TICKSIZE (для NQ100 это 0.1)
Tried also this variant of code:
double StoimPunkt(string B){
double S = MarketInfo(B,MODE_TICKVALUE)/(MarketInfo(B,MODE_TICKSIZE)/MarketInfo(B,MODE_POINT));return(S);
}
//valSL - размер стопа//price - цена открытия ордера//iLots - размер лота
SL_punkt=(price-valSL)/MarketInfo(symb,MODE_POINT); //Переводим денежное выражение в пунктыdouble pricePunkt=NormalizeDouble(iLots*StoimPunkt(symb)*SL_punkt,MarketInfo(symb,MODE_DIGITS)); //Вычисляем уровень убытка при заданном размере лота
THE RESULT IS EXACTLY THE SAME AS IN MY EXAMPLE ABOVE.
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.
Why is the last line without a slash, and is it possible to return a value from a macro
this is macro substitution syntax, string gluing
here is an example of how to return a valuehttps://www.mql5.com/ru/forum/318246/page10#comment_12652228
Please, can someone help me?
Can you please tell me why this logic doesn't work? (mql4)
Deals do not open
Please advise why this logic does not work? (mql4)
The trades do not open
So is the logic not working or are the EA positions not opening?
It is a good habit to look at the "Experts" magazine first - there is a lot to write about. And I would also like to check the "Journal".
I see exactly two errors and one uncertainty when sending a trade request.
So is the logic not working or are the EA positions not opening?
It is a good habit to look at the "Experts" magazine first - there is a lot to write about. And it does not hurt to look at the "Journal" too.
Just off the top of my head, I see exactly two errors and one uncertainty when sending a trade request.
Thank you, it's working!
Just re-flipped this logic into the standard MACD EA.
Just needed a base to deploy different signals and summarise them.
Apologies for the hassle. (log was empty by the way, no errors either, just didn't open trades and that's it).
If you don't mind, please still point out the error
There is a primitive code
Question how to callTotal() function, I want to call it for example in OnInit(), guys please don't be rude, I'm a jackass, I don't understand the help? Do I need to delete the memory of the class, and if so, where and how?
GLITCH WHEN CALCULATING RISK PER TRADE.
TASK: Calculate the lot size for an allowable risk per trade of $250 for any instrument (including forex, mullions, CFDs).
MY REALIZATION (for BUY, snippet of function code):
THE PROBLEM: This code correctly calculates losses for all assets, including currency pairs (including crosses), gold, oil, BUT INDEXes, nq100, EXAMPLE,DOES NOT CALCULATE correctly. Namely, my script data (potential deal losses) is consistently 10 times LESS THAN what the MT4 STRATEGY Tester reads!
SOME NOTES:
1. testing was conducted in Alpari terminal.
2. According to the terminal, the way of profit calculation for XAUUSD, BRN (oil) and NQ100 is "CFD", for currency pairs, respectively, "forex".
I think the problem is in the contract size, which I do not take into account (for oil - 1000, for XAUUSD - 100, for NQ100 - 10). But then why XAUUSD, BRN are counting correctly (and currency pairs too), but NQ100 isn't? Maybe, in spite of the fact that in the properties of the Alpari terminal symbol the profit calculation method is "CFD", but in reality it is counted as "Forex"? Is this even possible?
In general, I would appreciate it if somebody would explain me my script error and how to fix it.
THANK YOU!
GLITCH WHEN CALCULATING THE RISK PER TRANSACTION.
MODE _TICKSIZE
GLITCH IN CALCULATION OF RISK PER TRADE.
MODE _TICKSIZE
Read xxxxxxxx
This does not solve the problem, unfortunately. I have
Tried also this variant of code:
THE RESULT IS EXACTLY THE SAME AS IN MY EXAMPLE ABOVE.
Any other ideas?