Indicator doesn't stick to the chart after MT4 restarts

 

Hi

Background: I developed a custom indicator to calculate the lot size to trade based on my entry price and stop loss price. This indicator worked fine before the major upgrade to the MQL4 language.

Current situation: I can attach the indicator to my chart and it works. When I close MT4 and restart, the indicator unattaches itself from the chart automatically. Previously, it would be attached to the the chart until I remove it or close the chart.

Can someone help me, please? I have attached the indicator.

Files:
ekl_lots.mq4  3 kb
 
I don't know the solution to this, only commenting to confirm that you are correct, although it is random. I had to close and restart a few times before it happened and a second time was able to repeat it by just switching time frames, but not every time.
 
eenewbie:

Hi

Background: I developed a custom indicator to calculate the lot size to trade based on my entry price and stop loss price. This indicator worked fine before the major upgrade to the MQL4 language.

Current situation: I can attach the indicator to my chart and it works. When I close MT4 and restart, the indicator unattaches itself from the chart automatically. Previously, it would be attached to the the chart until I remove it or close the chart.

Can someone help me, please? I have attached the indicator.

Do you have any line printed in the logs relative to your indicator ? (See Experts and Journal tabs).

I got an error "divide by zero" when trying your code, on this line :

   Lots = AccountBalance() * risk / (SLpips * PipValue * 10);