Hi All,
I am trying to create a study for Options Delta change from Max delta for the day. I have written the code which works well on lower Chart but when i create it as a watchlist column with same code its shows wrong info. Any idea what i am doing wrong?
Some of the Symbols for your test:
.DASH210827C190
.GOOGL210827C2780
.PENN210827C70
Code in Lower Study: ( Daily 3 Minute Chart )
Any help will be appricaited.
I am trying to create a study for Options Delta change from Max delta for the day. I have written the code which works well on lower Chart but when i create it as a watchlist column with same code its shows wrong info. Any idea what i am doing wrong?
Some of the Symbols for your test:
.DASH210827C190
.GOOGL210827C2780
.PENN210827C70
Code in Lower Study: ( Daily 3 Minute Chart )
Ruby:
Code in Lower Study: ( Daily 3 Minute Chart )
##
# Find Max Delta and substract to find out Delta Max Change
#
declare lower;
def epsilon = 0.01 * close(GetUnderlyingSymbol());
def delta = (OptionPrice(underlyingPrice = close(GetUnderlyingSymbol()) + epsilon) - OptionPrice()) / epsilon;
#Find Highest Delta
def highdelta = if barnumber() == 1 then delta[0]
else if delta[0] > highdelta[1]
then delta[0]
else highdelta[1];
#def highdelta= if Highest(delta,length) > delta[0] then Highest(delta,length) else delta;
def Flag= if delta[1] > delta[0] then 0 else 1;
plot DeltaDiff = AbsValue(highdelta-delta[0])*100;
DeltaDiff.AssignValueColor(if Flag==1 then Color.GREEN else Color.RED);
AddLabel(YES,"DeltaChange="+ DeltaDiff ,(if Flag == 0 then Color.red else color.green));
Code in Watchlist with 3 minute Aggregation:
##
#declare lower;
def epsilon = 0.01 * close(GetUnderlyingSymbol());
def delta = (OptionPrice(underlyingPrice = close(GetUnderlyingSymbol()) + epsilon) - OptionPrice()) / epsilon;
#Find Highest Delta
def highdelta = if barnumber() == 1 then delta[0]
else if delta[0] > highdelta[1]
then delta[0]
else highdelta[1];
#def highdelta= if Highest(delta,length) > delta[0] then Highest(delta,length) else delta;
#def Flag= if highdelta[0] > delta[0] then 0 else 1;
plot DeltaDiff = AbsValue(highdelta[0]-delta[0])*100;
#AddLabel(yes,+ DeltaDiff , Color.RED);
AddLabel(Yes,+DeltaDiff,(if DeltaDiff > 2 and DeltaDiff < 5 then color.green else if DeltaDiff >=5 and DeltaDiff <=10 then color.yellow else if DeltaDiff >=11 then color.red else color.white));
#AddLabel(yes, Close_going_up ,color.green);
Any help will be appricaited.
Last edited: