Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 579

 

I'm working on Expert Advisor's code, but I have a problem with lot calculation.

Everything seems to be correct, it works fine in tester, but when I put it on demo account, it opens 2 lots, and then generates error that there is not enough money, and that's it. I tried so many different solutions, I failed to fix the problem. I tried to use my forex robot but I don't know how to use it.

I tried to replace orgynal formula

to

double lots = (AccountBalance()*0.0025*Bid);

But it didn't work.

Files:
lklhykvty2.ex4  18 kb
 
366366:

I'm working on Expert Advisor's code, but I have a problem with lot calculation.

Everything seems to be correct, it works fine in tester, but when I put it on demo account, it opens 2 lots, and then generates error that there is not enough money, and that's it. I tried so many different solutions, I failed to fix the problem. I tried to use my forex robot but I don't know how to use it.

I tried to replace orgynal formula

to

double lots = (AccountBalance()*0.0025*Bid);

But it didn't work.

Give a file with mq4 extension not ex4.
 
paladin80:
Give file extension mq4 instead of ex4.


apologies
Files:
 
AlexeyVik:
I haven't checked it myself, but the reference is https://docs.mql4.com/ru/constants/chartconstants/charts_samples.

Closer to the middle of the page.



Can you please be more specific. Should I put it in the indicator or in the script?

I'm not good at programming. Do I have to type in this function and call it every time?

Here is another question. What should I pass to this function?

 
366366:

извияюсь
double lots = (AccountBalance()*0.0025*Bid);
 

a word of advice,

The Expert Advisor uses several TFs, explicitly prescribed.

One TF is not present in quotes archive (H1),

I test it on 1-minute by open prices

does the tester convert the missing TF by itself?

because the results seem to be the same for all TFs in the quotes history

where can i read about it

 

Help to understand.

When opening orders, TakeProfit =90, StopLoss =30. Orders are closed only by TakeProfit or StopLoss levels. Their value differs by a factor of 3, and in the Strategy Tester report when testing the Expert Advisor, the largest profitable trade = the average profitable trade = the largest losing trade = the average losing trade. Only when I increase TakeProfit and StopLoss ratio the situation changes. I cannot understand why this is so. Help me figure it out.

 
Roger:
double lots = (AccountBalance()*0.0025*Bid);


This is the formula for calculating the lot for the EURUSD pair with a leverage of 1:500.

The original formula was different, but also for 1:500 leverage.

Changed it to my own: double lots = (AccountBalance()*0.0025*Bid);

The problem remained, it also opens 2 lots.

 
hoz:

I don't quite understand the reason for the question. As for the algorithm, that's your choice. As for the code, there is nothing complicated there. The candlesticks have high, low, open and close prices. And when this data is available, you can get any other market data, including Fibo levels, if necessary.

I'm not familiar with Fibonacci, but thank you for the tip on what direction to move in, I've been looking out for highs and lows for a long time.
 
When the EA parameters are changed, the objects/variables are not re-initialised? That is, they were initialised at startup, but when parameters are changed, only OnDeinit is called, then OnInit and nothing else happens?
Reason: