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)
there are several way to approach this, one would be to store the net profit in a variable at the beginning of a new period in which you want to stop the trading when a certain net profit is reached (for example daily or weekly, but others would be possible, too).
Now you compute the difference of the current net profit to the value that you stored within the variable. If the difference is greater than your profit limit, block your code from taking further entries and maybe even close all open positions.
If Date = CurrentDate and Date <> Date[1] then
begin
vNetProfit = NetProfit;
end
else
If Date = CurrentDate then
begin
{ Calculate Daily NetProfits }
vDailyNetProfit = NetProfit - vNetProfit;
end;
i found this online how do implement this with order execution so once the robot profits x amount ( E.g. 200$) stop trading. At the same time i want it to run between certain hours 8am-10:30am the way i want it to function is the following . if 200$ are made starting at 8am and 1030 has not come yet then stop trading else continue trading until 1030 then stop disregarding if it made 200 or not.
I am afraid without knowing how your "order execution" part of the code looks like, it's hard to give you a clear direction on how to add the code snippet you posted.
The variable vDailyNetProfit holds the daily profit since midnight, if you only want it to hold the profit since 8am, you would have to modify the code to do the reset based on time and not on the date change.
for that code you could for example set VVSUP and VVSDN to false when your profit goals are met. Additionally you can exclude this part from being executed when your goals are met:
Something like the above should work, under the condition that profitGoalIsMet is a boolean variable that holds the result of your profit goal check.