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

Morgan  

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
Paladin80  
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.
Morgan  
paladin80:
Give file extension mq4 instead of ex4.


apologies
Files:
[Deleted]  
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?

Alexander  
366366:

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

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.

[Deleted]  
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.
Ilya Malev  
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: