Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Easylanguage NetProfit Strategy with midnight issues
Looking for some help on an easylanguage coding spot where I am stuck.
Im using a daily profit target / daily profit loss method whereby it will stop trading once either threshold has been hit.
I have seen some other code posted along these lines and to some degree, for the most part they work. However, the problem that I am running into is the fact that "NetProfit" resets at midnight.
So, trading the e-mini S&P beginning at 1700 CT and running till 1515 CT the next day for example, at midnight which is in the middle of the trading session the NetProfit resets and essentially takes all the math calculating the daily profit and daily profit / loss targets back to zero and doesn't do what it is intended to do.
In other words, if the goal has been hit for the next day before midnight (starting at 1700 and say target has been hit by 2100) it will stop trading as it is supposed to.
But, at midnight it will think its ok to trade again since everything reset and the intention is that it would not start trading again until 1700 the next day.
If someone could provide the missing pieces I would greatly appreciate it.
Here is the portion of the code that I am having the issue with:
welcome to futures.io. You could simply move the resetting of the net profit value to the time of your choice, for example after 5 PM.
You can accomplish this for example by using below code snippet:
This works with regards to what it is supposed to do. Resets profits to zero at specified time and with P&L / Loss parameters set it would stop trading once target is met.
However, it works for the specific code on the market that it is activated on.
If I am trading 3 different markets for example, it would run the parameters individually on each market and stop trading accordingly for that particular market.
Trying to figure out what I would need to implement in the code to have it look at the combined P&L / Loss for the account for the day / markets traded for the day.
For example: If we set the day P&L target to $500 in the code it would keep taking new trades until that market either hit the $500 profit target or the daily loss amount was triggered.
But, if were trading 5 markets for example, I want to be able to have each individual market look at the profit / loss overall for the day before taking a new trade. So, if $500 has already been hit for the profits it would not enter new trades in any of the other markets since the daily goal has been hit. Regardless of the fact that each particular market may not have had a trade.
I hope that all makes sense, and I am pretty sure it is something rather simple I am missing.