HOW CAN I ADD TIME START MARKET OPEN TO MARKET CLOSE?

Happyfadez

New member
2019 Donor
  1. declare upper; input period = 45; input stdev_length = 1; input extrema_stdev_length = 20; input extrema_stdev_number = 2; def vol = volume; def op = open; def cl = close; def p = (cl - op) * vol; def osc = EhlersSuperSmootherFilter(p, period); def osc_diff = osc - osc[1]; def unclear_band = StDev(osc, stdev_length); def extrema = extrema_stdev_number * StDev(osc, extrema_stdev_length); def bullish_condition = Crosses(osc, unclear_band, CrossingDirection.ABOVE); Alert(bullish_condition, "Bullish!", Alert.ONCE, Sound.Ding); def bearish_condition = Crosses(osc, -unclear_band, CrossingDirection.BELOW); Alert(bearish_condition, "Bearish!", Alert.ONCE, Sound.Chimes); def out_bullish_trade_condition = Crosses(osc_diff, 0, CrossingDirection.BELOW); Alert(out_bullish_trade_condition, "Take Profit on Bullish Trades!", Alert.ONCE, Sound.Ding); def out_bearish_trade_condition = Crosses(osc_diff, 0, CrossingDirection.ABOVE); Alert(out_bearish_trade_condition, "Take Profit on Bearish Trades!", Alert.ONCE, Sound.Chimes); AddLabel(yes, if osc >= 0 and osc_diff >= 0 then "BUY" else if osc < 0 and osc_diff < 0 then "SELL" else if osc >= 0 and osc_diff < 0 then "LONG OUT" else "SHORT OUT", if osc >= 0 and osc_diff >= 0 then Color.GREEN else if osc < 0 and osc_diff < 0 then Color.RED else if osc >= 0 and osc_diff < 0 then Color.DARK_GREEN else Color.YELLOW); def long_sl = close - ATR(); def short_sl = close + ATR(); AddChartBubble(bullish_condition, long_sl, "Long " + close + " " + "stop loss " + long_sl, color=Color.GREEN, up=no); AddChartBubble(bearish_condition, short_sl, "Short " + close + " " + "stop loss " + short_sl, color=Color.RED, up=yes); plot bull = bullish_condition; bull.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); bull.SetDefaultColor(Color.GREEN); plot bear = bearish_condition; bear.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); bear.SetDefaultColor(Color.RED);
 
Solution
Ruby:
declare upper;

input period = 45;
input stdev_length = 1;
input extrema_stdev_length = 20;
input extrema_stdev_number = 2;

################################################
def starttime = 0930;
def endtime = 1600;
def RTH = secondstilltime(endtime) >= 0 and secondsfromtime(starttime) >=0;
################################################

def vol = volume;
def op = open;
def cl = close;
def p = (cl - op) * vol;
def osc = EhlersSuperSmootherFilter(p, period);
def osc_diff = osc - osc[1];
def unclear_band = StDev(osc, stdev_length);
def extrema = extrema_stdev_number * StDev(osc, extrema_stdev_length);

def bullish_condition = RTH and Crosses(osc, unclear_band, CrossingDirection.ABOVE);
Alert(bullish_condition, "Bullish!", Alert.ONCE...
Ruby:
declare upper;

input period = 45;
input stdev_length = 1;
input extrema_stdev_length = 20;
input extrema_stdev_number = 2;

################################################
def starttime = 0930;
def endtime = 1600;
def RTH = secondstilltime(endtime) >= 0 and secondsfromtime(starttime) >=0;
################################################

def vol = volume;
def op = open;
def cl = close;
def p = (cl - op) * vol;
def osc = EhlersSuperSmootherFilter(p, period);
def osc_diff = osc - osc[1];
def unclear_band = StDev(osc, stdev_length);
def extrema = extrema_stdev_number * StDev(osc, extrema_stdev_length);

def bullish_condition = RTH and Crosses(osc, unclear_band, CrossingDirection.ABOVE);
Alert(bullish_condition, "Bullish!", Alert.ONCE, Sound.Ding);

def bearish_condition = RTH and Crosses(osc, -unclear_band, CrossingDirection.BELOW);
Alert(bearish_condition, "Bearish!", Alert.ONCE, Sound.Chimes);

def out_bullish_trade_condition = RTH and Crosses(osc_diff, 0, CrossingDirection.BELOW);
Alert(out_bullish_trade_condition, "Take Profit on Bullish Trades!", Alert.ONCE, Sound.Ding);

def out_bearish_trade_condition = RTH and Crosses(osc_diff, 0, CrossingDirection.ABOVE);
Alert(out_bearish_trade_condition, "Take Profit on Bearish Trades!", Alert.ONCE, Sound.Chimes);

AddLabel(yes, if osc >= 0 and osc_diff >= 0 then "BUY" else if osc < 0 and osc_diff < 0 then "SELL" else if osc >= 0 and osc_diff < 0 then "LONG OUT" else "SHORT OUT", if osc >= 0 and osc_diff >= 0 then Color.GREEN else if osc < 0 and osc_diff < 0 then Color.RED else if osc >= 0 and osc_diff < 0 then Color.DARK_GREEN else Color.YELLOW);

def long_sl = close - ATR();
def short_sl = close + ATR();
AddChartBubble(bullish_condition, long_sl, "Long " + close + " " + "stop loss " + long_sl, color=Color.GREEN, up=no);

AddChartBubble(bearish_condition, short_sl, "Short " + close + " " + "stop loss " + short_sl, color=Color.RED, up=yes);

plot bull = bullish_condition;
bull.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bull.SetDefaultColor(Color.GREEN);

plot bear = bearish_condition; bear.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bear.SetDefaultColor(Color.RED);
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
352 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top