Can any one guide me to the right path
my idea is that if was loss last day than my lotsize for today trade must be increase.But i am not understanding that where should i place those two variables to get account balance and check that. Can any one guide me to the right path
You don' have to store those variables because each Order already provides information about its own Profit or Loss. You also have the account details at all times and can calculate your risk based on current balance, equity and free margin.
Just read the documentation in detail or follow the online MT4 tutorial/book. Have a look at functions such as Account Information and Trade Functions, specially OrderProfit().
Also, do a search on the forum. Many users have provided explanations and links to code on how to calculate risk on many occasions. Here is a recent quote from one of WHRoeder which is also relevant (all credit goes to him):
WHRoeder:
- You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
- Account Balance * percent = RISK = |OrderOpenPrice - OrderStopLoss| * OrderLots * DeltaPerlot (Note OOP-OSL includes the SPREAD)
- Do NOT use TickValue by itself - DeltaPerlot
- You must normalize lots properly and check against min and max.
- You must also check FreeMargin to avoid stop out
You don' have to store those variables because each Order already provides information about its own Profit or Loss. You also have the account details at all times and can calculate your risk based on current balance, equity and free margin.
Just read the documentation in detail or follow the online MT4 tutorial/book. Have a look at functions such as Account Information and Trade Functions, specially OrderProfit().
Also, doa search on the forum. Many users have provided explanations and links to code on how tocalculate risk on many occasions. Here is a recent quote from one of WHRoeder which is also relevant (all credit goes to him):
WHRoeder:
- You place the stop where it needs to be - where the reason for thetrade is no longer valid. E.g. trading a support bounce the stop goesbelow the support.
- Account Balance * percent = RISK = |OrderOpenPrice - OrderStopLoss| * OrderLots * DeltaPerlot (Note OOP-OSL includes the SPREAD)
- Do NOT use TickValue by itself - DeltaPerlot
- You must normalize lots properly and check against min and max.
- You must also check FreeMargin to avoid stop out
Thanks for guiding me !!
But still i am confused " the final balance problem is solved " but how will i check the highest balance of account .
Should i have to loop through the recent history of all closed trades.
If yes than how should i define its code.
Thanks for guiding me !!
But still i am confused " the final balance problem is solved " but how will i check the highest balance of account .
Should i have to loop through the recent history of all closed trades.
If yes than how should i define its code.
You only need to loop through the History of Closed and Open Orders during Initialisation and/or Recovery, but you don't need to go to far back (just enough for you to synchronise your trading states). After that, you can just keep a running tab of the orders as they progress.
As for how to code it, you will have to reason it out. That is what coding is about - defining the steps you require to do something. Once you have outlined your coding attempt for it, then post it here for advice if you are still having trouble.
One more thing! You should not use the balance or the equity to keep track of profit (or loss), because that would make your EA incompatible with other running EAs or even itself if it is running on another chart as well.
You should keep track of profit based only on the orders themselves as identified by its unique magic number and that are specific to the current symbol.
trading009:
But still i am confused " the final balance problem is solved " but how will i check the highest balance of account .
Should i have to loop through the recent history of all closed trades.
If yes than how should i define its code.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey Readers !
I have initialized two variables initial_balance // Account balance before trade
final_balance // Account balance after trades are closed
my idea is that if was loss last day than my lotsize for today trade must be increase.But i am not understanding that where should i place those two variables to get account balance and check that.
I searched online for it but i was not able to find any good solution .