NexusFi: Find Your Edge


Home Menu

 





Keeping track of day trades?


Discussion in EasyLanguage Programming

Updated
    1. trending_up 5,932 views
    2. thumb_up 4 thanks given
    3. group 3 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

Keeping track of day trades?

  #1 (permalink)
 Captain135 
Bay Area, CA
 
Experience: Intermediate
Platform: TradeStation, TOS
Trading: Futures, Equities, Options on Futures
Posts: 48 since Feb 2017
Thanks Given: 53
Thanks Received: 30

Has anyone figured out any EL code that can keep track of day trades, so that a strategy will only execute a trade if there have been less than 3 trades in previous 5 business days?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Quant vue
Trading Reviews and Vendors
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 IFeelLikeNeo   is a Vendor
 
Posts: 26 since Nov 2019
Thanks Given: 8
Thanks Received: 38

Good idea!

I was fairly sure this was included in Kevin D's great Entries and Exits book... I am sure I've seen it somewhere online too but I can't now find it either on my bookshelf or online!

But opening my EasyLanguage book of all the reserved words and functions (super useful, downloadable here: https://s3.amazonaws.com/easylanguage/EasyLanguage/EasyLanguage+Functions+and+Reserved+Words+Reference.pdf), I'd start playing with the "TotalTrades" reserved word and see if you can use that.

"NumWinTrades" might also be useful.

I haven't used either of them in code otherwise I'd share.

James

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
 kjhosken 
Seattle, WA/USA
 
Experience: Intermediate
Platform: TOS, TS
Trading: Forex, crude
Posts: 96 since Sep 2016
Thanks Given: 7
Thanks Received: 35


try the tradestoday function. I haven't tested this, but perhaps something like
 
Code
(tradestoday(date[0]) +tradestoday(date[1]) +tradestoday(date[2]) +tradestoday(date[3]) +tradestoday(date[4])) <=3

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
 Captain135 
Bay Area, CA
 
Experience: Intermediate
Platform: TradeStation, TOS
Trading: Futures, Equities, Options on Futures
Posts: 48 since Feb 2017
Thanks Given: 53
Thanks Received: 30

Thanks James, I think if I just set the timeframe to "5 days back", then use total trades

 
Code
if totaltrades < 4 then
*your entry signal code*
Kjhosken, "tradestoday" doesn't seem to exist in tradestation

Started this thread Reply With Quote
  #5 (permalink)
 IFeelLikeNeo   is a Vendor
 
Posts: 26 since Nov 2019
Thanks Given: 8
Thanks Received: 38

Hi,

>I think if I just set the timeframe to "5 days back
D'you mean in the chart? That would make it impossible to properly backtest, walk forward, monte carlo and lightly optimise though, unless I've misunderstood.

I just compiled this;

if (totaltrades[0] + totaltrades[1] + totaltrades[2] + totaltrades[3] + totaltrades[4]) <=3 then begin
// insert entry here
end;

based on KJ's structure but using a function included in the EasyLanguage bible I mentioned.

Of course, code that compiles doesn't necessarily do what you want it to, but it's a start!

J

Follow me on Twitter Reply With Quote
  #6 (permalink)
 Captain135 
Bay Area, CA
 
Experience: Intermediate
Platform: TradeStation, TOS
Trading: Futures, Equities, Options on Futures
Posts: 48 since Feb 2017
Thanks Given: 53
Thanks Received: 30


IFeelLikeNeo View Post
Hi,

>I think if I just set the timeframe to "5 days back
D'you mean in the chart? That would make it impossible to properly backtest, walk forward, monte carlo and lightly optimise though, unless I've misunderstood.

I just compiled this;

if (totaltrades[0] + totaltrades[1] + totaltrades[2] + totaltrades[3] + totaltrades[4]) <=3 then begin
// insert entry here
end;

based on KJ's structure but using a function included in the EasyLanguage bible I mentioned.

Of course, code that compiles doesn't necessarily do what you want it to, but it's a start!

J

What you have would only work if you are on daily candles, because if you were on intraday, the previous totaltrades[1] bar would be the previous bar, not the previous day. For my use case, this code would just be for live trading, and the backtesting would be done on the strategy without this code included. I can't think of any reason why it would fundamentally change a strategy for better or worse---it would just reduce the number of trades.

Started this thread Reply With Quote
  #7 (permalink)
 IFeelLikeNeo   is a Vendor
 
Posts: 26 since Nov 2019
Thanks Given: 8
Thanks Received: 38

Good spot! You're right... though if you wanted to use the same code, you could have data1 as the bar size of your choice and data2 as daily bars, then reference data2 in the code I wrote.

Or this may be better?

if (totaltrades[currentdate] + totaltrades[currentdate-1] + totaltrades[currentdate-2] + totaltrades[currentdate-3] + totaltrades[currentdate-4]) <=3 then begin
// insert entry here
end;

I think it's best to backtest, walk forward, etc with the same code you trade, whenever possible.

Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
 Captain135 
Bay Area, CA
 
Experience: Intermediate
Platform: TradeStation, TOS
Trading: Futures, Equities, Options on Futures
Posts: 48 since Feb 2017
Thanks Given: 53
Thanks Received: 30

Ah yes, putting daily bars on data2 would be a good way to do that, thanks for the insight! I don't think totaltrades[currentrade] would work because currentdate returns values like "200901"

Started this thread Reply With Quote
  #9 (permalink)
 IFeelLikeNeo   is a Vendor
 
Posts: 26 since Nov 2019
Thanks Given: 8
Thanks Received: 38

Ha! Yes, you're right about my second idea.. a perfect example of something that compiles, but doesn't work!

I'll ask a pal though as I'm sure it's possible to use reserved words to get this done too... will let you know if I work it out.

Happy trading in the meantime!


Follow me on Twitter Reply With Quote
  #10 (permalink)
 Captain135 
Bay Area, CA
 
Experience: Intermediate
Platform: TradeStation, TOS
Trading: Futures, Equities, Options on Futures
Posts: 48 since Feb 2017
Thanks Given: 53
Thanks Received: 30


EDIT: I just remembered, when you have multiple data series on a chart, but a shorter timeframe on one of the data series, the historical reference brackets [1] counts based on shorter timeframe.

For example, say you have 1 minute bars on data1, and 5 minute bars on data2. To make the bars line up, tradestation just puts blank spaces between the 5 minute bars, and each of those blank spaces holds the price values of whatever the last 5min bar was. So if you wanted to reference the close price on data2 one (5min) bar ago, you would actually do close[5], and for two 5 min bars ago, you could do close[10], and so on.

So in the case of daily bars on data2, and perhaps 1 minute chart on data1, to reference the close price of 1 day ago, you would need close[390] (based on a 6.5 hour trading session)

Started this thread Reply With Quote
Thanked by:




Last Updated on September 1, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts