Gilgameash
New member
i hate writing code.
made for AAPL 1m timeframe scalping
adjust min_Profit for higher timeframes and higher valued stocks
a combination of indicators.... with an 70% to 80% win rate on AAPL
All indicator used are open scoured.
Kaufman AMA (Adaptive Moving Average)
scalperline (found online don't remember where)
TEMA 3 different lengths
Moving Averages
CumulativeVolumeIndex
FastKcustom
Vortex
buy me a beer.
opening positions
Closing Positions/ minimum profit per share (STILL WIP)
made for AAPL 1m timeframe scalping
adjust min_Profit for higher timeframes and higher valued stocks
a combination of indicators.... with an 70% to 80% win rate on AAPL
All indicator used are open scoured.
Kaufman AMA (Adaptive Moving Average)
scalperline (found online don't remember where)
TEMA 3 different lengths
Moving Averages
CumulativeVolumeIndex
FastKcustom
Vortex
buy me a beer.

opening positions
Rich (BB code):
#Frick my life,I hate writing code
input Strat_trading_timeopen = 0930;
input Strat_trading_timeclose = 1550;
def TIME = if SecondsTillTime(Strat_trading_timeclose) == 0 and SecondsFromTime(Strat_trading_timeclose) == 0 then 1 else 0;
def usetimefilter = yes;
def close_all = if usetimefilter == yes then if SecondsFromTime(Strat_trading_timeopen) >= 0 and SecondsTillTime(Strat_trading_timeclose) >= 0 then 1 else 0 else 1;
def trading_time = !TIME and close_all;
def p = (open[-1]);
# Kaufman AMA (Adaptive Moving Average)
# Mobius
# Chat Room Request 01.29.2017
def n = 10;
def FastSC = 13;
def SlowSC = 30;
def c = close;
def netchg = AbsValue(c - c[n]);
def sumchg = sum(AbsValue(c - c[1]), n);
def KER = (netchg / sumchg);
def SC = (KER * (2/(FastSc+1) - 2/(SlowSC+1)) + 2/(SlowSC+1)) * 2;
def KAMA = KAMA[1] + SC * (c - KAMA[1]);
def up =ohlc4> KAMA;
def down =ohlc4< KAMA;
# End Code Kaufman AMA
#TEMA x3
def price = close[1];
def length = 50;
def ema1 = ExpAverage(price, length);
def ema2 = ExpAverage(ema1, length);
def ema3 = ExpAverage(ema2, length);
def TEMA = 3 * ema1 - 3 * ema2 + ema3;
def length2 = 200;
def ema12 = ExpAverage(price, length2);
def ema22 = ExpAverage(ema12, length2);
def ema32 = ExpAverage(ema22, length2);
def TEMA2 = 3 * ema12 - 3 * ema22 + ema32;
def length3 = 300;
def ema13 = ExpAverage(price, length3);
def ema23 = ExpAverage(ema13, length3);
def ema33 = ExpAverage(ema23, length3);
def TEMA3 = 3 * ema13 - 3 * ema23 + ema33;
def between= if
between(close[1],tema,tema2) or between(close[1],tema2,tema)
or between(open[1],tema,tema2) or between(open[1],tema2,tema)
or between(high[1],tema,tema2) or between(high[1],tema2,tema)
or between(low[1],tema,tema2) or between(low[1],tema2,tema)
then 1 else 0;
#MovingAverage
def fastLengthA = 3;
def mediumLengthA = 8;
def slowLengthA = 21;
def priceA = close[1];
def avgTypeA = AverageType.EXPONENTIAL;
def fastMVA = MovingAverage( avgTypeA, pricea, fastLengtha );
def mediumMVAA = MovingAverage( avgTypea, pricea, mediumLengtha );
def slowMVAA = MovingAverage( avgTypea, pricea, slowLengtha );
def upA= (slowMvaa > slowMvaa[1]) and (mediumMvaa > mediumMvaa[1]) and (fastMVA > fastMVA[1]);
def downA=(slowMvaa < slowMvaa[1]) and (mediumMvaa < mediumMvaa[1]) and (fastMVA < fastMVA[1]);
#FastKCustom
def colorNormLength = 14;
def smLength = 14;
def mfi = if volume[1] > 0 then (high[1] - low[1]) / volume[1] * 100 else 0;
def mul = 50 * mfi * ((high[1] + low[1]) - (high[2] + low[2]));
def EOM = Average(mul, smLength)[1];
def ZeroLine = 0;
def eomup=eom>zeroLine;
def eomdown=eom<zeroLine;
#scalperline
def lengthtt = 100;
def topBand = Highest(high[1], lengthtt);
def bottomBand = Lowest(low[1], lengthtt);
def centerBand = (topBand + bottomBand) / 2;
def MPr = (high[1] + low[1]) / 2;
def factor = 15;
def scalper_line = Average(close[1], factor) - Log(Double.Pi * (Average(TrueRange(high[1], close[1], low[1]), factor)));
#CVI
def breadth = close("$UVOA")[1] - close("$DVOA")[2];
def CVI = if isNaN(close[1]) then Double.NaN else TotalSum(if isNaN(breadth[1]) then 0 else breadth[1]);
def cviup=CVI > CVI[1];
def cvidown=CVI < CVI[1];
def upsig =(TEMA > TEMA2)and(close[1]>TEMA2)and(close[1]>TEMA3)and(between is false);
def downsig=(tema<tema2)and(close[1]<tema2)and(close[1]<TEMA3)and(between is false);
#Vortex?
DEF length4 = 55;
def trSum = sum(TrueRange(high[1], close[1], low[1]), length4);
DEF VIa = if trSum == 0 then 0 else sum(AbsValue(high[1] - low[2]), length4) / trSum;
DEF VI = if trSum == 0 then 0 else sum(AbsValue(low[1] - high[2]), length4) / trSum;
DEF vUP=VIA>VI;
DEF vDOWN=VIA<VI;
#
def allup =up and(TEMA > TEMA2)and(close[1]>TEMA2)and(close[1]>TEMA3)and(between is false);
def alldown=down and (tema<tema2)and(close[1]<tema2)and(close[1]<TEMA3)and(between is false);
#2
DEF allup2=up[1] and upsig[1] and upA[1] and eomup[1] and (((ohlc4[1])>scalper_line[1])and ( scalper_line > scalper_line[1]) and (ohlc4[1])>centerBand[1]) and ( MPr > MPr[1]);
DEF alldown2=down[1] and downsig[1] and downA[1] and eomdown[1] and(((ohlc4[1])<scalper_line[1])and ( scalper_line < scalper_line[1]) and (ohlc4[1])<centerBand[1]) and ( MPr < MPr[1]) ;
#3
DEF allup3=up[1] and upsig[1] and cviup[1] AND upA[1] and eomup[1] AND vUP[1];# and (osc[1] >1) TEMAup[1];
DEF alldown3=down[1] and downsig[1] and cvidown[1] AND downA[1] and eomdown[1] AND vDOWN[1];# and (osc[1]<-1) and downA[1] ;
#4
DEF allup4=up[1] and upsig[1]and cviup[1] and upA[1] and eomup[1] and (((ohlc4[1])>scalper_line[1])and ( scalper_line > scalper_line[1]) and (ohlc4[1])>centerBand[1]) and ( MPr > MPr[1]);
DEF alldown4=down[1] and downsig[1] and cvidown[1] and downA[1] and eomdown[1] and(((ohlc4[1])<scalper_line[1])and ( scalper_line < scalper_line[1]) and (ohlc4[1])<centerBand[1]) and ( MPr < MPr[1]) ;
#5
DEF allup5=up[1] and upsig[1] and cviup[1] AND upA[1] and eomup[1] AND UP[1];# and (osc[1]>1);
DEF alldown5=down[1] and downsig[1] and cvidown[1] AND downA[1] and eomdown[1] AND DOWN[1];# and (osc[1]<-1);
#opening POS
#1
AddOrder(OrderType.BUY_TO_OPEN, trading_time and (allup[1]) , tickcolor = Color.DARK_GREEN, arrowcolor = Color.DARK_GREEN, name = "BUY TO OPEN");
AddOrder(OrderType.SELL_TO_OPEN, trading_time and (alldown[1] ) , tickcolor = Color.DARK_RED, arrowcolor = Color.DARK_RED, name = "SELL TO OPEN");
#2
AddOrder(OrderType.BUY_TO_OPEN, trading_time and (allup2[1]) , tickcolor = Color.DARK_GREEN, arrowcolor = Color.DARK_GREEN, name = "BUY TO OPEN");
AddOrder(OrderType.SELL_TO_OPEN, trading_time and (alldown2[1] ) , tickcolor = Color.DARK_RED, arrowcolor = Color.DARK_RED, name = "SELL TO OPEN");
#3
AddOrder(OrderType.BUY_TO_OPEN, trading_time and (allup3[1]) , tickcolor = Color.DARK_GREEN, arrowcolor = Color.DARK_GREEN, name = "BUY TO OPEN");
AddOrder(OrderType.SELL_TO_OPEN, trading_time and (alldown3[1]) , tickcolor = Color.DARK_RED, arrowcolor = Color.DARK_RED, name = "SELL TO OPEN");
#4
AddOrder(OrderType.BUY_TO_OPEN, trading_time and (allup4[1]) , tickcolor = Color.DARK_GREEN, arrowcolor = Color.DARK_GREEN, name = "BUY TO OPEN");
AddOrder(OrderType.SELL_TO_OPEN, trading_time and (alldown4[1] ) , tickcolor = Color.DARK_RED, arrowcolor = Color.DARK_RED, name = "SELL TO OPEN");
#5
AddOrder(OrderType.BUY_TO_OPEN, trading_time and (allup5[1]) , tickcolor = Color.DARK_GREEN, arrowcolor = Color.DARK_GREEN, name = "BUY TO OPEN");
AddOrder(OrderType.SELL_TO_OPEN, trading_time and (alldown5[1] ) , tickcolor = Color.DARK_RED, arrowcolor = Color.DARK_RED, name = "SELL TO OPEN");
#beer time
Closing Positions/ minimum profit per share (STILL WIP)
Rich (BB code):
#exits
#some parts are still WIP
input MIN_PROFIT = .3;
input Close_EndofDay =no;#hint recommend "NO"
def TIME = if SecondsTillTime(1555) == 0 and SecondsFromTime(1555) == 0 then 1 else 0;
def usetimefilter = yes;
def timeopen = 0930;
def timeclose = 1555;
def close_all = if usetimefilter == yes then if SecondsFromTime(timeopen) >= 0 and SecondsTillTime(timeclose) >= 0 then 1 else 0 else 1;
def trading_time = !TIME and close_all;
def p = (open[-1]);
#close End of days
def timeFrame = GetAggregationPeriod();
def EOD = if timeFrame ==
AggregationPeriod.MIN and SecondsTillTime(1557) == 0 then 1 else if timeFrame == AggregationPeriod.TWO_MIN and SecondsTillTime(1556) == 0 then 1 else if timeFrame == AggregationPeriod.THREE_MIN and SecondsTillTime(1554) == 0 then 1 else if timeFrame == AggregationPeriod.FOUR_MIN and SecondsTillTime(1554) == 0 then 1 else if timeFrame == AggregationPeriod.FIVE_MIN and SecondsTillTime(1550) == 0 then 1 else if timeFrame == AggregationPeriod.TEN_MIN and SecondsTillTime(1540) == 0 then 1 else if timeFrame == AggregationPeriod.FIFTEEN_MIN and SecondsTillTime(1530) == 0 then 1 else if timeFrame == AggregationPeriod.TWENTY_MIN and SecondsTillTime(1530) == 0 then 1 else if timeFrame == AggregationPeriod.THIRTY_MIN and SecondsTillTime(1500) == 0 then 1 else if timeFrame == AggregationPeriod.HOUR and SecondsTillTime(1430) == 0 then 1 else if timeFrame == AggregationPeriod.TWO_HOURS and SecondsTillTime(1330) == 0 then 1 else 0;
addOrder(OrderType.SELL_TO_CLOSE, EOD and Close_EndofDay, tickColor = Color.DARK_GREEN, arrowColor = Color.DARK_GREEN, name = "SELL TO CLOSE");
addOrder(OrderType.BUY_TO_CLOSE,EOD and Close_EndofDay, tickColor = Color.DARK_RED, arrowColor = Color.DARK_RED, name = "BUY TO CLOSE");
def LONG_PROFIT = (close[1]) > (EntryPrice() + (MIN_PROFIT));
def SHORT_PROFIT = (close[1]) < (EntryPrice() - (MIN_PROFIT));
#long
AddOrder(OrderType.sell_TO_CLOSE, LONG_PROFIT and trading_time, tickcolor = Color.DARK_GREEN, arrowcolor = Color.DARK_GREEN, name = "SELL TO CLOSE");
#short
AddOrder(OrderType.buy_TO_CLOSE, shoRT_PROFIT and trading_time, tickcolor = Color.DARK_RED, arrowcolor = Color.DARK_RED, name = "BUY TO CLOSE");
def reward =(min_PROFIT*500)*5;
def risk = (-reward) ;
##WIP
def AO = Average(hl2, 10) - Average(hl2, 34);
def AOup= AO[1]>0;
def AOdown= AO[1]<0;
def position_total = EntryPrice() * 500;
def current_position = open * 500;
def reward_profit = if ((current_position - position_total) > reward) then 1 else 0;
def reward_profit2 = if ((current_position - position_total) < risk) then 1 else 0;
AddOrder(type = OrderType.SELL_TO_CLOSE, condition = reward_profit2 and aodown and trading_time, name = "SELL TO CLOSE", tickColor = Color.DARK_GREEN, arrowColor = Color.DARK_GREEN);
AddOrder(type = OrderType.BUY_TO_CLOSE, condition = reward_profit and aoup and trading_time, tickcolor = Color.DARK_RED, arrowcolor = Color.DARK_RED, name = "BUY TO CLOSE");
#end WIP
#reversal exit
def fastLengthA = 3;
def mediumLengthA = 8;
def slowLengthA = 21;
def priceA = close[1];
def avgTypeA = AverageType.EXPONENTIAL;
def fastMVA = MovingAverage( avgTypeA, pricea, fastLengtha );
def mediumMVAA = MovingAverage( avgTypea, pricea, mediumLengtha );
def slowMVAA = MovingAverage( avgTypea, pricea, slowLengtha );
def upA= (slowMvaa > slowMvaa[1]) and (mediumMvaa > mediumMvaa[1]) and (fastMVA > fastMVA[1]);
def downA=(slowMvaa < slowMvaa[1]) and (mediumMvaa < mediumMvaa[1]) and (fastMVA < fastMVA[1]);
def colorNormLength = 14;
def smLength = 14;
def mfi = if volume[1] > 0 then (high[1] - low[1]) / volume[1] * 100 else 0;
def mul = 50 * mfi * ((high[1] + low[1]) - (high[2] + low[2]));
def EOM = Average(mul, smLength)[1];
def ZeroLine = 0;
def eomup=eom>zeroLine;
def eomdown=eom<zeroLine;
def lengthtt = 100;
def topBand = Highest(high[1], lengthtt);
def bottomBand = Lowest(low[1], lengthtt);
def centerBand = (topBand + bottomBand) / 2;
def MPr = (high[1] + low[1]) / 2;
def factor = 15;
def scalper_line = Average(close[1], factor) - Log(Double.Pi * (Average(TrueRange(high[1], close[1], low[1]), factor)));
def breadth = close("$UVOA")[1] - close("$DVOA")[2];
def CVI = if isNaN(close[1]) then Double.NaN else TotalSum(if isNaN(breadth[1]) then 0 else breadth[1]);
def cviup=CVI > CVI[1];
def cvidown=CVI < CVI[1];
def price = close[1];
def length = 50;
def ema1 = ExpAverage(price, length);
def ema2 = ExpAverage(ema1, length);
def ema3 = ExpAverage(ema2, length);
def TEMA = 3 * ema1 - 3 * ema2 + ema3;
def length2 = 200;
def ema12 = ExpAverage(price, length2);
def ema22 = ExpAverage(ema12, length2);
def ema32 = ExpAverage(ema22, length2);
def TEMA2 = 3 * ema12 - 3 * ema22 + ema32;
def length3 = 300;
def ema13 = ExpAverage(price, length3);
def ema23 = ExpAverage(ema13, length3);
def ema33 = ExpAverage(ema23, length3);
def TEMA3 = 3 * ema13 - 3 * ema23 + ema33;
def between= if
between(close[1],tema,tema2) or between(close[1],tema2,tema)
or between(open[1],tema,tema2) or between(open[1],tema2,tema)
or between(high[1],tema,tema2) or between(high[1],tema2,tema)
or between(low[1],tema,tema2) or between(low[1],tema2,tema)
then 1 else 0;
def upsig =(TEMA > TEMA2)and(close[1]>TEMA2)and(close[1]>TEMA3)and(between is false);
def downsig=(tema<tema2)and(close[1]<tema2)and(close[1]<TEMA3)and(between is false);
def n = 10;
def FastSC = 13;
def SlowSC = 30;
def c = close;
def netchg = AbsValue(c - c[n]);
def sumchg = sum(AbsValue(c - c[1]), n);
def KER = (netchg / sumchg);
def SC = (KER * (2/(FastSc+1) - 2/(SlowSC+1)) + 2/(SlowSC+1)) * 2;
def KAMA = KAMA[1] + SC * (c - KAMA[1]);
def up =ohlc4> KAMA;
def down =ohlc4< KAMA;
def allup=up[1] and upsig[1] and upA[1] and eomup[1] and (((ohlc4[1])>scalper_line[1])and ( scalper_line > scalper_line[1]) and (ohlc4[1])>centerBand[1]) and ( MPr > MPr[1]);
def alldown=down[1] and downsig[1] and downA[1] and eomdown[1] and(((ohlc4[1])<scalper_line[1])and ( scalper_line < scalper_line[1]) and (ohlc4[1])<centerBand[1]) and ( MPr < MPr[1]) ;
def allup2=up[1] and upsig[1] and cviup[1] AND upA[1] and eomup[1] AND UP[1];# and (osc[1] >1) TEMAup[1];
def alldown2=down[1] and downsig[1] and cvidown[1] AND downA[1] and eomdown[1] AND DOWN[1];# and (osc[1]<-1) and downA[1] ;
addOrder(OrderType.SELL_TO_CLOSE, (alldown2[1] or alldown[1]), tickColor = Color.DARK_grEEN, arrowColor = Color.DARK_grEEN, name = "SELL TO CLOSE");
addOrder(OrderType.BUY_TO_CLOSE,(allup2[1] or allup[1]), tickColor = Color.DARK_RED, arrowColor = Color.DARK_RED, name = "BUY TO CLOSE");
#end reversal