# Option Straddle based on Moving Average

#### Piper2808t

##### Member
2019 Donor
VIP
open and close between avgexp. i meant high and low between avgexp. straddles on a daily time frame in a column if ema 200 is between the high and low of a daily bar than by a straddle 30-45 days out

#### horserider

##### Well-known member
VIP
Makes no sense. Rethink.

#### horserider

##### Well-known member
VIP
Still makes no sense. If avgexp means an EMA and an EMA is a line. How do you get a high and low or open and close to fall between a line ?

#### horserider

##### Well-known member
VIP
That is not what you said. Now it makes some sense as far as a statement but what sense does it make for trading.

#### horserider

##### Well-known member
VIP
Ahh ok Now that what you wanted is better explained maybe someone will be able to help.

#### sirigina

##### New member
2019 Donor
Here is a script that plots an arrow when EMA crosses between High and Low of the day.
Is this what you are looking for?

input duration = 200;
def lo = low;
def hi = high;
def cl = close;

def _EMA = MovingAverage(AverageType.EXPONENTIAL, cl, duration);

def emabetween = if (_EMA <= hi and _EMA >= lo) then 1 else 0;

plot EmaBetweenHighLow = emabetween;
EmaBetweenHighLow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
EmaBetweenHighLow.SetLineWeight(2);

plot EMA = _EMA;
#END

#### Piper2808t

##### Member
2019 Donor
VIP
thank you very much looks great

#### sirigina

##### New member
2019 Donor
2 General Questions:
1. Is it possible to show the above indicator Only ONCE and Only if it occurred in the last 5 days? Avoid noise and ignore older signals
2. How do I make this indicator to show only on daily aggregation chart? Noisy in 5 min charts

#### BenTen

Staff member
Staff
VIP
@sri5nivas Regarding your second question, try using the following condition.

Code:
``declare hide_on_intraday;``

#### sirigina

##### New member
2019 Donor
Awesome, that works like a charm. Thank you.

#### sirigina

##### New member
2019 Donor
Couldn't sleep until I figure this out, but I finally got it working the way I want it.
In this modified script, you can specify LookbackDays (number of days to look back) for this condition.
Basically if the condition occurred too long ago, then it won't show it.
If you want to see all past indicators, you can specify 0 for LookbackDays

Note: TOS indicates that this might cause performance issues. If you see any sluggishness, use the previous version.

#LookbackDays = 0 will show all past indicators, or specify number of days to look back

input Duration = 200;
input LookbackDays = 0;
def lo = low;
def hi = high;
def cl = close;

def _EMA = MovingAverage(AverageType.EXPONENTIAL, cl, Duration);
def NumberOfBars = HighestAll(if !IsNaN(close) then BarNumber() else Double.NEGATIVE_INFINITY);

def emabetween = if ( (LookbackDays <= 0 or BarNumber() > NumberOfBars-LookbackDays ) AND (_EMA <= hi and _EMA >= lo) ) then 1 else 0;

plot EmaBetweenHighLow = emabetween;
EmaBetweenHighLow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
EmaBetweenHighLow.SetLineWeight(2);

plot EMA = _EMA;

#END

#### Piper2808t

##### Member
2019 Donor
VIP
any way to put this in a column as to when the arrow appears

#### sirigina

##### New member
2019 Donor
Here it is. You can add this to a Custom Column script.
It shows "A" if the EMA crossed between high and low in the last 5 days.

def _EMA = MovingAverage(AverageType.EXPONENTIAL, close, 200);

def emabetween = if ( (_EMA[0] <= high[0] and _EMA[0] >= low[0]) or (_EMA[1] <= high[1] and _EMA[1] >= low[1]) or (_EMA[2] <= high[2] and _EMA[2] >= low[2]) or (_EMA[3] <= high[3] and _EMA[3] >= low[3]) or (_EMA[4] <= high[4] and _EMA[4] >= low[4]) ) then 1 else 0;

#END

Last edited:

#### sirigina

##### New member
2019 Donor
@Piper2808t
If you are adding the signal column, probably it would be good to know the approximate straddle cost as well.
You can add this column which approximate theoretical cost of a straddle that is 45 days out.

#Approximate theoretical cost of Straddle 45 days out
2 * (0.4 * ImpVolatility() * Sqrt (45/365)) * close
#END

#### Piper2808t

##### Member
2019 Donor
VIP
wow thats great thanks so much Sirigina

#### sirigina

##### New member
2019 Donor
@Piper2808t
Please let me know how this indicator works for you.

I usually buy 45 day straddle when I see a stock is moving in a tight channel and expecting a catalyst or a surprise in the next 45 days. I will try this as well.

#### 2sureshk

##### Member
How do you manage to buy when it is high volatility as the premium decay will be fast on both CALL and put . Do you but ITM OR OTM OR any specific delta value options consider buying . What is the expected return such as 300% to 500% of return expected?

With similar idea I want to generate 500-800% but did not see any such combination for options

#### sirigina

##### New member
2019 Donor
My approach is not that sophisticated, so take it with a grain of salt.
If a stock moved down to 200 MA and holding there, I see it as buyers and sellers are in equilibrium. On of that if there is another catalyst is in the wings, then the big move is imminent. It doesn't always work out like that. Also, some stocks by nature operate in a channel for long periods of time, I ignore them.

Also, you are right about high volatility, At the money could be expensive. I try to use FIBs to guess how it might move and buy something in that range with in my risk profile.

I don't look for 300% to 500%, instead I look for a quick 50% gain on total premium paid.

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?