YungTraderFromMontana
Well-known member
@RickAns @HighBredCloud @Playstation @ezrollin @markos
Here is the latest and completely reshaped version intended for uptrending equities, I have yet to find a different strategy that can beat it without taking thousands of trades. If you guys want a ranged version for commodities or a downtrend version feel free to ask.
I was able to heavily cut the frequency of trades while also increasing p/l, for example on SPY where it made 355 dollars going up and 215 going down on 150 orders in the last 26 years. It would certainly would be even crazier on more volatile stocks.
This is meant for long term trading but I think I'll start working on a short term intraday version, It shouldn't be to hard to modify it. If I were doing an intraday version how many times a day would be ideal for you guys? 10 trades a day on average?
Here is the code
The left has the bull strategy the right has the bear strategy. They aren't opposites so I can't combine them. One last thing to note is that the bull strategy is more developed and better in more scenarios while the bear strategy shines in 2008 crash like environments.
Bull
BEAR
The thing I'm working on right now for the Bull side is getting out quicker from trades when prices tank. I might relate volatility into this somehow.
Here is the latest and completely reshaped version intended for uptrending equities, I have yet to find a different strategy that can beat it without taking thousands of trades. If you guys want a ranged version for commodities or a downtrend version feel free to ask.
I was able to heavily cut the frequency of trades while also increasing p/l, for example on SPY where it made 355 dollars going up and 215 going down on 150 orders in the last 26 years. It would certainly would be even crazier on more volatile stocks.
This is meant for long term trading but I think I'll start working on a short term intraday version, It shouldn't be to hard to modify it. If I were doing an intraday version how many times a day would be ideal for you guys? 10 trades a day on average?
Here is the code
The left has the bull strategy the right has the bear strategy. They aren't opposites so I can't combine them. One last thing to note is that the bull strategy is more developed and better in more scenarios while the bear strategy shines in 2008 crash like environments.
Bull
Code:
#TMO True Momentum Oscillator with Higher Aggregation _Mobius
#Tuesday, May 15, 2018 12:36 PM
## OneNote Archive Name: TMO True Momentum Oscillator with Higher Aggregation _Mobius
## Archive Section: Momentum
## Suggested Tos Name: TrueMomentumOscillator_w_HigherAggregation_Mobius
## Archive Date: 5.15.2018
## Archive Notes:
## 08:43 Mobius: Well give it a few days to get altered, muched, distorted and twisted. Then when it get back to being used as intended someone will start making money with it.
## 08:45 Mobius: Oh and in my view - It's highest and best use is as designed with a secondary aggregation plotted either on it or with it around 5 to 10 time higher.
## "##" indicates an addition or adjustment by the OneNote Archivist
## Original Code Follows
# TMO ((T)rue (M)omentum (O)scillator) With Higher Aggregation
# Mobius
# V01.05.2018
#hint: TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.
input length = 14;
input calcLength = 5;
input smoothLength = 3;
input agg = AggregationPeriod.DAY;
input agg2 = AggregationPeriod.Two_DAYS;
input agg3 = AggregationPeriod.THREE_DAYS;
input agg4 = AggregationPeriod.four_DAYS;
input agg5 = AggregationPeriod.weeK;
def zeroline = 0;
def o = open(period = agg);
def c = close(period = agg);
def data = fold i = 0 to length
with s
do s + (if c > getValue(o, i)
then 1
else if c < getValue(o, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
def zero = if isNaN(c) then double.nan else 0;
def ob = if isNaN(c) then double.nan else round(length * .5);
def os = if isNaN(c) then double.nan else -round(length * .05);
def o2 = open(period = agg2);
def c2 = close(period = agg2);
def data2 = fold i2 = 0 to length
with s2
do s2 + (if c2 > getValue(o2, i2)
then 1
else if c2 < getValue(o2, i2)
then - 1
else 0);
def EMA52 = ExpAverage(data2, calcLength);
def Main2 = ExpAverage(EMA52, smoothLength);
def Signal2 = ExpAverage(Main2, smoothLength);
def o3 = open(period = agg3);
def c3 = close(period = agg3);
def data3 = fold i3 = 0 to length
with s3
do s3 + (if c3 > getValue(o3, i3)
then 1
else if c3 < getValue(o3, i3)
then - 1
else 0);
def EMA53 = ExpAverage(data3, calcLength);
def Main3 = ExpAverage(EMA53, smoothLength);
def Signal3 = ExpAverage(Main3, smoothLength);
def o4 = open(period = agg4);
def c4 = close(period = agg4);
def data4 = fold i4 = 0 to length
with s4
do s4 + (if c4 > getValue(o4, i4)
then 1
else if c4 < getValue(o4, i4)
then - 1
else 0);
def EMA54 = ExpAverage(data4, calcLength);
def Main4 = ExpAverage(EMA54, smoothLength);
def Signal4 = ExpAverage(Main4, smoothLength);
def o5 = open(period = agg5);
def c5 = close(period = agg5);
def data5 = fold i5 = 0 to length
with s5
do s5 + (if c5 > getValue(o5, i5)
then 1
else if c5 < getValue(o5, i5)
then - 1
else 0);
def EMA55 = ExpAverage(data5, calcLength);
def Main5 = ExpAverage(EMA55, smoothLength);
def Signal5 = ExpAverage(Main5, smoothLength);
plot bullish = (Main > Signal) and (Main2 > Signal2) and (Main3 > Signal3) and (Main4 > Signal4) and (Main5 < Ob);
plot bearish = (Main < Signal) and (Main2 < Signal2) and (Main3 < Signal3);
def sellshort = (Main4 > Signal4);
def selllong = (Main5 < Signal5) and (Signal5 < ob);
def SSS = if sellshort then 100 else if selllong then -100 else 0;
def SS = if bullish then 100 else if bearish then -100 else 0;
def sBuy = SS crosses above 0;
def sSell = SS crosses below 0;
def sbuysell = SSS crosses below 0;
def SSellbuy = SSS crosses above 0;
AddOrder(OrderType.Buy_TO_OPEN, condition = Sbuy
, price = open[-1], 1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "BE");
AddOrder(OrderType.Sell_to_Close, condition = sbuysell
, price = open[-1], 1, tickcolor = Color.RED, arrowcolor = Color.RED, name = "SE");
Code:
#TMO True Momentum Oscillator with Higher Aggregation _Mobius
#Tuesday, May 15, 2018 12:36 PM
## OneNote Archive Name: TMO True Momentum Oscillator with Higher Aggregation _Mobius
## Archive Section: Momentum
## Suggested Tos Name: TrueMomentumOscillator_w_HigherAggregation_Mobius
## Archive Date: 5.15.2018
## Archive Notes:
## 08:43 Mobius: Well give it a few days to get altered, muched, distorted and twisted. Then when it get back to being used as intended someone will start making money with it.
## 08:45 Mobius: Oh and in my view - It's highest and best use is as designed with a secondary aggregation plotted either on it or with it around 5 to 10 time higher.
## "##" indicates an addition or adjustment by the OneNote Archivist
## Original Code Follows
# TMO ((T)rue (M)omentum (O)scillator) With Higher Aggregation
# Mobius
# V01.05.2018
#hint: TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.
input length = 14;
input calcLength = 5;
input smoothLength = 3;
input agg = AggregationPeriod.DAY;
input agg2 = AggregationPeriod.TWO_DAYS;
input agg3 = AggregationPeriod.THREE_DAYS;
input agg4 = AggregationPeriod.FOUR_DAYS;
input agg5 = AggregationPeriod.WEEK;
input agg6 = AggregationPeriod.Month;
input length2 = 14;
input price = close;
input averageType = AverageType.WILDERS;
input length3 = 10;
input overBought = -20;
input overSold = -80;
def hh = Highest(high, length);
def ll = Lowest(low, length);
def result = if hh == ll then -100 else (hh - close) / (hh - ll) * (-100);
def WR = if result > 0 then 0 else result;
def NetChgAvg = MovingAverage(averageType, price - price[1], length2);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length2);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def o = open(period = agg);
def c = close(period = agg);
def data = fold i = 0 to length
with s
do s + (if c > GetValue(o, i)
then 1
else if c < GetValue(o, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
def zero = if IsNaN(c) then Double.NaN else 0;
def ob = if IsNaN(c) then Double.NaN else Round(length * .5);
def os = if IsNaN(c) then Double.NaN else -Round(length * .5);
def o2 = open(period = agg2);
def c2 = close(period = agg2);
def data2 = fold i2 = 0 to length
with s2
do s2 + (if c2 > GetValue(o2, i2)
then 1
else if c2 < GetValue(o2, i2)
then - 1
else 0);
def EMA52 = ExpAverage(data2, calcLength);
def Main2 = ExpAverage(EMA52, smoothLength);
def Signal2 = ExpAverage(Main2, smoothLength);
def o3 = open(period = agg3);
def c3 = close(period = agg3);
def data3 = fold i3 = 0 to length
with s3
do s3 + (if c3 > GetValue(o3, i3)
then 1
else if c3 < GetValue(o3, i3)
then - 1
else 0);
def EMA53 = ExpAverage(data3, calcLength);
def Main3 = ExpAverage(EMA53, smoothLength);
def Signal3 = ExpAverage(Main3, smoothLength);
def o4 = open(period = agg4);
def c4 = close(period = agg4);
def data4 = fold i4 = 0 to length
with s4
do s4 + (if c4 > GetValue(o4, i4)
then 1
else if c4 < GetValue(o4, i4)
then - 1
else 0);
def EMA54 = ExpAverage(data4, calcLength);
def Main4 = ExpAverage(EMA54, smoothLength);
def Signal4 = ExpAverage(Main4, smoothLength);
def o5 = open(period = agg5);
def c5 = close(period = agg5);
def data5 = fold i5 = 0 to length
with s5
do s5 + (if c5 > GetValue(o5, i5)
then 1
else if c5 < GetValue(o5, i5)
then - 1
else 0);
def EMA55 = ExpAverage(data5, calcLength);
def Main5 = ExpAverage(EMA55, smoothLength);
def Signal5 = ExpAverage(Main5, smoothLength);
def o6 = open(period = agg6);
def c6 = close(period = agg6);
def data6 = fold i6 = 0 to length
with s6
do s6 + (if c6 > GetValue(o6, i6)
then 1
else if c6 < GetValue(o6, i6)
then - 1
else 0);
def EMA56 = ExpAverage(data5, calcLength);
def Main6 = ExpAverage(EMA55, smoothLength);
def Signal6 = ExpAverage(Main5, smoothLength);
plot bullish = (Main < os) and (Main2 > Signal2) and (Main3 > Signal3) and (Main4 > Signal4) and ((Main and Main2 and Main3 and Main4) < os);
plot bearish = (Main4 < Signal2) and (Signal5 < ob) and (Main6 < Signal6);
def sellshort = (Main5 > Signal5);
def selllong = (Main3 < Signal3);
def SSS = if sellshort then 100 else if selllong then -100 else 0;
def SS = if bullish then 100 else if bearish then -100 else 0;
def sBuy = SS crosses above 0;
def sSell = SS crosses below 0;
def sbuysell = SSS crosses below 0;
def SSellbuy = SSS crosses above 0;
AddOrder(OrderType.SELL_TO_OPEN, condition = sSell, price = open[-1], 1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN);
AddOrder(OrderType.BUY_TO_CLOSE, condition = SSellbuy, price = open[-1], 1, tickcolor = Color.RED, arrowcolor = Color.RED);