Tan Chee Ho: what if make use of the monthly candle opening. every time new monthly candle created, then take the balance of that point. Will that works?
I am also new to coding MQL4, many to learn. I am not sure this code above will work. but the idea is to update the Account Balance every time new monthly candle created. Please correct me if this code is no good.
the GetInitAccount() function returns the value of the Account on the first day of the month (or
the first day with a tick, when the first day is a Sunday) You should put the return value of the function into a double variable and you can print the value like this:
It is not a good idea to call the GetInitAccount every tick, cause it costs a little bit of performance to open the file and read it. You can use the isNewMonth function form William or you can call the function only, when you open an order.
Second point: At the calculaton of the lot-size you use the AccountBalance() function, whitch returns the current balance and not the Balane at the first day of the month.
the GetInitAccount() function returns the value of the Account on the first day of the month (or
the first day with a tick, when the first day is a Sunday) You should put the return value of the function into a double variable and you can print the value like this:
It is not a good idea to call the GetInitAccount every tick, cause it costs a little bit of performance to open the file and read it. You can use the isNewMonth function form William or you can call the function only, when you open an order.
Second point: At the calculaton of the lot-size you use the AccountBalance() function, whitch returns the current balance and not the Balane at the first day of the month.
Instead of this you could use the GetInitAccount function like this:
the GetInitAccount() function returns the value of the Account on the first day of the month (or
the first day with a tick, when the first day is a Sunday) You should put the return value of the function into a double variable and you can print the value like this:
It is not a good idea to call the GetInitAccount every tick, cause it costs a little bit of performance to open the file and read it. You can use the isNewMonth function form William or you can call the function only, when you open an order.
Second point: At the calculaton of the lot-size you use the AccountBalance() function, whitch returns the current balance and not the Balane at the first day of the month.
Instead of this you could use the GetInitAccount function like this:
the GetInitAccount() function returns the value of the Account on the first day of the month (or
the first day with a tick, when the first day is a Sunday) You should put the return value of the function into a double variable and you can print the value like this:
It is not a good idea to call the GetInitAccount every tick, cause it costs a little bit of performance to open the file and read it. You can use the isNewMonth function form William or you can call the function only, when you open an order.
Second point: At the calculaton of the lot-size you use the AccountBalance() function, whitch returns the current balance and not the Balane at the first day of the month.
Instead of this you could use the GetInitAccount function like this:
I hope, this will help you ...
Best regards,
It works well sir but when I backtest on JANUARY, it can not get the current balance
what if make use of the monthly candle opening. every time new monthly candle created, then take the balance of that point. Will that works?
Hi,
please try my last post (yesterday 16:25) I have tested it and it works really fine in my environment.
Best regards,
Hi there,
i have changed the function for you and now it saves the date of the last update into the file:
I hope, this one works better for you.
Best regards,
I tried but it does not work, I think there is a problem in my code :-(
Hi Steeve,
the GetInitAccount() function returns the value of the Account on the first day of the month (orthe first day with a tick, when the first day is a Sunday) You should put the return value of the function
into a double variable and you can print the value like this:
It is not a good idea to call the GetInitAccount every tick, cause it costs a little bit of performance to
open the file and read it. You can use the isNewMonth function form William or you can call the function
only, when you open an order.
Second point: At the calculaton of the lot-size you use the AccountBalance() function, whitch
returns the current balance and not the Balane at the first day of the month.
Lots=(((AccountBalance() * MaximumRisk / 100) / (StopLoss)));Instead of this you could use the GetInitAccount function like this:
Lots=(((GetInitAccount() * MaximumRisk / 100) / (StopLoss)));I hope, this will help you ...
Best regards,
Hi Steeve,
the GetInitAccount() function returns the value of the Account on the first day of the month (orthe first day with a tick, when the first day is a Sunday) You should put the return value of the function
into a double variable and you can print the value like this:
It is not a good idea to call the GetInitAccount every tick, cause it costs a little bit of performance to
open the file and read it. You can use the isNewMonth function form William or you can call the function
only, when you open an order.
Second point: At the calculaton of the lot-size you use the AccountBalance() function, whitch
returns the current balance and not the Balane at the first day of the month.
Instead of this you could use the GetInitAccount function like this:
I hope, this will help you ...
Best regards,
Lots=(((GetInitAccount() * MaximumRisk / 100) / (StopLoss)));if the "GetInitAccount()" function is called at here, wouldn't it also run this function quite frequently?
Hi Steeve,
in this case the "GetInitAccount()" function is only called before you open an order and that
shouldn't be as often as every tick?
Best regards
Hi Steeve,
in this case the "GetInitAccount()" function is only called before you open an order and that
shouldn't be as often as every tick?
Best regards
thanks
Hi Steeve,
the GetInitAccount() function returns the value of the Account on the first day of the month (orthe first day with a tick, when the first day is a Sunday) You should put the return value of the function
into a double variable and you can print the value like this:
It is not a good idea to call the GetInitAccount every tick, cause it costs a little bit of performance to
open the file and read it. You can use the isNewMonth function form William or you can call the function
only, when you open an order.
Second point: At the calculaton of the lot-size you use the AccountBalance() function, whitch
returns the current balance and not the Balane at the first day of the month.
Instead of this you could use the GetInitAccount function like this:
I hope, this will help you ...
Best regards,
Thanks so much sir It works very well now
Hi Steeve,
the GetInitAccount() function returns the value of the Account on the first day of the month (orthe first day with a tick, when the first day is a Sunday) You should put the return value of the function
into a double variable and you can print the value like this:
It is not a good idea to call the GetInitAccount every tick, cause it costs a little bit of performance to
open the file and read it. You can use the isNewMonth function form William or you can call the function
only, when you open an order.
Second point: At the calculaton of the lot-size you use the AccountBalance() function, whitch
returns the current balance and not the Balane at the first day of the month.
Instead of this you could use the GetInitAccount function like this:
I hope, this will help you ...
Best regards,
It works well sir but when I backtest on JANUARY, it can not get the current balance