input EnableStrategy = yes;
input UseMarketTime = no; #hint UseMarketTime: Use Trading hours?
input TradeTimeStart = 0930;
input TradeTimeEnd = 1555;
input UseTradeOffTradeTime = no;
input UseMarketTradeTimeToExitPositions = no; #hint UseMarketTradeTimeToExitPositions: Exit/Close open trades based on the market hours selected
input UseDateRange = no; #hint UseDateRange: Trade Signals within the date range specified
input ActiveStartDate = 20230101;
input ActiveEndDate = 20240101;
def activedaterange = GetYYYYMMDD() >= ActiveStartDate and GetYYYYMMDD() <= ActiveEndDate;
def activerange = if UseDateRange then activedaterange else 1;
AddLabel(UseDateRange, if activerange then "Range " + AsPrice(ActiveStartDate) + " - " + AsPrice(ActiveEndDate) else "" , Color.WHITE );
def Active = if GetDay() != GetDay()[1]
then 0
else if SecondsTillTime(TradeTimeStart) <= 0 and
SecondsTillTime(TradeTimeEnd) >= 0
then 1
else 0;
def ActiveTradeTime = if UseTradeOffTradeTime then !Active else if UseMarketTime then if SecondsTillTime(TradeTimeStart) <= 0 and
SecondsTillTime(TradeTimeEnd) >= 0 then 1 else 0
else 1;
def closeallmarket = ( if UseMarketTime and UseTradeOffTradeTime then Active and !Active[1] and UseMarketTradeTimeToExitPositions else !ActiveTradeTime and ActiveTradeTime[1]) and UseMarketTradeTimeToExitPositions;
input ShowTime = yes;
input TimeZone = 10.5;
def Hours = Floor(TimeZone + SecondsFromTime(0930) / 60 / 60) - 1;
def Minutes = ((TimeZone + SecondsFromTime(930) / 60 / 60) % 1) * 60;
AddLabel(ShowTime, " Market Time: " + GetMonth() + "/" + GetDayOfMonth(GetYYYYMMDD()) + "/" + (AsPrice(GetYear())) + ":" + Hours + ":" + Minutes ,
if !IsNaN(GetTime())
then Color.LIME
else if IsNaN(GetTime())
then Color.PINK
else Color.WHITE);
AddOrder(OrderType.BUY_TO_CLOSE, EnableStrategy and closeallmarket, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "BxEdt@ " + open[-1]) ;
AddOrder(OrderType.SELL_TO_CLOSE, EnableStrategy and closeallmarket, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "SxEdt" + open[-1]);
AddOrder(OrderType.BUY_TO_CLOSE, EnableStrategy and !activerange, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "BxSession@ " + open[-1]) ;
AddOrder(OrderType.SELL_TO_CLOSE, EnableStrategy and !activerange, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "SxSession@" + open[-1]);
##@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# Shimi's Scalp Pro Elite Platinum Extreme; Deluxe Edition.
# Based on Quant Trade Edge's Strategy in https://www.youtube.com/watch?v=lhW5czmfc14
# Original Strategy is for NQ 1 minute chart, long only above 10ema and short only below 10ema, risking 1 ATR for .5 ATR target.
# Start EMA
input price = close;
input length = 10;
input displace = 0;
def ema = expAverage(price[-displace], length);
def ema20 = expAverage (price, length=20);
def ema50 = expAverage (price, length=50);
def bull = close > open and low < low[1] and high < high[1] and close > ema and ema > ema20 and ema20 > ema50;
def bear = close < open and low > low[1] and high > high[1] and close < ema and ema < ema20 and ema20 < ema50;
plot upsignal = bull;
plot downsignal = bear;
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
def averagePrice = ohlc4;
def medianPrice = hl2;
def medianBodyPrice = MidBodyVal();
def entryGandaldfPattern = (averagePrice[1] < medianPrice[1] and
medianPrice[2] <= averagePrice[1] and
medianBodyPrice[2] <= averagePrice[3]) or
(averagePrice[1] < medianPrice[3] and
medianBodyPrice < medianPrice[2] and
medianBodyPrice[1] < medianBodyPrice[2]);
def exitGandalfPattern = (averagePrice[1] < medianBodyPrice[1] and
medianPrice[2] == medianBodyPrice[3] and
medianBodyPrice[1] <= medianBodyPrice[4]) or
(averagePrice[2] < medianBodyPrice and
medianPrice[4] <= averagePrice[3] and
medianBodyPrice[1] <= averagePrice[1]);
def wiz_buy = bull or (entryGandaldfPattern) ;
def wiz_sell = ( bear ) and (exitGandalfPattern or !entryGandaldfPattern);
input useAutoOrderswiz = yes;
AddOrder(OrderType.BUY_auto, EnableStrategy and activerange and ActiveTradeTime and useAutoOrderswiz and wiz_buy, name = "B(w>)@ " + open[-1], price = open[-1], tickcolor = GetColor(1), arrowcolor = GetColor(1));
AddOrder(OrderType.sell_auto, EnableStrategy and activerange and ActiveTradeTime and useAutoOrderswiz and wiz_sell, name = "S(<w)@ " + open[-1], price = open[-1], tickcolor = GetColor(4), arrowcolor = GetColor(4));
#######################################
## START of Strategies DashBoard
####################################
addOrder(OrderType.BUY_AUTO, no);
input enableDashBoard = yes;
input ShowStrategyCurrentPnlBubble = yes;
input ShowStrategyPnlBubble = no;
input ShowStrategyPnlEntryBubble = yes;
input ShowStrategyPnlVertical = no;
Input ShowStrategyProfitLossLabels = yes;
def fpl = FPL();
def StrategyEntryprice = if IsNaN(EntryPrice()) then 0 else EntryPrice();
def ep = entryprice();
def poschange = ( StrategyEntryprice <> StrategyEntryprice[1] and StrategyEntryprice == 0 ) or ( StrategyEntryprice <> StrategyEntryprice[1] and StrategyEntryprice[1] == 0 ) or ( StrategyEntryprice <> StrategyEntryprice[1] and StrategyEntryprice[1] > 0 and StrategyEntryprice[0] > 0 );
def pnlentry = if poschange then fpl[1] else pnlentry[1];
def currentprofit = fpl() - pnlentry[1];
def pnlprofit = if pnlentry <> pnlentry[1] then fpl()[1] - pnlentry[1] else 0 ;
def entryprofit = (if pnlprofit> 0 then 1 else -1 ) * absValue( if poschange then if StrategyEntryprice == 0 then open[0] - ep[1] else ep-ep[1] else 0) ;
def dollarentryprofitloss = Round(((entryprofit ) / TickSize()) * TickValue());
AddChartBubble(enableDashBoard and ShowStrategyPnlEntryBubble and poschange and absValue(dollarentryprofitloss )>0, open[0], AsDollars(dollarentryprofitloss[0]), if dollarentryprofitloss[0] > 0 then Color.light_GREEN else if dollarentryprofitloss[0] < 0 then Color.pink else Color.BLUE);
AddVerticalLine(ShowStrategyPnlVertical and ShowStrategyPnlEntryBubble and poschange, AsDollars(fpl) + " (" + dollarentryprofitloss + ")" , if dollarentryprofitloss > 0 then Color.GREEN else if dollarentryprofitloss < 0 then Color.RED else if pnlentry == 0 then Color.WHITE else Color.CYAN);
def fplpnlprofit = pnlprofit;
AddChartBubble(enableDashBoard and ShowStrategyPnlBubble and poschange[0] and absValue(fplpnlprofit )>0, open[0], AsDollars(fplpnlprofit[0]), if fplpnlprofit[0] > 0 then Color.GREEN else if fplpnlprofit[0] < 0 then Color.RED else Color.BLUE);
AddVerticalLine(enableDashBoard and ShowStrategyPnlVertical and ShowStrategyPnlBubble and poschange, AsDollars(fpl) + " (" + pnlprofit + ")" , if pnlprofit > 0 then Color.GREEN else if pnlprofit < 0 then Color.RED else if pnlentry == 0 then Color.WHITE else Color.CYAN);
def lastentry =if isnan( entryprice()) then lastentry[1] else entryprice() ;
AddChartBubble(enableDashBoard and ShowStrategyCurrentPnlBubble and !IsNaN(close) and IsNaN(close [-1] ) and HighestAll(BarNumber()) and absValue(currentprofit)> 0, lastentry, AsDollars(currentprofit[0]), if currentprofit[0] > 0 then Color.green else if currentprofit[0] < 0 then Color.red else Color.BLUE);
def pl = if ShowStrategyPnlEntryBubble then if isnan( dollarentryprofitloss) then 0 else dollarentryprofitloss else if isnan(fplpnlprofit) then 0 else fplpnlprofit;
def StrategyLongprofitLossSum = CompoundValue(1, if BarNumber() == 1 then 0 else if pl > 0 then StrategyLongprofitLossSum[1] + pl[0] else StrategyLongprofitLossSum[1], 0);
def StrategyShortprofitLossSum = CompoundValue(1, if BarNumber() == 1 then 0 else if pl < 0 then StrategyShortprofitLossSum[1] + pl[0] else StrategyShortprofitLossSum[1], 0);
def StrategyProfittradecnt = if BarNumber() == 1 then 0 else if pl > 0 then StrategyProfittradecnt[1] + 1 else StrategyProfittradecnt[1] ;
def Strategylosstradecnt = if BarNumber() == 1 then 0 else if pl < 0 then Strategylosstradecnt[1] + 1 else Strategylosstradecnt[1] ;
def Strategytradecnt = StrategyProfittradecnt + Strategylosstradecnt;
# What percent were winners
def StrategyPCTWin = Round(((StrategyProfittradecnt) / (Strategytradecnt)) * 100, 2) ;
def StrategyPCTLoss = Round(((Strategylosstradecnt) / (Strategytradecnt)) * 100, 2) ;
def StrategyPCTWinamt = Round(((absValue(StrategyLongprofitLossSum/StrategyProfittradecnt)) /absValue( (StrategyLongprofitLossSum/StrategyProfittradecnt) + absValue(StrategyShortprofitLossSum/Strategytradecnt))) * 1, 2) ;
def PCTLossamt = Round(((absValue(StrategyShortprofitLossSum/Strategylosstradecnt)) /absValue( (StrategyLongprofitLossSum/StrategyProfittradecnt) + absValue(StrategyShortprofitLossSum/Strategytradecnt))) * 1, 2) ;
plot PltEntryPrice = if enableDashBoard then ep else double.nan;
PltEntryPrice.SetPaintingStrategy(PaintingStrategy.DASHES);
PltEntryPrice.SetdefaultColor(color.cyan);
PltEntryPrice.assignValueColor(if currentprofit then color.green else
if entryprofit < 0 then color.red else color.cyan );
def Strategylowestdrawdown = min(if isnan(currentprofit) then 0 else currentprofit,Strategylowestdrawdown[1]);
def StrategyHigestdrawUp = max(if isnan(currentprofit) then 0 else currentprofit,StrategyHigestdrawUp[1]);
def Strategylowestloss = min(pl,Strategylowestloss[1]);
def highestwin = max(pl,highestwin[1]);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels,"Last Entry: "+lastentry +"("+currentprofit +")" ,if currentprofit > 0 then color.light_green else if currentprofit < 0 then color.light_red else color.cyan );
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "PNL: " + (FPL()), if FPL() > 0 then Color.LIME else Color.RED);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "Winners: " + StrategyPCTWin + "%", if StrategyPCTWin > 50 then Color.GREEN else if StrategyPCTWin > 40 then Color.YELLOW else Color.GRAY);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "ProfitLossSum: " + (StrategyLongprofitLossSum + StrategyShortprofitLossSum), if (StrategyLongprofitLossSum + StrategyShortprofitLossSum) > 0 then Color.LIME else Color.RED);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "ShortprofitLossSum: " + (StrategyShortprofitLossSum), Color.pink);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "LongprofitLossSum: " + (StrategyLongprofitLossSum), Color.LIME);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "Trades: " + (Strategytradecnt), Color.WHITE);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "Profit Trades: " + (StrategyProfittradecnt), if StrategyProfittradecnt > Strategylosstradecnt then Color.LIME else Color.RED);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "Loss Trades: " + (Strategylosstradecnt), if StrategyProfittradecnt < Strategylosstradecnt then Color.LIME else Color.pink);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "Profit Factor: " +round(absvalue (StrategyLongprofitLossSum/StrategyShortprofitLossSum)),color.cyan);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "Lowest Loss: " + (Strategylowestloss), Color.pink);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "Lowest DrawDown: " + (Strategylowestdrawdown), Color.pink);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "Highest DrawUp: " + (StrategyHigestdrawUp), Color.LIME);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "Highest Win: " + (highestwin), Color.LIME);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "PCTWin Trades: " + (StrategyPCTWin), Color.GREEN);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "PCTLoss Trades: " + (StrategyPCTLoss), Color.PINK);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "PCTWin Amount: " + (StrategyPCTWinamt), Color.GREEN);
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "PCTLoss Amount: " + (PCTLossamt), Color.PINK);
def firstentry = if Strategytradecnt ==1 then close[1] else firstentry[1];
def buyandhold = Round(((close - firstentry ) / TickSize()) * TickValue());
AddLabel(enableDashBoard and ShowStrategyProfitLossLabels, "Buy&Hold: " + (buyandhold), if buyandhold > 0 then Color.LIME else Color.RED);
#######################################
## END of Strategy DashBoard
#######################################