[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 922

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
How can I determine the open order type?
OrderType()
Actually, you should start with a textbook... :) Or at least use F1 in MetaEditor
OP_BUY - buy position,
OP_SELL - sell position,
OP_BUYLIMIT - pending Buy order upon reaching a specified level, the current price is higher than the level,
OP_BUYSTOP - pending Buy order when the specified level is reached, the current price is below the level,
OP_SELLLIMIT - pending sell order when the specified level is reached, current price is below the level,
OP_SELLSTOP - pending sell order when the specified level is reached, current price is above the level.
The order must be pre-selected using the OrderSelect() function.
A floating point value is a real number like double
And instead of digits use a variable of int type
For example int dg=MarketInfo ( Symbol(), MODE_DIGITS);
datetime time;
//--------------------------------------------------------------- 2 --
int start()
{
int Total;
bool
Ans =false, // Ответ сервера после закрытия
Cls_B=false, // Критерий для закрытия Buy
Cls_S=false, // Критерий для закрытия Sell
Opn_B=false, // Критерий для открытия Buy
Opn_S=false; // Критерий для открытия Sell
//--------------------------------------------------------------- 3 --
// Учёт ордеров
for(int i=OrdersTotal()-1;i>=0;i--)
if (OrderSelect(i,SELECT_BY_POS)&&OrderSymbol()==Symbol()&&OrderType()>1)Total++;
if(Total!=0 || time==Time[1])return;
static int KolBars;
if (Close[0]-Open[0] > Point && Close[1]-Open[1] > Point && Bars == KolBars)
{
KolBars=Bars ; // запоминаем кол-во бар при которых совершались действия
}
// Торговые критерии
// Критерий откр. Buy
Opn_B=true;
//--------------------------------------------------------------- 7 --
if (Opn_B)
{OrderSend(Symbol(),OP_BUY,Lot,Ask,0,0,0);time=Time[1];}
}
Please help, I'm asking for the 3rd time. An elementary EA, opens a buy position at the appearance of a new candle (provided the previous 2 candles are green), and closes the position at the close of the candle on which the position was opened, or at the close of the next candle.
The one you see above opens a position every time a new candle appears, without reacting to the opening criteria, but I don't understand how to close the position, I couldn't find it in the tutorial or on the forums.
Floating point value is a real number of double type
And instead of digits use a variable of int type
For example int dg=MarketInfo ( Symbol(), MODE_DIGITS);
They wrote to me: "NormalizeDouble(), check for maximum/minimum lot limit, if five digits - increase stop and profit by 10 times".
The documentation says: "Rounding floating point number to specified precision. The calculated StopLoss and TakeProfit values, as well as opening prices of pending orders must be normalized to the accuracy, the value of which is stored in the predefined variable Digits."
I did not find it in the textbook. I understood that I need to normalize the current price, StopLoss and TakeProfit with NormalizeDouble --- how should I normalize it?
double value -- instead of double value I can use e.g. Prise
int digits -- and this variable dg is equal to MarketInfo( Symbol(), MODE_DIGITS); ???
I was written: "NormalizeDouble(), check for maximum/minimum lot limit, if five digits - increase stop and profit by 10 times".
The documentation says: "Rounding floating point number to specified precision. The calculated StopLoss and TakeProfit values, as well as opening prices of pending orders must be normalized to the accuracy, the value of which is stored in the predefined variable Digits."
I did not find it in the tutorial, I understand I need to normalize the current price, StopLoss and TakeProfit with NormalizeDouble --- if so, how exactly?
double value -- instead of it, I can set e.g. Prise
int digits -- and this variable dg is equal to MarketInfo( Symbol(), MODE_DIGITS); ???
int StopLoss=50; // StopLoss in pips
int TakeProfit=150; // TakeProfit in pips
intOrderDistance=50; // Pending order distance in points
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
int pt=MarketInfo(Symbol(), MODE_POINT); // Point size in the quote currency
int dg=MarketInfo(Symbol(),MODE_DIGITS); // Number of digits after the decimal point in the symbol price
int StLev=MarketInfo(Symbol(),MODE_STOPLEVEL); // Minimum allowed stop loss/stake profit level in points
double pa=MarketInfo(Symbol(), MODE_ASK); // Ask price
double pb=MarketInfo(Symbol(), MODE_BID); // Bid price
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
double slB=NormalizeDouble(pa-StopLoss*pt, dg); // normalize StopLoss price level for Buy position
double tpB=NormalizeDouble(pa+TakeProfit*pt, dg); // normalize TakeProfit price level for Bid position
double slS=NormalizeDouble(pb+StopLoss*pt, dg); // normalizeStopLoss price level for Sell position
double tpS=NormalizeDouble(pb-TakeProfit*pt, dg); // normalize TakeProfit price level for Sell position
doubleB=NormalizeDouble(pa+SetOrderDistance*pt, dg); // normalize price level for placing a Buy pending order
double SetS=NormalizeDouble(pb-SetOrderDistance*pt, dg); // normalize price for placing a Sell pending order
double slBS=NormalizeDouble(SetB-StopLoss*pt, dg); // normalize price level of StopLoss for a pending Buy order
double tpBS=NormalizeDouble(SetB+TakeProfit*pt, dg); // normalize price level of TakeProfit of the pending Buy order
double slSS=NormalizeDouble(SetS+StopLoss*pt, dg); // normalize price level of StopLoss for the pending Sell order
double tpSS=NormalizeDouble(SetS-TakeProfit*pt, dg); // Normalize the price level of TakeProfit of the pending Sell order
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Figure it out... :)
And do not forget about StopLev - int StLev=MarketInfo(Symbol(), MODE_STOPLEVEL);
Check the minimum stop and takeaway distance to make sure it is not less than this value
int StopLoss=50; // StopLoss in points
int TakeProfit=150; // TakeProfit in points
intOrderDistance=50; // Pending order placement distance in points
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
int pt=MarketInfo(Symbol(), MODE_POINT); // Point size in the quote currency
int dg=MarketInfo(Symbol(),MODE_DIGITS); // Number of digits after the decimal point in the symbol price
int StLev=MarketInfo(Symbol(),MODE_STOPLEVEL); // Minimum allowed stop loss/stake profit level in points
double pa=MarketInfo(Symbol(), MODE_ASK); // Ask price
double pb=MarketInfo(Symbol(), MODE_BID); // Bid price
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
double slB=NormalizeDouble(pa-StopLoss*pt, dg); // normalize StopLoss price level for Buy position
double tpB=NormalizeDouble(pa+TakeProfit*pt, dg); // normalize TakeProfit price level for Bid position
double slS=NormalizeDouble(pb+StopLoss*pt, dg); // normalize StopLoss price level for Sell position
double tpS=NormalizeDouble(pb-TakeProfit*pt, dg); // normalize TakeProfit price level for Sell position
doubleB=NormalizeDouble(pa+SetOrderDistance*pt, dg); // normalize price level for placing a Buy pending order
double SetS=NormalizeDouble(pb-SetOrderDistance*pt, dg); // normalize price for placing a Sell pending order
double slBS=NormalizeDouble(SetB-StopLoss*pt, dg); // normalize price level of StopLoss for a pending Buy order
double tpBS=NormalizeDouble(SetB+TakeProfit*pt, dg); // normalize price level of TakeProfit of the pending Buy order
double slSS=NormalizeDouble(SetS+StopLoss*pt, dg); // normalize price level of StopLoss for the pending Sell order
double tpSS=NormalizeDouble(SetS-TakeProfit*pt, dg); // Normalize the price level of TakeProfit of the pending Sell order
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Figure it out... :)
And do not forget about StopLev - int StLev=MarketInfo(Symbol(), MODE_STOPLEVEL);
Check the minimum distance for setting stops and takeaways so that it is not less than this value
Thank you so much!!! I'll look into it! )
Reinstalled Windows. the Alert window has stopped popping up. there is an audible notification, there is a log entry, but the floating window won't pop up.
I cleaned the terminal, recompiled everything. what could be the reason?
How do I create a function and call it?
For the umpteenth time, read a textbook, study the material... :)