input TargetRatio = 1.015;
input barexit = 2;
def LongTarget = LongEnt * TargetRatio;
def LongExt= LongTarget or LongEnt from barexit bars ago;
AddOrder(OrderType.SELL_TO_CLOSE, LongExt, close, TradeSize);
input TargetRatio = 1.015;
input barexit = 2;
def LongTarget = EntryPrice() * TargetRatio;
def LongExt= (close >= LongTarget) or (LongEnt from barexit bars ago);
AddOrder(OrderType.SELL_TO_CLOSE, LongExt, close, TradeSize);
input expirationDate = 20191019;
AddLabel(IsOptionable(), "ATM Call: " + GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL), Color.UPTICK);
AddLabel(IsOptionable(), "1st OTM Call: " + GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)), Color.GREEN);
AddLabel(IsOptionable(), "2nd OTM Call: " + GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))), Color.LIGHT_GREEN);
@RobertPayne Thanks. It seems TS doesn't provide the means to get price from codes.
def MA5 = Average(close, 5);
def MA13 = Average(close, 13);
def buyCondition = MA5 crosses above MA13;
AddOrder(OrderType.BUY_TO_OPEN, buyCondition, open[-1], 100, Color.UPTICK, Color.UPTICK, "BTO");
def sellCondition = close >= EntryPrice() + 2;
AddOrder(OrderType.SELL_TO_CLOSE, sellCondition, open[-1], 100, Color.DOWNTICK, Color.DOWNTICK, "STC");
GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)
How do you get price using that function? The code you posted last doesn't seem to use it.
@RobertPayne Got it working, thanks.
EDIT: The option function (returns a code) can be used with a fundamental function (returns price) to get the option price:
close(symbol = GetATMOption(GetUnderlyingSymbol(), Date, OptionClass.CALL))
def expDate = 20191019; #options expiration date
def bidPrice = close(symbol = GetATMOption(GetUnderlyingSymbol(), expDate, OptionClass.CALL), priceType = PriceType.BID);
def askPrice = close(symbol = GetATMOption(GetUnderlyingSymbol(), expDate, OptionClass.CALL), priceType = PriceType.ASK);
plot Data = close;
declare lower;
input expirationDate = 20200612;
plot AprilATMPutPrice = close(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.PUT));
Option functions are broken in TOS...@RobertPayne just wanted to let you know that these aren't working for some reason. I tried them over the weekend and nothing appeared, so I wanted to wait till the market was active today and still no response from the program. The labels appear but the actual options don't appear.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
T | ThinkScript strategy orders seem off | Questions | 5 | |
![]() |
Email Alerts From ThinkScript | Questions | 1 | |
![]() |
Adding a stoploss line that follows price to existing ThinkScript | Questions | 13 | |
B | Access color link symbol in thinkscript? | Questions | 1 | |
F | How to have Thinkscript show historical plots? | Questions | 1 |