The AAPL scalp Collector For ThinkOrSwim

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

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
 

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

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

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
Can you share your setup my friend?
Thanks for the amazing post!
 
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

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
Like Betozenho said, thank you for the great post :) I tried looking at the script in tos, but am getting mixed results. Would you be willing to share a link to your set-up? Beers on me brother!
 
@Gilgameash
So it seems like the 2 codes that are accessible (so far) are the buy and sell strategies. Do you create conditional orders based on the strategies you have above?
Also, were you able to share your chart setups via 'share charts' + 'share grid'?

thanks for posting man this seems aweswome
 
Last edited by a moderator:
I do like this script. However I back-tested this into a strategy on buy-sell and found that it does rather poorly under certain market conditions -- in particular 2021 and 2020. Ondemand is pretty slow so it takes a while to test this since you can only use 1min on 30 days.

I recommend integrating in a trailing stop since this script has some losers.
 
This looks amazing! Thanks for all your contributions :)) I'm curious, how would you personally trade this? Also, is there any way to code for not holding a position overnight (closing all positions at the end of day)? Looks like we got burned a few times by holding overnight.
working on this one currently, in the origin post I may have "#" the end of day order out
https://tos.mx/MkFpR8h


Rich (BB code):
#test
input MIN_PROFIT = .3;
input Close_EndofDay =yes;#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 at End of day
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");
## finished shoould close on the 2nd to last bar of day

#profit target and stoploss
#losses have a multiple((MIN_PROFIT* 3), helps filter out false losses

def entryPrice = entryPrice();
DEF profitLONG =(entryPrice +(MIN_PROFIT * 1));
DEF profitshort =(entryPrice -(MIN_PROFIT * 1));

DEF losslong =(entryPrice -(MIN_PROFIT * 3));
DEF lossshort =(entryPrice +(MIN_PROFIT * 3));

input Use_tested_stoploss=no;
##
addOrder(OrderType.SELL_TO_CLOSE, (close[1] > profitLONG) AND TRAding_time, tickColor = Color.DARK_GREEN, arrowColor = Color.DARK_GREEN, name = "SELL TO CLOSE");

addOrder(OrderType.SELL_TO_CLOSE,Use_tested_stoploss and  (close[1] < losslong) AND TRADing_time, tickColor = Color.DARK_GREEN, arrowColor = Color.DARK_GREEN, name = "SELL TO CLOSE");

addOrder(OrderType.buy_TO_CLOSE, (close[1] < profitshort) AND TRAding_time, tickColor = Color.DARK_RED, arrowColor = Color.DARK_RED, name = "BUY TO CLOSE");

addOrder(OrderType.buy_TO_CLOSE, Use_tested_stoploss and (close[1] > lossshort) AND TRADing_time, tickColor = Color.DARK_RED, arrowColor = Color.DARK_RED, name = "BUY TO CLOSE");



####complete work in progress
def ll=100;
def hi=average(high[1],ll);
def lo=average(low[1],ll);
def dif=(hi-lo);
def ww=average((close-dif),ll);


input Use_WIP_stoploss=yes;

addOrder(OrderType.SELL_TO_CLOSE,Use_WIP_stoploss and (close[1] crosses  ww[1]) and (close[1]<  losslong) AND TRADing_time, tickColor = Color.DARK_GREEN, arrowColor = Color.DARK_GREEN, name = "SELL TO CLOSE");

addOrder(OrderType.buy_TO_CLOSE,Use_WIP_stoploss and(close[1] crosses  ww[1]) and  (close[1] > lossshort) AND TRADing_time, tickColor = Color.DARK_RED, arrowColor = Color.DARK_RED, name = "BUY TO CLOSE");
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
496 Online
Create Post

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