Hi Jedicoders and fellow Padawans,
In my path of mastering “coding” I’ve reached the next level where I try to include the Ultimate Oscillator and have a price divergence from the oscillator. I have read through other related and well documented topics here on PRC and even tried the Vonasi-style with a couple of glasses wine, but I just cant figure it out. I actually have two simple(?) requests that i hope someone could help me with:
- How to include the Ultimate Oscillator to my code and have a price divergence both for Buy and Sell
- How to also include an entry signal to Long that buys 1 pip over previous high and to Sell that sellshort 1 pip under previous low
Ultimate Oscillator found here: https://www.prorealcode.com/prorealtime-indicators/ultimate-oscillator/
Strategy based on Smash Day pattern, found here: https://www.prorealcode.com/prorealtime-indicators/larry-williams-smash-days/
This is my strategy so far:
//-------------------------------------------------------------------------
// Code Name: SmashBar Larry Style
//-------------------------------------------------------------------------
//------------------------------------------------------------------------------------//
// Strategy: Smash Day Pattern - Type C
// Developer: Larry Williams
// Concept: Trading strategy based on a failed price pattern.
// Time Frame: Any ?
// Inspiration: https://oxfordstrat.com/trading-strategies/smash-day-pattern-c/
//------------------------------------------------------------------------------------//
// Definition of code parameters
DEFPARAM CumulateOrders = false // Cumulating positions deactivated
DEFPARAM PreloadBars = 10000
// Position Size
positionsize=1
tradetype=3 // long = 1 ; short = 2 ; long&short = 3
//====== SmashBar STRATEGY ==============================================
// Long pattern
c10=low<lowest[2](low[1])
c11=close<low[1]
long = c10 and c11
// Short pattern
c12=high>highest[2](high[1])
c13=close>high[1]
short = c12 and c13
// Conditions to enter Long positions
if tradetype=1 or tradetype=3 then
IF NOT ONMARKET AND long THEN
BUY positionsize CONTRACT AT MARKET
ENDIF
endif
// Conditions to enter Short positions
if tradetype=2 or tradetype=3 then
IF NOT ONMARKET AND short THEN
SELLSHORT positionsize CONTRACT AT MARKET
ENDIF
endif
//==== TRAILING STOP %
trailingPercent = .24 //org .26
stepPercent = .012 //org .014
if onmarket then
trailingstart = tradeprice(1)*(trailingpercent/100) //trailing will start @trailinstart points profit
trailingstep = tradeprice(1)*(stepPercent/100) //% step to move the stop
endif
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart THEN
newSL = tradeprice(1)+trailingstep
ENDIF
//next moves
IF newSL>0 AND close-newSL>trailingstep THEN
newSL = newSL+trailingstep
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart THEN
newSL = tradeprice(1)-trailingstep
ENDIF
//next moves
IF newSL>0 AND newSL-close>trailingstep THEN
newSL = newSL-trailingstep
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
And this is the Ultimate Oscillator:
//Ultimate Oscillator by Larry Williams
BuyPressure = close - min(low, close[1])
TrueRange = TR
per = 7
avper = summation[per](BuyPressure) / summation[per](TrueRange)
avper2 = summation[per * 2](BuyPressure) / summation[per * 2](TrueRange)
avper4 = summation[per * 4](BuyPressure) / summation[per * 4](TrueRange)
UltimateOscillator = 100 * ((4 * avper) + (2 * avper2) + avper4) / 7
lowerline = 30
upperline = 70
return UltimateOscillator coloured(0,0,0), lowerline coloured(0,0,255) as "lower line", upperline coloured(0,0,255) as "upper line"
…*pour another glass of wine*.
hello keewee hope you are well. I like your reasoning, but I can’t help you yet … too bad. Have you made progress on your own?