YungTraderFromMontana
Well-known member
I'm interested on the connection between P/C ratio and price movement but to analyze it I would need a lower study that plots the P/C ratio. Nothing fancy, just all puts/all calls, I don't care about the strikes. It seems like it would be easy but I've never come across it. Does anyone know of an indicator like this or how to make one? I feel it would be a cool thing to backtest and maybe add to a strategy. If I could get this I'd be happy to create an indicator using it for the community.
Code:
declare lower;
input pcrAveragePeriod = 20;
input expirationDate = 20150418;
def atmC = volume(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL));
def itmC1 = volume(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)));
def itmC2 = volume(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))));
def itmC3 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)))));
def itmC4 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))))));
def itmC5 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)))))));
def itmC6 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))))))));
def itmC7 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)))))))));
def itmC8 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))))))))));
def itmC9 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)))))))))));
def itmC10 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))))))))))));
def otmC1 = volume(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)));
def otmC2 = volume(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))));
def otmC3 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)))));
def otmC4 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))))));
def otmC5 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)))))));
def otmC6 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))))))));
def otmC7 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)))))))));
def otmC8 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))))))))));
def otmC9 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)))))))))));
def otmC10 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))))))))))));
def atmCV = if !IsNaN(atmC) then atmC else 0;
def itmC1V = if !IsNaN(itmC1) then itmC1 else 0;
def itmC2V = if !IsNaN(itmC2) then itmC2 else 0;
def itmC3V = if !IsNaN(itmC3) then itmC3 else 0;
def itmC4V = if !IsNaN(itmC4) then itmC4 else 0;
def itmC5V = if !IsNaN(itmC5) then itmC5 else 0;
def itmC6V = if !IsNaN(itmC6) then itmC6 else 0;
def itmC7V = if !IsNaN(itmC7) then itmC7 else 0;
def itmC8V = if !IsNaN(itmC8) then itmC8 else 0;
def itmC9V = if !IsNaN(itmC9) then itmC9 else 0;
def itmC10V = if !IsNaN(itmC10) then itmC10 else 0;
def otmC1V = if !IsNaN(otmC1) then otmC1 else 0;
def otmC2V = if !IsNaN(otmC2) then otmC2 else 0;
def otmC3V = if !IsNaN(otmC3) then otmC3 else 0;
def otmC4V = if !IsNaN(otmC4) then otmC4 else 0;
def otmC5V = if !IsNaN(otmC5) then otmC5 else 0;
def otmC6V = if !IsNaN(otmC6) then otmC6 else 0;
def otmC7V = if !IsNaN(otmC7) then otmC7 else 0;
def otmC8V = if !IsNaN(otmC8) then otmC8 else 0;
def otmC9V = if !IsNaN(otmC9) then otmC9 else 0;
def otmC10V = if !IsNaN(otmC10) then otmC10 else 0;
def atmP = volume(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT));
def itmP1 = volume(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT)));
def itmP2 = volume(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT))));
def itmP3 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT)))));
def itmP4 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT))))));
def itmP5 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT)))))));
def itmP6 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT))))))));
def itmP7 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT)))))))));
def itmP8 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT))))))))));
def itmP9 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT)))))))))));
def itmP10 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT))))))))))));
def otmP1 = volume(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT)));
def otmP2 = volume(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT))));
def otmP3 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT)))));
def otmP4 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT))))));
def otmP5 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT)))))));
def otmP6 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT))))))));
def otmP7 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT)))))))));
def otmP8 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT))))))))));
def otmP9 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT)))))))))));
def otmP10 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT))))))))))));
def atmPV = if !IsNaN(atmP) then atmP else 0;
def itmP1V = if !IsNaN(itmP1) then itmP1 else 0;
def itmP2V = if !IsNaN(itmP2) then itmP2 else 0;
def itmP3V = if !IsNaN(itmP3) then itmP3 else 0;
def itmP4V = if !IsNaN(itmP4) then itmP4 else 0;
def itmP5V = if !IsNaN(itmP5) then itmP5 else 0;
def itmP6V = if !IsNaN(itmP6) then itmP6 else 0;
def itmP7V = if !IsNaN(itmP7) then itmP7 else 0;
def itmP8V = if !IsNaN(itmP8) then itmP8 else 0;
def itmP9V = if !IsNaN(itmP9) then itmP9 else 0;
def itmP10V = if !IsNaN(itmP10) then itmP10 else 0;
def otmP1V = if !IsNaN(otmP1) then otmP1 else 0;
def otmP2V = if !IsNaN(otmP2) then otmP2 else 0;
def otmP3V = if !IsNaN(otmP3) then otmP3 else 0;
def otmP4V = if !IsNaN(otmP4) then otmP4 else 0;
def otmP5V = if !IsNaN(otmP5) then otmP5 else 0;
def otmP6V = if !IsNaN(otmP6) then otmP6 else 0;
def otmP7V = if !IsNaN(otmP7) then otmP7 else 0;
def otmP8V = if !IsNaN(otmP8) then otmP8 else 0;
def otmP9V = if !IsNaN(otmP9) then otmP9 else 0;
def otmP10V = if !IsNaN(otmP10) then otmP10 else 0;
input expirationDate2 = 20150516;
def atm2C = volume(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL));
def itm2C1 = volume(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL)));
def itm2C2 = volume(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL))));
def itm2C3 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL)))));
def itm2C4 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL))))));
def itm2C5 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL)))))));
def itm2C6 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL))))))));
def itm2C7 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL)))))))));
def itm2C8 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL))))))))));
def itm2C9 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL)))))))))));
def itm2C10 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL))))))))))));
def otm2C1 = volume(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL)));
def otm2C2 = volume(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL))));
def otm2C3 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL)))));
def otm2C4 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL))))));
def otm2C5 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL)))))));
def otm2C6 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL))))))));
def otm2C7 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL)))))))));
def otm2C8 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL))))))))));
def otm2C9 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL)))))))))));
def otm2C10 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.CALL))))))))))));
def atm2CV = if !IsNaN(atm2C) then atm2C else 0;
def itm2C1V = if !IsNaN(itm2C1) then itm2C1 else 0;
def itm2C2V = if !IsNaN(itm2C2) then itm2C2 else 0;
def itm2C3V = if !IsNaN(itm2C3) then itm2C3 else 0;
def itm2C4V = if !IsNaN(itm2C4) then itm2C4 else 0;
def itm2C5V = if !IsNaN(itm2C5) then itm2C5 else 0;
def itm2C6V = if !IsNaN(itm2C6) then itm2C6 else 0;
def itm2C7V = if !IsNaN(itm2C7) then itm2C7 else 0;
def itm2C8V = if !IsNaN(itm2C8) then itm2C8 else 0;
def itm2C9V = if !IsNaN(itm2C9) then itm2C9 else 0;
def itm2C10V = if !IsNaN(itm2C10) then itm2C10 else 0;
def otm2C1V = if !IsNaN(otm2C1) then otm2C1 else 0;
def otm2C2V = if !IsNaN(otm2C2) then otm2C2 else 0;
def otm2C3V = if !IsNaN(otm2C3) then otm2C3 else 0;
def otm2C4V = if !IsNaN(otm2C4) then otm2C4 else 0;
def otm2C5V = if !IsNaN(otm2C5) then otm2C5 else 0;
def otm2C6V = if !IsNaN(otm2C6) then otm2C6 else 0;
def otm2C7V = if !IsNaN(otm2C7) then otm2C7 else 0;
def otm2C8V = if !IsNaN(otm2C8) then otm2C8 else 0;
def otm2C9V = if !IsNaN(otm2C9) then otm2C9 else 0;
def otm2C10V = if !IsNaN(otm2C10) then otm2C10 else 0;
def atm2P = volume(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT));
def itm2P1 = volume(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT)));
def itm2P2 = volume(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT))));
def itm2P3 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT)))));
def itm2P4 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT))))));
def itm2P5 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT)))))));
def itm2P6 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT))))))));
def itm2P7 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT)))))))));
def itm2P8 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT))))))))));
def itm2P9 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT)))))))))));
def itm2P10 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT))))))))))));
def otm2P1 = volume(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT)));
def otm2P2 = volume(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT))));
def otm2P3 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT)))));
def otm2P4 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT))))));
def otm2P5 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT)))))));
def otm2P6 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT))))))));
def otm2P7 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT)))))))));
def otm2P8 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT))))))))));
def otm2P9 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT)))))))))));
def otm2P10 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate2, OptionClass.PUT))))))))))));
def atm2PV = if !IsNaN(atm2P) then atm2P else 0;
def itm2P1V = if !IsNaN(itm2P1) then itm2P1 else 0;
def itm2P2V = if !IsNaN(itm2P2) then itm2P2 else 0;
def itm2P3V = if !IsNaN(itm2P3) then itm2P3 else 0;
def itm2P4V = if !IsNaN(itm2P4) then itm2P4 else 0;
def itm2P5V = if !IsNaN(itm2P5) then itm2P5 else 0;
def itm2P6V = if !IsNaN(itm2P6) then itm2P6 else 0;
def itm2P7V = if !IsNaN(itm2P7) then itm2P7 else 0;
def itm2P8V = if !IsNaN(itm2P8) then itm2P8 else 0;
def itm2P9V = if !IsNaN(itm2P9) then itm2P9 else 0;
def itm2P10V = if !IsNaN(itm2P10) then itm2P10 else 0;
def otm2P1V = if !IsNaN(otm2P1) then otm2P1 else 0;
def otm2P2V = if !IsNaN(otm2P2) then otm2P2 else 0;
def otm2P3V = if !IsNaN(otm2P3) then otm2P3 else 0;
def otm2P4V = if !IsNaN(otm2P4) then otm2P4 else 0;
def otm2P5V = if !IsNaN(otm2P5) then otm2P5 else 0;
def otm2P6V = if !IsNaN(otm2P6) then otm2P6 else 0;
def otm2P7V = if !IsNaN(otm2P7) then otm2P7 else 0;
def otm2P8V = if !IsNaN(otm2P8) then otm2P8 else 0;
def otm2P9V = if !IsNaN(otm2P9) then otm2P9 else 0;
def otm2P10V = if !IsNaN(otm2P10) then otm2P10 else 0;
input expirationDate3 = 20150620;
def atm3C = volume(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL));
def itm3C1 = volume(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL)));
def itm3C2 = volume(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL))));
def itm3C3 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL)))));
def itm3C4 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL))))));
def itm3C5 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL)))))));
def itm3C6 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL))))))));
def itm3C7 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL)))))))));
def itm3C8 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL))))))))));
def itm3C9 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL)))))))))));
def itm3C10 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL))))))))))));
def otm3C1 = volume(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL)));
def otm3C2 = volume(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL))));
def otm3C3 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL)))));
def otm3C4 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL))))));
def otm3C5 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL)))))));
def otm3C6 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL))))))));
def otm3C7 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL)))))))));
def otm3C8 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL))))))))));
def otm3C9 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL)))))))))));
def otm3C10 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.CALL))))))))))));
def atm3CV = if !IsNaN(atm3C) then atm3C else 0;
def itm3C1V = if !IsNaN(itm3C1) then itm3C1 else 0;
def itm3C2V = if !IsNaN(itm3C2) then itm3C2 else 0;
def itm3C3V = if !IsNaN(itm3C3) then itm3C3 else 0;
def itm3C4V = if !IsNaN(itm3C4) then itm3C4 else 0;
def itm3C5V = if !IsNaN(itm3C5) then itm3C5 else 0;
def itm3C6V = if !IsNaN(itm3C6) then itm3C6 else 0;
def itm3C7V = if !IsNaN(itm3C7) then itm3C7 else 0;
def itm3C8V = if !IsNaN(itm3C8) then itm3C8 else 0;
def itm3C9V = if !IsNaN(itm3C9) then itm3C9 else 0;
def itm3C10V = if !IsNaN(itm3C10) then itm3C10 else 0;
def otm3C1V = if !IsNaN(otm3C1) then otm3C1 else 0;
def otm3C2V = if !IsNaN(otm3C2) then otm3C2 else 0;
def otm3C3V = if !IsNaN(otm3C3) then otm3C3 else 0;
def otm3C4V = if !IsNaN(otm3C4) then otm3C4 else 0;
def otm3C5V = if !IsNaN(otm3C5) then otm3C5 else 0;
def otm3C6V = if !IsNaN(otm3C6) then otm3C6 else 0;
def otm3C7V = if !IsNaN(otm3C7) then otm3C7 else 0;
def otm3C8V = if !IsNaN(otm3C8) then otm3C8 else 0;
def otm3C9V = if !IsNaN(otm3C9) then otm3C9 else 0;
def otm3C10V = if !IsNaN(otm3C10) then otm3C10 else 0;
def atm3P = volume(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT));
def itm3P1 = volume(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT)));
def itm3P2 = volume(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT))));
def itm3P3 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT)))));
def itm3P4 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT))))));
def itm3P5 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT)))))));
def itm3P6 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT))))))));
def itm3P7 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT)))))))));
def itm3P8 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT))))))))));
def itm3P9 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT)))))))))));
def itm3P10 = volume(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetNextITMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT))))))))))));
def otm3P1 = volume(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT)));
def otm3P2 = volume(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT))));
def otm3P3 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT)))));
def otm3P4 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT))))));
def otm3P5 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT)))))));
def otm3P6 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT))))))));
def otm3P7 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT)))))))));
def otm3P8 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT))))))))));
def otm3P9 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT)))))))))));
def otm3P10 = volume(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate3, OptionClass.PUT))))))))))));
def atm3PV = if !IsNaN(atm3P) then atm3P else 0;
def itm3P1V = if !IsNaN(itm3P1) then itm3P1 else 0;
def itm3P2V = if !IsNaN(itm3P2) then itm3P2 else 0;
def itm3P3V = if !IsNaN(itm3P3) then itm3P3 else 0;
def itm3P4V = if !IsNaN(itm3P4) then itm3P4 else 0;
def itm3P5V = if !IsNaN(itm3P5) then itm3P5 else 0;
def itm3P6V = if !IsNaN(itm3P6) then itm3P6 else 0;
def itm3P7V = if !IsNaN(itm3P7) then itm3P7 else 0;
def itm3P8V = if !IsNaN(itm3P8) then itm3P8 else 0;
def itm3P9V = if !IsNaN(itm3P9) then itm3P9 else 0;
def itm3P10V = if !IsNaN(itm3P10) then itm3P10 else 0;
def otm3P1V = if !IsNaN(otm3P1) then otm3P1 else 0;
def otm3P2V = if !IsNaN(otm3P2) then otm3P2 else 0;
def otm3P3V = if !IsNaN(otm3P3) then otm3P3 else 0;
def otm3P4V = if !IsNaN(otm3P4) then otm3P4 else 0;
def otm3P5V = if !IsNaN(otm3P5) then otm3P5 else 0;
def otm3P6V = if !IsNaN(otm3P6) then otm3P6 else 0;
def otm3P7V = if !IsNaN(otm3P7) then otm3P7 else 0;
def otm3P8V = if !IsNaN(otm3P8) then otm3P8 else 0;
def otm3P9V = if !IsNaN(otm3P9) then otm3P9 else 0;
def otm3P10V = if !IsNaN(otm3P10) then otm3P10 else 0;
def totalCallVolume = atmCV + itmC1V + itmC2V + itmC3V + itmC4V + itmC5V + itmC6V + itmC7V + itmC8V + itmC9V + itmC10V
+ otmC1V + otmC2V + otmC3V + otmC4V + otmC5V + otmC6V + otmC7V + otmC8V + otmC9V + otmC10V +
atm2CV + itm2C1V + itm2C2V + itm2C3V + itm2C4V + itm2C5V + itm2C6V + itm2C7V + itm2C8V + itm2C9V + itm2C10V
+ otm2C1V + otm2C2V + otm2C3V + otm2C4V + otm2C5V + otm2C6V + otm2C7V + otm2C8V + otm2C9V + otm2C10V +
atm3CV + itm3C1V + itm3C2V + itm3C3V + itm3C4V + itm3C5V + itm3C6V + itm3C7V + itm3C8V + itm3C9V + itm3C10V
+ otm3C1V + otm3C2V + otm3C3V + otm3C4V + otm3C5V + otm3C6V + otm3C7V + otm3C8V + otm3C9V + otm3C10V;
plot calls = if !isNan(close) then totalCallVolume else double.nan;
calls.SetDefaultColor(Color.GREEN);
def totalPutVolume = atmPV + itmP1V + itmP2V + itmP3V + itmP4V + itmP5V + itmP6V + itmP7V + itmP8V + itmP9V + itmP10V
+ otmP1V + otmP2V + otmP3V + otmP4V + otmP5V + otmP6V + otmP7V + otmP8V + otmP9V + otmP10V+
atm2PV + itm2P1V + itm2P2V + itm2P3V + itm2P4V + itm2P5V + itm2P6V + itm2P7V + itm2P8V + itm2P9V + itm2P10V
+ otm2P1V + otm2P2V + otm2P3V + otm2P4V + otm2P5V + otm2P6V + otm2P7V + otm2P8V + otm2P9V + otm2P10V+
atm3PV + itm3P1V + itm3P2V + itm3P3V + itm3P4V + itm3P5V + itm3P6V + itm3P7V + itm3P8V + itm3P9V + itm3P10V
+ otm3P1V + otm3P2V + otm3P3V + otm3P4V + otm3P5V + otm3P6V + otm3P7V + otm3P8V + otm3P9V + otm3P10V;
plot puts = if !isNan(close) then totalPutVolume else double.nan;
puts.SetDefaultColor(Color.RED);
plot pcr = (puts/max(1,calls));
pcr.setDefaultColor(color.BLACK);
plot pcrAvg = average(pcr,pcrAveragePeriod);
pcrAvg.setDefaultColor(color.BLUE);
pcr.hide();
AddLabel(yes, Concat("Put Volume: ", totalPutVolume), color.RED);
AddLabel(yes, Concat("Call Volume: ", totalCallVolume), color.GREEN);
AddLabel(yes, Concat("P/C: ", totalPutVolume/totalCallVolume), color.BLUE);