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 Daily Profit and Daily Loss limit in strategy
EasyLanguage Daily Profit and Daily Loss limit in strategy
Big Mike
Manta, Ecuador
Site Administrator Developer Swing Trader
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,399 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,539
I needed this for my own strategies, so I wanted to share it here.
This will allow a dollar limit of daily loss and daily profit targets, whereby if one or the other is hit then the strategy will stop for the day.
If you wanted to make it weekly, it wouldn't be hard to do. The input for daily loss should be a + value (ie: "250" means a loss of 250, don't use "-250").
Condition1 evaluates to true if the profit for today is between the max loss and max profit. It evaluates to false if one or the other is exceeded. So place your entry code (buy/sellshort) inside the if block.
H
I everyone
I am trying to implement a daily profit/ loss limit in my trading strategy. To understand exactly what is going on I implemented Big Mike Code in a simple MACD cross over, prior to implementing it my "production trading code" - .
For some reason the code below doesn't work, and don't understand why it isn't working
What I am trying to achieve is very simple; - I want the trading to stop IF dailyprofit or dailyloss is reached within the specified timeframe.
condition1 = var2 crosses under 0 ;
condition2 = var2 crosses over 0 ;
condition98 = (-dailyloss < todaynet and todaynet < dailyprofit) and (Time > starttrade and time < endtrade);
if condition98 then begin
if condition1 then sellshort ( "MacdSE" ) next bar at market;
if condition2 then buy ( "MacdLE" ) next bar at market ;
end;
volatilius
Toronto, Canada
Posts: 1 since Jan 2015
Thanks Given: 0
Thanks Received: 0
Hi Mengelbrecht and all:
I am trying to set up an automated strategy involving a daily stop loss/profit target in Easy Language. I was browsing the forum for any answers and discovered Mengelbrecht encountered the same problem that I am having, in 2010, but I don't know whether the issue was resolved as that's where the thread ends.
In a nutshell, I also wanted to somehow incorporate in the code, a mechanism to terminate a current position if its profit/loss makes the daily profit/loss reach the target. I independently wrote an almost identical code as the code posted by Mengelbrecht, but also put [Intrabarordergeneration=true], and declared some variables as "intrabarpersist". Still, it didn't work.
If that issue has been resolved, could someone please post a working code that is taking into account any current position (the code should be probably using "positionprofit") and terminates that position when the daily profit/loss is reached?
Thanks!
ABCTG
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623
volatilius,
post your code and I am sure someone here in the forum can point you in the right direction.
Regards,
ABCTG
volatilius
Hi Mengelbrecht and all:
I am trying to set up an automated strategy involving a daily stop loss/profit target in Easy Language. I was browsing the forum for any answers and discovered Mengelbrecht encountered the same problem that I am having, in 2010, but I don't know whether the issue was resolved as that's where the thread ends.
In a nutshell, I also wanted to somehow incorporate in the code, a mechanism to terminate a current position if its profit/loss makes the daily profit/loss reach the target. I independently wrote an almost identical code as the code posted by Mengelbrecht, but also put [Intrabarordergeneration=true], and declared some variables as "intrabarpersist". Still, it didn't work.
If that issue has been resolved, could someone please post a working code that is taking into account any current position (the code should be probably using "positionprofit") and terminates that position when the daily profit/loss is reached?
I am trying to set up an automated strategy involving a daily stop loss/profit target in Easy Language. I was browsing the forum for any answers and discovered Mengelbrecht encountered the same problem that I am having, in 2010, but I don't know whether the issue was resolved as that's where the thread ends.
In a nutshell, I also wanted to somehow incorporate in the code, a mechanism to terminate a current position if its profit/loss makes the daily profit/loss reach the target. I independently wrote an almost identical code as the code posted by Mengelbrecht, but also put [Intrabarordergeneration=true], and declared some variables as "intrabarpersist". Still, it didn't work.
If that issue has been resolved, could someone please post a working code that is taking into account any current position (the code should be probably using "positionprofit") and terminates that position when the daily profit/loss is reached?
Thanks!
Hi volatilius
sorry for the late respons, I have been away from my desk all weekend.
This is code that someone send me:
How can this code be modified to set a profit objective for the day that acts as a profit stop? For example the profit breaches a $200 profit level and keeps trading unless the profit falls back below $200 in the same day. Any ideas?
djplastic
Prague
Posts: 2 since Nov 2013
Thanks Given: 1
Thanks Received: 0
Hi,
is there way to get yesterday Netprofit to compare with todays Netprofit please?