[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 575

 

to Armen

This means that the functions have not been used in the EA. Write something like

if (CountBuys()>2 && CountSells()>2) {\\действия}

 
Can you please tell me if it is possible to withdraw excess funds, for example into a safe deposit box, if they exceed the original deposit while the EA is running and leave them within the original deposit, without closing any open positions?
 
link1:


Vinin, thank you very much for your answer. But i honestly don't understand why ask1,ask2,ask3 are assigned values 1,-1,-1. what do they mean. I'm a beginner, I don't understand it too well. I will be very grateful to you).


They are assigned values that will never be equal to the price.

 
yosuf:
Can I withdraw excess funds, e.g. to the safe deposit box, if they exceed the initial deposit during the EA operation and leave them within the initial deposit without closing the open positions?

On MT5 you can see. Using TesterWithdrawal() to simulate profit withdrawal

This is not possible on MT4

 

Hello!

I am writing an indicator that counts the number of points the price moved up and down during one tick.
What's wrong with the code and where the error is, please advise!

#property indicator_chart_window

extern int LimitBar = 10;
extern int cegl = 6;
extern string Shrift = "Arial Black";
extern bool delete = true;



double old_price, max_price, sum_pip_sell, sum_pip_bay, new_pip_bay, new_pip_sell, old_pip_bay, old_pip_sell;
datetime ctat_SB =0;

int init() {return(0);}

int deinit() {
if (delete == true) {
GetDellName(); 
}
ObjectsDeleteAll(0, OBJ_TREND);
return(0);
}

int start() {
double price;
string name_4,name_b;
int i=0;
int limit, pip; 
double delta; 
int counted_bars=IndicatorCounted(); 
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if(ctat_SB==0) ctat_SB=Time[0];

if(limit>0) limit=0;

for(i=limit; i>=0; i--) {
if(old_price==0) old_price=Close[i];

if(iBarShift(NULL,0,ctat_SB)-iBarShift(NULL,0,Time[i])>=LimitBar) { ' счетчик баров для LimitBar

sum_pip_sell =0;
sum_pip_bay = 0; 
new_pip_bay = 0;
new_pip_sell = 0;
old_pip_bay = 0;
old_pip_sell = 0;

} 

price = Close[i];
if(price > max_price) max_price=price; 

delta = price - old_price; ' разница пунктов
pip = delta*10000; ' округляем до целого

//---- Каунт плюс 

if(delta>=0) { ' условие для ап пунктов

new_pip_bay = pip;
sum_pip_bay = old_pip_bay+new_pip_bay;
old_pip_bay = sum_pip_bay; 

}
//---- Каунт минус
if(delta<0) { ' условие для даун пунктов

new_pip_sell = MathAbs(pip);
sum_pip_sell = old_pip_sell+new_pip_sell;
old_pip_sell = sum_pip_sell;

} 
//----
old_price=price;

//---- размещаем счетчик на графике
name_4 = "TPM_ 4 "+TimeToStr(ctat_SB);
SetText(name_4+"sell",DoubleToStr(sum_pip_sell,0), ctat_SB+60*Period()*2, max_price+(Ask-Bid)*6, Blue,12); 
SetText(name_4+"bay",DoubleToStr(sum_pip_bay,0),ct at_SB-60*Period()*2, max_price+(Ask-Bid)*4.5, Red,12); 

} 

return(0);
}
void SetText(string name,string text,datetime t1, double p1, color c, int size) // --- отображение текста
{
if (ObjectFind(name)!=-1) ObjectDelete(name);
ObjectCreate(name,OBJ_TEXT,0,0,0,0,0); 
ObjectSet(name, OBJPROP_TIME1 , t1);
ObjectSet(name, OBJPROP_PRICE1, p1); 
ObjectSetText(name,text,cegl,Shrift,c);
}

//+------------------------------------------------------------+
void GetDellName (string name_n = "TPM_ ") // -- удаление меток с графика
{
string vName;
for(int i=ObjectsTotal()-1; i>=0;i--)
{
vName = ObjectName(i);
if (StringFind(vName,name_n) !=-1) ObjectDelete(vName);
} 
} 
//----

Thanks in advance!


 
yosuf:
Please tell me if it is possible to withdraw excessive funds, for example, to the safe, if they exceed the initial deposit during the work of the Expert Advisor and leave them within the initial deposit, without closing the open positions?

Only allow the Expert Advisor to trade with a deposit equal to the initial deposit.

Remember the size of the initial deposit and before each opening of a position check its lot. If the deal volume exceeds the permissible value - reduce the lot or release the funds.

 
Fox_RM:

Hello!

I am writing an indicator that counts the number of points the price moved up and down during one tick.
What's wrong with the code and where the error is, please advise!

Thanks in advance!


Why is there so much stuff?

Remember the price of the previous tick. When a new tick arrives, count the price difference divided by the point and remember that price again as the price of the previous tick.

 
artmedia70:

Why is that so much stuff?

Remember the price of the last tick. With the arrival of a new tick, count the price difference divided by the point and remember that price again as the price of the previous tick.

In the conditions for AP and DAUN points the code is exactly as prescribed, but when displaying the indicator on the price chart, the marker outputs 0 for up and 0 for down the number of points. What is the problem I don't understand!
 

Gentlemen programmers!

Does the priority (and associativity) of MQL4 operations correspond to C?

I don't want to abuse parentheses, but the priority of operations is not mentionedanywhere in the documentation.

This is not an idle question. MQL4 is positioned as a C-like language. The key word here is DEFINITELY. If such a thing as a complete calculation of logical expressions is just a departure from the C standard, then visibility of variables defined in a block outside this block is a serious error in programming canons.

Who knows how far the imagination of MQL4 developers could go :).

 
artmedia70:

Only allow the Expert Advisor to trade with a deposit equal to the initial deposit.

Remember the size of the initial deposit and before each opening of a position check its lot. If the volume of the trade exceeds the permissible size - reduce the lot or release the funds.

I mean something like this: when I trade on micro-real with 10k cents deposit, may I withdraw my excess funds manually whenever I want during the EA operation, or do I have to stop the EA, close all open positions and only then withdraw the excess funds? I trade with a fixed lot 0.1. How can I really implement your recommendation: "Allow the Expert Advisor to trade only with the deposit equal to the initial deposit.
Reason: