The Open Range Strategy with Dynamic Profit Target

Author: ChaoZhang, Date: 2023-09-10 00:10:22
Tags:

img

The Open Range Strategy with Dynamic Profit Target is a technical trading strategy that uses the opening range of the market to identify potential trading opportunities. The strategy is based on the idea that the opening range of the market can provide valuable information about the direction of the market in the short term.

The strategy works by first calculating the opening range of the market. The opening range is the difference between the high price and the low price of the first bar of the trading day. The strategy then identifies potential trading opportunities by looking for a break above or below the opening range.

If the price breaks above the opening range, the strategy will enter a long position. If the price breaks below the opening range, the strategy will enter a short position. The strategy will exit the position when the price reaches a predetermined profit target or stop loss.

The profit target for the strategy is dynamic, meaning that it changes as the price moves. The profit target is calculated based on the opening range and the current price of the market. The strategy will exit the position when the price reaches a predetermined percentage of the opening range.

The stop loss for the strategy is also dynamic, meaning that it changes as the price moves. The stop loss is calculated based on the current price of the market and the predetermined percentage of the opening range. The strategy will exit the position if the price reaches the stop loss.

The Open Range Strategy with Dynamic Profit Target is a relatively simple strategy to implement, but it can be effective in identifying short-term trading opportunities. However, it is important to remember that no trading strategy is guaranteed to be profitable. It is always important to backtest the strategy on historical data before using it in live trading.

Here is a more detailed explanation of the different components of the strategy:

  • Opening Range: The opening range is the difference between the high price and the low price of the first bar of the trading day. It is a measure of the volatility of the market at the beginning of the day.
  • Breakout: A breakout occurs when the price breaks above or below the opening range. This is a signal that the market is likely to continue moving in the direction of the breakout.
  • Profit Target: The profit target is the predetermined percentage of the opening range that the strategy will try to reach before exiting the position.
  • Stop Loss: The stop loss is the predetermined price at which the strategy will exit the position if the market moves against the trade. The Open Range Strategy with Dynamic Profit Target is a versatile strategy that can be used on a variety of timeframes and markets. However, it is important to note that the strategy is most effective in trending markets. In choppy markets, the strategy may generate a lot of false signals.

Here are some tips for using the Open Range Strategy with Dynamic Profit Target:

  • Use a stop loss to protect your profits.
  • Use a trailing stop loss to lock in profits as the market moves in your favor.
  • Backtest the strategy on historical data before using it in live trading.
  • Use a variety of other indicators to confirm the signals generated by the Open Range Strategy with Dynamic Profit Target. The Open Range Strategy with Dynamic Profit Target is a powerful tool that can be used to identify short-term trading opportunities. However, it is important to use the strategy wisely and to understand its limitations. By following the tips above, you can increase your chances of success when using this strategy.

I hope this article is helpful. Let me know if you have any other questions.


/*backtest
start: 2023-08-09 00:00:00
end: 2023-09-08 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
args: [["v_input_10",true]]
*/

//@version=2
//Created by Frenchy/lisfse/Francois Seguin on 2019-01-22"
strategy(title="Open_Range_Strategy_with_dynamic_PT_by_frenchy", shorttitle="O/R Strategy Dynamic PT  ", overlay=true)

// === INPUT BACKTEST RANGE ===
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromYear  = input(defval = 2017, title = "From Year", minval = 2010)
ToMonth   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToDay     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear    = input(defval = 9999, title = "To Year", minval = 2016)
// === FUNCTION EXAMPLE ===
start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)  // backtest start window
finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)        // backtest finish window
window()  => time >= start and time <= finish ? true : false // create function "within window of time"


// === INPUT SESSION RANGE ===
SessionLenght = input('0930-1100',  title="Session Lenght")
res = input('30', title="Length Of Opening Range?")
Notradetime= time('30', '0930-1000')
Tradetime= time('1', '1000-1100')

// === LONG/SHORT STRATEGY AND ALERT SELECTION     ===

Select_long = input(true, title="Long Strategy and alert ?")
Select_short = input(false, title="Short Strategy and alert ?")


//Session Rules
sessToUse = SessionLenght
bartimeSess = time('D', sessToUse)
fr2to17 =  time(timeframe.period, sessToUse) 
newbarSess = bartimeSess != bartimeSess[1]
high_range = valuewhen(newbarSess,high,0)
low_range = valuewhen(newbarSess,low,0)
adopt(r, s) => security(syminfo.tickerid, r, s)


//Formula For Opening Range
highRes = adopt(res, high_range)
lowRes = adopt(res, low_range)
range = highRes - lowRes

//Highlighting Line Rules For Opening Range
highColor = Notradetime  ? red : green
lowColor = Notradetime  ? red : green


//Plot Statements For Opening Range Lines
openRangeHigh = plot(fr2to17 > 0 ? highRes : na, color=highColor, style=linebr, linewidth=4,title="OR High")
openRangeLow = plot(fr2to17 > 0 ? lowRes : na, color=lowColor, style=linebr, linewidth=4,title="OR Low")


//Price definition
price = security(syminfo.tickerid, timeframe.period, close)
haclose = ((open + high + low + close)/4)
//aopen = na(haopen[1]) ? (open + close)/2 : (haopen[1] + haclose[1]) / 2
MA20= sma(price,20)


//Plots For Profit Targe 2
bgcolor(Notradetime? red:na)


///////////////////////////////////////Strategy Definition ///////////////////////////////////////////////////////////////


/////////////////////////////////////////Long Strategy////////////////////////////////////////////////////////////////////
//Enter Strategy Long criteria 
Enterlong = (crossover(price,highRes) and Select_long and Tradetime ? 1:0 ) and (Notradetime ? 0:1) 
plotarrow(Enterlong, color=black, style=shape.triangleup, text="Enter", location=location.belowbar, minheight = 80, maxheight=80, offset=0)

//Exit Strategy Long  criteria
Exitlong  = crossunder(price,highRes) or crossunder(price,MA20) 
//plotshape(Exitlong, color=black, style=shape.triangledown, text="Exit", location=location.abovebar)

/////////////////////////////////////////Long Strategy Excution////////////////////////////////////////////////////////
strategy.entry ("Call", strategy.long, when=Enterlong and window())
strategy.close("Call", when=Exitlong and window())




//////////////////////////////////////////Short Strategy////////////////////////////////////////////////////////////////

//Enter Strategy Short criteria
Entershort = crossunder(price,lowRes) and time(res, SessionLenght) and Select_short ? 1:0

// Exit Strategy short criteria
Exitshort  =  crossover(price,lowRes) or crossover(haclose,MA20)


///////////////////////////////////////Strategy execution Short///////////////////////////////////////////////////////

strategy.entry ("put", strategy.short, when=Entershort and window()) 
strategy.close("put", when=Exitshort and window())



 





More