NexusFi: Find Your Edge


Home Menu

 





Trading day of the month/year counter


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 5 posts (1 thanks)
    2. looks_two edgeseek with 2 posts (0 thanks)
    3. looks_3 andby with 1 posts (0 thanks)
    4. looks_4 SMCJB with 1 posts (2 thanks)
    1. trending_up 5,416 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

Trading day of the month/year counter

  #1 (permalink)
edgeseek
Riyadh, Saudi Arabia
 
Posts: 5 since Feb 2017
Thanks Given: 0
Thanks Received: 0

Dear All,

I need help I'm trying to implement a trading day of the month/year strategy.

Where a trade would be entered on the open of a particular trading day of particular month or year and then exit on the close of that day.

I'm having a problem creating the counter for either.


 
Code
Inputs:
Month1(0),
TDOM1(0);



Variables: 
TDOM (0);

TDOM = 0;

If month(Date) = Month1 then
Begin
TDOM = TDOM + 1;
End;

If TDOM = TDOM1 then
Buy 1 Contract next bar open;

If barssinceentry=0 then
Sell 1 contract this bar close;
Thanks for the help!!!!!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Quant vue
Trading Reviews and Vendors
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629


edgeseek,

I would suggest to add print statements to your code to find out what values TDOM has throughout your code.

Print (Reserved Word)

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #4 (permalink)
edgeseek
Riyadh, Saudi Arabia
 
Posts: 5 since Feb 2017
Thanks Given: 0
Thanks Received: 0

Thanks but do you know how to deal with the trading day counter?

I can call a particular month as month of January = 1 but

then on counting the trading days from the beginning of the month to the end is where I have an issue!

Print doesn't because the counter does not work, if I enter 1 as in first trading day it gives me results for trading every day for a particular month entering 2 would give me 0 trades.

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

edgeseek,

the counter works, the problem is that you reset the counter variable to 0 on every code computation. That's why I suggested using print, so you can see the values that your code computes.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #6 (permalink)
 
andby's Avatar
 andby 
Norwich, UK
 
Experience: Intermediate
Platform: Multiple:research&executi
Broker: Started with Stage5/OEC ... multiple
Trading: Anything found profitable goes ...
Posts: 168 since Jul 2012
Thanks Given: 88
Thanks Received: 88

Hi ABCTG,

Is there a week function / implementation that would return the week ID of the year?

I know a search would return: https://www.multicharts.com/support/base/week but that doesn't work as it returns some wrong data:

Date: 1070315.00; week: 11.00
Date: 1070316.00; week: 11.00
Date: 1070319.00; week: 11.00
Date: 1070320.00; week: 12.00
Date: 1070321.00; week: 12.00

Looking in a calendar ... 19 March 2007 was a Monday ... impossible to be same week number as the 16th ... hence it doesn't work properly.

Thanks

Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Hi andby,

I am not aware of any publicly available functions besides the week function you pointed out.
If you found an error with it, I would suggest reporting it to Multicharts so they can fix it.

Regards,

ABCTG


andby View Post
Hi ABCTG,

Is there a week function / implementation that would return the week ID of the year?

I know a search would return: https://www.multicharts.com/support/base/week but that doesn't work as it returns some wrong data:

Date: 1070315.00; week: 11.00
Date: 1070316.00; week: 11.00
Date: 1070319.00; week: 11.00
Date: 1070320.00; week: 12.00
Date: 1070321.00; week: 12.00

Looking in a calendar ... 19 March 2007 was a Monday ... impossible to be same week number as the 16th ... hence it doesn't work properly.

Thanks


Follow me on Twitter Reply With Quote
  #8 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

andby,

you might also want to check your data and code. I am getting a result of 12 for the week on March 19th using daily MSFT data and just plotting Week(Date).

Regards,

ABCTG


andby View Post
Hi ABCTG,

Is there a week function / implementation that would return the week ID of the year?

I know a search would return: https://www.multicharts.com/support/base/week but that doesn't work as it returns some wrong data:

Date: 1070315.00; week: 11.00
Date: 1070316.00; week: 11.00
Date: 1070319.00; week: 11.00
Date: 1070320.00; week: 12.00
Date: 1070321.00; week: 12.00

Looking in a calendar ... 19 March 2007 was a Monday ... impossible to be same week number as the 16th ... hence it doesn't work properly.

Thanks


Follow me on Twitter Reply With Quote
Thanked by:
  #9 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,388
Thanks Received: 10,207

Use Julian Dates
 
Code
var:
yearenddate(0),
weeknumber(0);

If barnumber = 1 then yearenddate = DateToJulian((year(date)-1)*10000 + 1231);
If year(date) > year(date[1]) then yearenddate = DateToJulian(year(date[1])*10000 + 1231);
weeknumber = floor((DateToJulian(Date) - yearenddate - 1)/7) + 1;

Reply With Quote
Thanked by:
  #10 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629


Hi @andby,

have you been able to track down the problem that is causing the wrong week number on your end?

Regards,

ABCTG

Follow me on Twitter Reply With Quote




Last Updated on July 30, 2018


© 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