Need AFL for Plotting vertical lines on futures expiry dates in price chart

doss186

Well-Known Member
#12
I try to copy the code but it gives me an error. Can you help me? I find the idea very interesting. regards
Find below the correct code to plot vertical line on expiry day.

Showthrsday = ParamToggle( "Show Lst Thursday", "No|Yes" );

function Lastthursday ()
{
Daysinmonth = IIf( Month() == 1 OR Month() == 3 OR Month() == 5 OR Month() == 7 OR
Month() == 8 OR Month() == 10 OR Month() == 12, 31, 30 );
Daysinmonthfeb = IIf( Year() % 4 == 0 AND Year() % 100 != 0, 29, 28 );
Daysinmonthfinal = IIf( Month() == 2, Daysinmonthfeb, Daysinmonth );
returnvalue = IIf( Daysinmonthfinal - Day() < 7 AND DayOfWeek() == 4, 1, 0 );
return returnvalue;
}

if ( Showthrsday )
{PlotShapes( IIf( Lastthursday(), shapeSmallCircle, shapeNone ), colorWhite, 0, L, -20 );
}

Plot(Lastthursday(),"Expiry Day",colorGreen,styleHistogram);
 
#13
Excuse me my mistake. I would like to be able to draw on the clandle on the graph the options expiration that is the third Friday of the month. And if you can paint on the bar the day ... better! I repeat, excuse me
Thank you
 

doss186

Well-Known Member
#14
Excuse me my mistake. I would like to be able to draw on the clandle on the graph the options expiration that is the third Friday of the month. And if you can paint on the bar the day ... better! I repeat, excuse me
Thank you
For that just use styleownscale and it will do the needfull.

Showthrsday = ParamToggle( "Show Lst Thursday", "No|Yes" );

function Lastthursday ()
{
Daysinmonth = IIf( Month() == 1 OR Month() == 3 OR Month() == 5 OR Month() == 7 OR
Month() == 8 OR Month() == 10 OR Month() == 12, 31, 30 );
Daysinmonthfeb = IIf( Year() % 4 == 0 AND Year() % 100 != 0, 29, 28 );
Daysinmonthfinal = IIf( Month() == 2, Daysinmonthfeb, Daysinmonth );
returnvalue = IIf( Daysinmonthfinal - Day() < 7 AND DayOfWeek() == 4, 1, 0 );
return returnvalue;
}

if ( Showthrsday )
{PlotShapes( IIf( Lastthursday(), shapeSmallCircle, shapeNone ), colorWhite, 0, L, -20 );
}

Plot(Lastthursday(),"Expiry Day",colorGreen,styleHistogram|styleOwnScale);
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
 
#15
It´s very good the styleownscale!!!!! thank you
but I need change the day thursday for third friday of month , day expiring option. And how I plot the date over the graph?.
I try change thrsday and write Friday baut "error"
Can you help me?
Regards
 

Attachments

sr114

Well-Known Member
#16
function Lastthursday ()
{
Daysinmonth = IIf( Month() == 1 OR Month() == 3 OR Month() == 5 OR Month() == 7 OR
Month() == 8 OR Month() == 10 OR Month() == 12, 31, 30 );
Daysinmonthfeb = IIf( Year() % 4 == 0 AND Year() % 100 != 0, 29, 28 );
Daysinmonthfinal = IIf( Month() == 2, Daysinmonthfeb, Daysinmonth );
returnvalue = IIf( Daysinmonthfinal - Day() < 7 AND DayOfWeek() == 4, 1, 0 );
return returnvalue;
}


modified code
returnvalue = IIf( Daysinmonthfinal - Day() < 7 AND DayOfWeek() == 5, 1, 0 );

Thursday = 4, Friday = 5 .
Make this change.
 
#17
function Lastthursday ()
{
Daysinmonth = IIf( Month() == 1 OR Month() == 3 OR Month() == 5 OR Month() == 7 OR
Month() == 8 OR Month() == 10 OR Month() == 12, 31, 30 );
Daysinmonthfeb = IIf( Year() % 4 == 0 AND Year() % 100 != 0, 29, 28 );
Daysinmonthfinal = IIf( Month() == 2, Daysinmonthfeb, Daysinmonth );
returnvalue = IIf( Daysinmonthfinal - Day() < 7 AND DayOfWeek() == 4, 1, 0 );
return returnvalue;
}


modified code
returnvalue = IIf( Daysinmonthfinal - Day() < 7 AND DayOfWeek() == 5, 1, 0 );

Thursday = 4, Friday = 5 .
Make this change.
Glad to see you back Subroto ji .
 
#18
Thanks for your help. I try to rewrite the code but I am very clumsy !!!


function Lastfriday ()
{
Daysinmonth = IIf( Month() == 1 OR Month() == 3 OR Month() == 5 OR Month() == 7 OR
Month() == 8 OR Month() == 10 OR Month() == 12, 31, 30 );
Daysinmonthfeb = IIf( Year() % 4 == 0 AND Year() % 100 != 0, 29, 28 );
Daysinmonthfinal = IIf( Month() == 2, Daysinmonthfeb, Daysinmonth );
returnvalue = IIf( Daysinmonthfinal - Day() < 7 AND DayOfWeek() == 5, 1, 0 );
Friday = 5
return returnvalue;
}
if ( Showfriday )
{PlotShapes( IIf( Lastfriday(), shapeSmallCircle, shapeNone ), colorWhite, 0, L, -20 );
}

Plot(Lastfriday(),"Expiry Day",colorGreen,styleHistogram|styleOwnScale);
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

.
 

Attachments

#19
One more thing, can I paint/plot the expiration options third Friday from month to future? Could you make an annual calendar indicator and select the days I want to plot?
thanks
 
#20
Hello, I have not been able to write the code to draw vertical lines that paint their date at the base of the vertical line and to be able to put them to the right of the graph. So I can mark the future maturities of the year of options.
regards
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?