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
the post from @mengelbrecht two above your post shows how to store the previous NetProfit in a variable on a new day. Which is exactly what you'd have to do, too. Then you can use this variable in your checks.
By any chance, do you have an example of this incorporated into a full coded strategy example? I'm trying to learn how to code some strategies, and not sure where everything should be placed in regards to what you listed here. I assume this is for NT7? Thanks in advance if you can help.
Mike - I was wondering if something similar to this could be implemented for multiple TradeStation (TS) Workspaces? I trade 4 futures markets in TS and my goal for each day is $2K. I sometimes enter 3-4 markets at the same time (via my strategy) as they are all trending in the same direction. Many times they hit the $2k mark and fall off if am not watching every tick. I can get distracted with bathroom trips, snacks, phone calls, etc. I would like to have all my Workspaces shut down if I reach this daily profit or loss target. Is this a possibility? I was thinking you might be able to cross reference all 4 Workspaces some way. Maybe with a 5th chart referencing the other 4 as long as the same account is used? What do you think? Thanks in advance for your help. JK
it depends a bit of what exactly you want to do. If you want a global target across all workspaces, this would require some communication between the charts and maybe a separate chart that monitors all targets and blocks/allows the trading on the individual charts. One way to accomplish this in real time could by using a Global Dictionary.
Regards,
ABCTG
20YRTRADER
Mike - I was wondering if something similar to this could be implemented for multiple TradeStation (TS) Workspaces? I trade 4 futures markets in TS and my goal for each day is $2K. I sometimes enter 3-4 markets at the same time (via my strategy) as they are all trending in the same direction. Many times they hit the $2k mark and fall off if am not watching every tick. I can get distracted with bathroom trips, snacks, phone calls, etc. I would like to have all my Workspaces shut down if I reach this daily profit or loss target. Is this a possibility? I was thinking you might be able to cross reference all 4 Workspaces some way. Maybe with a 5th chart referencing the other 4 as long as the same account is used? What do you think? Thanks in advance for your help. JK
yes, this is defined in EasyLanguage. Global Dictionaries were introduced with Object Oriented EasyLanguage and can for example be used to share data across studies, charts or between applications.
Regards,
ABCTG
20YRTRADER
What is a Global Dictionary? Is this defined in Easy Language?
How can I put this on a Indicator? I want to see it.
Big Mike
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").
// for use in signal
inputs:
dailyprofit(500),
dailyloss(250);
vars:
todaynet(0),
yesterdaynet(0);
if date <> date[1] then begin
yesterdaynet = NetProfit;
end;
if MarketPosition = 0 then begin
todaynet = NetProfit - yesterdaynet;
end;
condition1 = -dailyloss < todaynet and todaynet < dailyprofit;
// entries
if condition 1 then begin
// put your long and short code here
end;
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.
You can do it reference to the account balance...
I have not the code to hand, but I can give you later..
20YRTRADER
Mike - I was wondering if something similar to this could be implemented for multiple TradeStation (TS) Workspaces? I trade 4 futures markets in TS and my goal for each day is $2K. I sometimes enter 3-4 markets at the same time (via my strategy) as they are all trending in the same direction. Many times they hit the $2k mark and fall off if am not watching every tick. I can get distracted with bathroom trips, snacks, phone calls, etc. I would like to have all my Workspaces shut down if I reach this daily profit or loss target. Is this a possibility? I was thinking you might be able to cross reference all 4 Workspaces some way. Maybe with a 5th chart referencing the other 4 as long as the same account is used? What do you think? Thanks in advance for your help. JK
what exactly do you want the indicator to display? Strategy related reserved words won't be available in indicators, but TS offers reserved words that make some strategy related values available in indicators like I_closedequity
for example and you can use this to replace Netprofit in the indicator code. You will however still need a strategy applied to the same chart in order for I_closedequity to return a value different than 0.
Regards,
ABCTG
AlexBa
How can I put this on a Indicator? I want to see it.