I have a strategy that buy/sell depends on number of (trading days) to expiry for a futures contract.
Is it possible to reference such field in multicharts code?
Thanks.
Futures Expiry Syntax
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: Futures Expiry Syntax
Yes, you can use the keyword: ExpirationDateI have a strategy that buy/sell depends on number of (trading days) to expiry for a futures contract.
Is it possible to reference such field in multicharts code?
Thanks.
For a list of available keywords,
look under PowerLanguage Keyword Reference
https://www.multicharts.com/trading-sof ... /Main_Page
Re: Futures Expiry Syntax
Yes, you can use the keyword: ExpirationDateI have a strategy that buy/sell depends on number of (trading days) to expiry for a futures contract.
Is it possible to reference such field in multicharts code?
Thanks.
For a list of available keywords,
look under PowerLanguage Keyword Reference
https://www.multicharts.com/trading-sof ... /Main_Page
TJ, Thanks for reading and replying my posts all the time.
I tried to use it but get a constant number which didnt make sense "239,700.00"
This is my code, what do you think the problem is?
"Plot1( ExpirationDate - Date, "NoOfDaysToExp" ) ;"
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: Futures Expiry Syntax
Have you looked under PowerLanguage Keyword Reference?TJ, Thanks for reading and replying my posts all the time.Yes, you can use the keyword: ExpirationDateI have a strategy that buy/sell depends on number of (trading days) to expiry for a futures contract.
Is it possible to reference such field in multicharts code?
Thanks.
For a list of available keywords,
look under PowerLanguage Keyword Reference
https://www.multicharts.com/trading-sof ... /Main_Page
I tried to use it but get a constant number which didnt make sense "239,700.00"
This is my code, what do you think the problem is?
"Plot1( ExpirationDate - Date, "NoOfDaysToExp" ) ;"
All the keyword definitions are there, including usage examples.
ps. it would help if you provide more information on your test. e.g the name of the instrument, so that other people can test and verify it on their side too.
ps. look up also the keyword definition of "Date".
Re: Futures Expiry Syntax
Code: Select all
Variables:
dateToday(0), dateTodayFormat(0),dateFutExp(0), dateFutExpFormat(0);
// 1. Assign the date of today to the variable 'dateToday'
dateToday = Date;
//Print("The current date in YYYMMdd format is: ", dateToday, NewLine);
// 2. Now, convert the date to DateTime format
dateTodayFormat = ELDateToDateTime(dateToday);
//Print("The current date in DateTime format is: ", NumToStr(dateTodayFormat , 5), NewLine);
// 1. Assign the date of today to the variable 'dateToday'
dateFutExp = ExpirationDate;
//Print("The current date in YYYMMdd format is: ", dateToday, NewLine);
// 2. Now, convert the date to DateTime format
dateFutExpFormat = ELDateToDateTime(dateFutExp);
//Print("The current date in DateTime format is: ", NumToStr(dateFutExpFormat , 5), NewLine);
Print("Number of days to expiry is ", NumToStr(dateFutExpFormat - dateTodayFormat, 5), NewLine);
Plot1( dateFutExpFormat - dateTodayFormat, "NoOfDaysToExp" ) ;
It is strange that the ExpirationDate is returning as Today. i.e. 2nd April. The expiry should be 16th April.
It seems the ExpirationDate field is not expressing what it should be?
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: Futures Expiry Syntax
Who is your data provider?
What is the expiry date in the QuoteManager?
Give this a try:
ps. you should post your print out, so that people can help trace the errors for you.
What is the expiry date in the QuoteManager?
Give this a try:
Code: Select all
If lastbaronchart then
begin
once begin
print("Today's date = ", date+19000000:0:0, newline,
" Expiry date for "+symbolname+" = "+ text(expirationdate+19000000:0:0));
end;
end;
ps. you should post your print out, so that people can help trace the errors for you.
Re: Futures Expiry Syntax
I have attached the screen shot here.
The problem is it seems the expiry date extracted are not the actual expiry dates.
All the contracts expires around the 1st of the month, which explains why I get a value of 0 for the April14 contract (as it expires today).
The real expiry date should be mid April, and should be mid month for every month.
So is the ExpirationDate field reliable?
The problem is it seems the expiry date extracted are not the actual expiry dates.
All the contracts expires around the 1st of the month, which explains why I get a value of 0 for the April14 contract (as it expires today).
The real expiry date should be mid April, and should be mid month for every month.
So is the ExpirationDate field reliable?
- Attachments
-
- MC_Capture.PNG
- (69.32 KiB) Downloaded 812 times
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: Futures Expiry Syntax
MultiCharts gets the ExpirationDate from your data provider.I have attached the screen shot here.
The problem is it seems the expiry date extracted are not the actual expiry dates.
All the contracts expires around the 1st of the month, which explains why I get a value of 0 for the April14 contract (as it expires today).
The real expiry date should be mid April, and should be mid month for every month.
So is the ExpirationDate field reliable?
Go to QuoteManager, double click on symbol,
you can see the expiry date of the contract.
- Attachments
-
- Expiry Date.jpg
- (31.94 KiB) Downloaded 848 times
Re: Futures Expiry Syntax
Thanks TJ, I am using IQFeed at the moment. Checking if they dont provide "good" futures exp dates.
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: Futures Expiry Syntax
Good that you found out now... instead of later.IQFeed came back and its a mistake on their end.
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Futures Expiry Syntax
The expiration date in QuoteManager is calculated based on the expiration rule for the instrument's symbol root. You can find the symbol root for a particular instrument in QuoteManager->Edit symbol->Futures tab.
You can find the symbol dictionary in QuoteManager->Tools->Symbol Dictionary.
In the symbol dictionary please select IQFeed->@VX->Edit->set Expiration rule to "Third Tuesday".
The expiration date will be automatically recalculated for all of the instruments from this data provider using this rule.
You can find the symbol dictionary in QuoteManager->Tools->Symbol Dictionary.
In the symbol dictionary please select IQFeed->@VX->Edit->set Expiration rule to "Third Tuesday".
The expiration date will be automatically recalculated for all of the instruments from this data provider using this rule.