------------------------------------------------------------------------------------------------------------------------------------ ++++++++REQUIREMENTS ABOVE++++++ ------------------------------------------------------------------------------------------------------------------------------------ instructions: - " MQ5 CODE MODIFICATION" - Date - "Nothing will be removed from the source code during the Modification." - "The whole specification will be rewritten to ensure clarity and readability - Your ownership of the original Pine script source code Inputs I want Trading style: DAYTRADING MODE SCALPING MODE MOVING AVERAGE MODE Trend Type: Medium Trend High Trend we will add a NO TRADE ZONE filter ✅✅ you’ll be able to see blocks that circulate around the candles showing you when there’s possible ranging markets or possible low volume to trade and other spots to avoid ✅✅ , whenever we get a signal it’s easy to avoid it with the blocks ✅✅ this is the closest thing we have to 100.% accuracy ✅✅ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ++++++++REQUIREMENTS ABOVE++++++ ----------------------------------------------------------------------------------------------------------------------------------- Put buy order on previous day open And stoploss on the previous day low MAKE THE PREV AND PREV DAILY LOW HIGH AND CLOSE,MAKE THE TEXT INVISIBLE I DONT WANT TO SEE THE TEXT ON THE CHART Put Sell order on previous day close And stoploss on the previous day High FOR THE MODIFCATIONS JOIN GROUP TO SEE WHAT THEME AND WHAT TEXT I WANT FOR THE BOT:https://t.me/+U43zwKEfGDxlZDU0 I want to modify your MQL 5 indicator to generate more powerful and early buy and sell signals by doing the following: - Buy: When the previous day opens, the indicator will generate a buy signal and place a stop loss at the previous day's low. - Sell: When the previous day closes, the indicator will generate a sell signal and place a stop loss at the previous day's high. ust so I'm clear on everything you want to add to the indicator, it should include: - Dashboard text: "Inception Power Activated Trend Type" (shows trend direction and trading signals) - License message: "License 2" (shows type and expiry date) - Text in top left corner: "Trend Type" (shows trend direction) - Text in top right corner: "License Type" (shows type and expiry date) ----------------------------------------------------------------------------------------------------------------------- ++++++++REQUIREMENTS ABOVE++++++ ----------------------------------------------------------------------------------------------------------------------- //+------------------------------------------------------------------+ //| JARVIS.mq5 | //| Copyright © 2018-2023, PYTHONFX.com | //| https://pythonfx12.company.site| //+------------------------------------------------------------------+ #property copyright "Copyright AI SCAPLER 2024 " #property copyright "Copyright © 2023, Nasdaq Ghost Traders Pythonfx" #property link "https://nasdaqghost.co.za" #property description "The Ghost Limited Addition Version 2.0" #property description "Intraday - should be attached to M1-M15 timeframes. M5 is recommended.\r\n" #property description "Designed for major currency pairs, but should work also with exotic pairs, CFDs, or commodities." #property version "1.00" #property icon "\\Images\\Logo.ico"; #property indicator_chart_window #property indicator_buffers 5 #property indicator_plots 4 #property indicator_color1 clrYellowGreen #property indicator_color2 clrLightCoral #property indicator_color3 clrMagenta #property indicator_color4 clrGoldenrod input int Window =0; input int X_trend =0; input int Y_trend =40; //input inline Alerts =false/true; input int Buy =75; input int Sell =75; input double MinRewardRatio = 2; input color BuyLevelColor = clrDodgerBlue; input color SellLevelColor = clrTomato; input color StopLossColor = clrOrangeRed; input color TakeProfitColor = clrSpringGreen; input ENUM_LINE_STYLE TakeProfitStyle = 2; input int TakeProfitWidth = 2; input string FontName = "Arial"; input int FontSize = 8; input color TextColor = clrAliceBlue; //---- buffers double PrevDayHiBuffer[]; double PrevDayLoBuffer[]; double PrevDayOpenBuffer[]; double PrevDayCloseBuffer[]; double trend[]; //---- double PrevDayHi, PrevDayLo, PrevDayOpen, PrevDayClose, fb, fs, fe, tp1, tp2, tp3, prevfb, prevfs, prevtrend; double LastHigh, LastLow, LastOpen, LastClose, x; double ri, re1, re2, re3, ra1, ra2, ra3; datetime prevtime, prevtgttime; //-------------------- //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { ObjectDelete(0, "PrevDayHi"); ObjectDelete(0, "PrevDayLo"); ObjectDelete(0, "PrevDayOpen"); ObjectDelete(0, "PrevDayClose"); ObjectDelete(0, "fe"); ObjectDelete(0, "fe Line"); ObjectDelete(0, "fs"); ObjectDelete(0, "fs Line"); ObjectDelete(0, "tp3"); ObjectDelete(0, "tp3 Line"); ObjectDelete(0, "tp2"); ObjectDelete(0, "tp2 Line"); ObjectDelete(0, "tp1"); ObjectDelete(0, "tp1 Line"); ObjectDelete(0, "fb"); ObjectDelete(0, "fb Line"); Comment(""); } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //+------------------------------------------------------------------+ //-- Chart Logo ObjectCreate(0, "Limited Ad", OBJ_BITMAP_LABEL, 0, 0, 0); ObjectSetString(0, "Limited Ad", OBJPROP_BMPFILE, "\\Images\\PYTHON FX LOGO 4.bmp"); ObjectSetInteger(0,"Limited Ad", OBJPROP_CORNER, 10); ObjectSetInteger(0,"Limited Ad", OBJPROP_XDISTANCE, 500); ObjectSetInteger(0, "Limited Ad", OBJPROP_YDISTANCE, 80); ObjectSetInteger(0,"Limited Ad",OBJPROP_BACK,1); string url = "https://pythonfx12.000webhostapp.com/test.php"; string headers; char post[]; int accountNumber = (int)AccountInfoInteger(ACCOUNT_LOGIN); string postText = "account_no="+IntegerToString(accountNumber); StringToCharArray(postText,post,0,WHOLE_ARRAY,CP_UTF8); char result[]; string resultHeaders; int response = WebRequest("POST",url,headers,1000,post,result,resultHeaders); Print(__FUNCTION__,"> Server response is ",response, "and the error is",GetLastError()); Print(__FUNCTION__," > ",CharArrayToString(result)); //------------------------------------------------------------- string short_name; //---- indicator line PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_LINE); PlotIndexSetInteger(1, PLOT_DRAW_TYPE, DRAW_LINE); PlotIndexSetInteger(2, PLOT_DRAW_TYPE, DRAW_LINE); PlotIndexSetInteger(3, PLOT_DRAW_TYPE, DRAW_LINE); //---- SetIndexBuffer(0, PrevDayHiBuffer, INDICATOR_DATA); SetIndexBuffer(1, PrevDayLoBuffer, INDICATOR_DATA); SetIndexBuffer(2, PrevDayOpenBuffer, INDICATOR_DATA); SetIndexBuffer(3, PrevDayCloseBuffer, INDICATOR_DATA); SetIndexBuffer(4, trend, INDICATOR_CALCULATIONS); ArraySetAsSeries(PrevDayHiBuffer, true); ArraySetAsSeries(PrevDayLoBuffer, true); ArraySetAsSeries(PrevDayOpenBuffer, true); ArraySetAsSeries(PrevDayCloseBuffer, true); ArraySetAsSeries(trend, true); //---- name for DataWindow and indicator subwindow label short_name = "Prev Hi-Lo levels"; IndicatorSetString(INDICATOR_SHORTNAME, short_name); PlotIndexSetString(0, PLOT_LABEL, "Prev Day High"); PlotIndexSetString(1, PLOT_LABEL, "Prev Day Low"); PlotIndexSetString(2, PLOT_LABEL, "Prev Day Open"); PlotIndexSetString(3, PLOT_LABEL, "Prev Day Close"); //---- PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, 1); //---- return INIT_SUCCEEDED; } int OnCalculate(const int rates_total, const int prev_calculated, const datetime &Time[], const double &Open[], const double &High[], const double &Low[], const double &Close[], const long &tick_volume[], const long &volume[], const int &spread[]) { ArraySetAsSeries(Time, true); ArraySetAsSeries(Open, true); ArraySetAsSeries(High, true); ArraySetAsSeries(Low, true); ArraySetAsSeries(Close, true); int limit = 0, i, counted_bars = IndicatorCountedMQL4(prev_calculated); //---- indicator calculation if(counted_bars > 0) limit = rates_total - counted_bars - 1; if(counted_bars == 0) { if(Period() > PERIOD_H4) { Print("Period > PERIOD_H4"); return(-1); } limit = rates_total - 2; } //---- for(i = limit; i >= 0; i--) { if(High[i] > LastHigh) LastHigh = High[i];//[iHighest(NULL, 0, MODE_HIGH, i + 1)]; if(Low[i] < LastLow ) LastLow = Low[i];//[iLowest(NULL, 0, MODE_LOW, i + 1)]; if(Open[i + 1] > LastOpen) LastOpen = Open[i + 1]; //---- if(TimeDayMQL4(Time[i]) != TimeDayMQL4(Time[i + 1]) && prevtime != Time[i]) { PrevDayHi = LastHigh; PrevDayLo = LastLow; PrevDayOpen = LastClose; PrevDayClose = Open[i]; //---- LastLow = Open[i]; LastHigh = Open[i]; LastOpen = Open[i]; LastClose = Open[i]; //---- if(TimeDayOfYearMQL4(Time[i]) == TimeDayOfYearMQL4(Time[0]) && TimeYearMQL4(Time[i]) == TimeYearMQL4(Time[0])) { if(ObjectFind(0, "PrevDayHi") != 0) { ObjectCreate(0, "PrevDayHi", OBJ_TEXT, 0, 0, 0); ObjectSetTextMQL4("PrevDayHi", " Prev. Day High", FontSize, FontName, TextColor); ObjectMove(0, "PrevDayHi", 0, Time[i], PrevDayHi); } else { ObjectMove(0, "PrevDayHi", 0, Time[i], PrevDayHi); } //---- if(ObjectFind(0, "PrevDayLo") != 0) { ObjectCreate(0, "PrevDayLo", OBJ_TEXT, 0, 0, 0); ObjectSetTextMQL4("PrevDayLo", " Prev. Day Low", FontSize, FontName, TextColor); ObjectMove(0, "PrevDayLo", 0, Time[i], PrevDayLo); } else { ObjectMove(0, "PrevDayLo", 0, Time[i], PrevDayLo); } //---- if(ObjectFind(0, "PrevDayOpen") != 0) { ObjectCreate(0, "PrevDayOpen", OBJ_TEXT, 0, 0, 0); ObjectSetTextMQL4("PrevDayOpen", " Prev. Day Open", FontSize, FontName, TextColor); ObjectMove(0, "PrevDayOpen", 0, Time[i], PrevDayOpen); } else { ObjectMove(0, "PrevDayOpen", 0, Time[i], PrevDayOpen); } //---- if(ObjectFind(0, "PrevDayClose") != 0) { ObjectCreate(0, "PrevDayClose", OBJ_TEXT, 0, 0, 0); ObjectSetTextMQL4("PrevDayClose", " Prev. Day Close", FontSize, FontName, TextColor); ObjectMove(0, "PrevDayClose", 0, Time[i], PrevDayClose); } else { ObjectMove(0, "PrevDayClose", 0, Time[i], PrevDayClose); } } prevtime = Time[i]; } PrevDayHiBuffer[i] = PrevDayHi; PrevDayLoBuffer[i] = PrevDayLo; PrevDayOpenBuffer[i] = PrevDayOpen; PrevDayCloseBuffer[i] = PrevDayClose; } // BUY if(counted_bars > 0) { double Ask = SymbolInfoDouble(Symbol(), SYMBOL_ASK); double Bid = SymbolInfoDouble(Symbol(), SYMBOL_BID); if(Ask > LastClose) trend[0] = 1; if(Bid < LastClose) trend[0] = -1; if(trend[0] > 0) { fb = PrevDayHi - (PrevDayHi - PrevDayLo) * 0.382; fe = PrevDayHi - (PrevDayHi - PrevDayLo) * 0.618; tp1 = ((PrevDayHi - PrevDayLo) * 0.618) + fb; tp2 = (PrevDayHi - PrevDayLo) + fb; tp3 = 1.618 * (PrevDayHi - PrevDayLo) + fb; ri = MathRound((fb - fe) * 10000) / 10000; re1 = MathRound((tp1 - fb) * 10000) / 10000; re2 = MathRound((tp2 - fb) * 10000) / 10000; re3 = MathRound((tp3 - fb) * 10000) / 10000; if(ri > 0) { ra1 = MathRound((re1 / ri) * 10) / 10; ra2 = MathRound((re2 / ri) * 10) / 10; ra3 = MathRound((re3 / ri) * 10) / 10; } //---- if(ObjectFind(0, "fs") == 0) ObjectDelete(0, "fs"); if(ObjectFind(0, "fs Line") == 0) ObjectDelete(0, "fs Line"); if(ObjectFind(0, "fb") != 0) { ObjectCreate(0, "fb", OBJ_TEXT, 0, Time[0], fb); ObjectSetTextMQL4("fb", " BUY LEVEL", FontSize, FontName, TextColor); } else { ObjectMove(0, "fb", 0, Time[0], fb); } //---- if(ObjectFind(0, "fb Line") != 0) { ObjectCreate(0, "fb Line", OBJ_HLINE, 0, Time[0], fb); ObjectSetInteger(0, "fb Line", OBJPROP_STYLE, STYLE_DOT); ObjectSetInteger(0, "fb Line", OBJPROP_COLOR, BuyLevelColor); } else { ObjectMove(0, "fb Line", 0, Time[0], fb); } //---- if(ra1 > MinRewardRatio) Comment( //"\Owner : ", AccountName()," Account number : ", AccountNumber(), "\n\nPrevDayHi ", PrevDayHi, "\nPrevDayLo ", PrevDayLo, "\nTrend was UP ", "\nBUY @ ", fb, "\nStopLoss ", fe, "\nTakeProit 1 ", tp1, " Risk/Reward Ratio : ", ra1, " OK Trade ", "\nTakeProit 2 ", tp2, " Risk/Reward Ratio : ", ra2, " OK Trade ", "\nTakeProit 3 ", tp3, " Risk/Reward Ratio : ", ra3, " OK Trade "); else Comment( //"\Owner :", AccountName()," Account number : ", AccountNumber(), "\n\nPrevDayHi ", PrevDayHi, "\nPrevDayLo ", PrevDayLo, "\nTrend was UP ", "\nBUY @ ", fb, "\nStopLoss ", fe, "\nTakeProit 1 ", tp1, " Risk/Reward Ratio : ", ra1, " NO TRADE ", "\nTakeProit 2 ", tp2, " Risk/Reward Ratio : ", ra2, " NO TRADE ", "\nTakeProit 3 ", tp3, " Risk/Reward Ratio : ", ra3, " NO TRADE "); } // SELL if(trend[0] < 0) { fs = (PrevDayHi - PrevDayLo) * 0.382 + (PrevDayLo); fe = (PrevDayHi - PrevDayLo) * 0.618 + (PrevDayLo); tp1 = ((PrevDayLo - PrevDayHi) * 0.618) + fs; tp2 = (PrevDayLo - PrevDayHi) + fs; tp3 = 1.618 * (PrevDayLo - PrevDayHi) + fs; ri = MathRound((fs - fe) * 10000) / 10000; re1 = MathRound((tp1 - fs) * 10000) / 10000; re2 = MathRound((tp2 - fs) * 10000) / 10000; re3 = MathRound((tp3 - fs) * 10000) / 10000; if(ri > 0) { ra1 = MathRound((re1 / ri) * 10) / 10; ra2 = MathRound((re2 / ri) * 10) / 10; ra3 = ((re3 / ri) * 10) / 10; } //---- if(ObjectFind(0, "fb") == 0) ObjectDelete(0, "fb"); if(ObjectFind(0, "fb Line") == 0) ObjectDelete(0, "fb Line"); if(ObjectFind(0, "fs") != 0) { ObjectCreate(0, "fs", OBJ_TEXT, 0, Time[0], fs); ObjectSetTextMQL4("fs", " SELL LEVEL", FontSize, FontName, TextColor); } else { ObjectMove(0, "fs", 0, Time[0], fs); } //---- if(ObjectFind(0, "fs Line") != 0) { ObjectCreate(0, "fs Line", OBJ_HLINE, 0, Time[0], fs); ObjectSetInteger(0, "fs Line", OBJPROP_STYLE, STYLE_DASHDOT); ObjectSetInteger(0, "fs Line", OBJPROP_COLOR, SellLevelColor); } else { ObjectMove(0, "fs Line", 0, Time[0], fs); } //---- if(ra1 > MinRewardRatio) Comment( //"\Owner : ", AccountName(12345),"Account number : ", AccountNumber(12345), "\n\nPrevDayHi ", PrevDayHi, "\nPrevDayLo ", PrevDayLo, "\nTrend was Down ", "\nSELL @ ", fs, "\nStopLoss ", fe, "\nTakeProit 1 ", tp1, " Risk/Reward Ratio : ", ra1, " OK Trade ", "\nTakeProit 2 ", tp2, " Risk/Reward Ratio : ", ra2, " OK Trade ", "\nTakeProit 3 ", tp3, " Risk/Reward Ratio : ", ra3, " OK Trade "); else Comment( //"\Owner : ", AccountName("12345"),"Account number : ", AccountNumber(12345), "\n\nPrevDayHi ", PrevDayHi, "\nPrevDayLo ", PrevDayLo, "\nTrend was Down ", "\nSELL @ ", fs, "\nStopLoss ", fe, "\nTakeProit 1 ", tp1, " Risk/Reward Ratio : ", ra1, " NO TRADE ", "\nTakeProit 2 ", tp2, " Risk/Reward Ratio : ", ra2, " NO TRADE ", "\nTakeProit 3 ", tp3, " Risk/Reward Ratio : ", ra3, " NO TRADE "); prevtrend = trend[0]; } //---- if(prevtgttime != Time[0] || prevfs != fs || prevfb != fb) { if(ObjectFind(0, "fe") != 0) { ObjectCreate(0, "fe", OBJ_TEXT, 0, Time[0], fe); ObjectSetTextMQL4("fe", " STOPLOSS LEVEL", FontSize, FontName, TextColor); } else { ObjectMove(0, "fe", 0, Time[0], fe); } //---- if(ObjectFind(0, "fe Line") != 0) { ObjectCreate(0, "fe Line", OBJ_HLINE, 0, Time[0], fe); ObjectSetInteger(0, "fe Line", OBJPROP_STYLE, STYLE_DASHDOT); ObjectSetInteger(0, "fe Line", OBJPROP_COLOR, StopLossColor ); } else { ObjectMove(0, "fe Line", 0, Time[0], fe); } //---- if(ObjectFind(0, "tp1") != 0) { ObjectCreate(0, "tp1", OBJ_TEXT, 0, Time[0], tp1); ObjectSetTextMQL4("tp1", " PROFIT TARGET 1", FontSize, FontName, TextColor); } else { ObjectMove(0, "tp1", 0, Time[0], tp1 ); } //---- if(ObjectFind(0, "tp1 Line") != 0) { ObjectCreate(0, "tp1 Line", OBJ_HLINE, 0, Time[0], tp1); ObjectSetInteger(0, "tp1 Line", OBJPROP_COLOR, TakeProfitColor ); ObjectSetInteger(0, "tp1 Line", OBJPROP_STYLE, TakeProfitStyle ); ObjectSetInteger(0, "tp1 Line", OBJPROP_WIDTH, TakeProfitWidth ); } else { ObjectMove(0, "tp1 Line", 0, Time[0], tp1 ); } //---- if(ObjectFind(0, "tp2") != 0) { ObjectCreate(0, "tp2", OBJ_TEXT, 0, Time[0], tp2); ObjectSetTextMQL4("tp2", " PROFIT TARGET 2", FontSize, FontName, TextColor); } else { ObjectMove(0, "tp2", 0, Time[0], tp2); } if(ObjectFind(0, "tp2 Line") != 0) { ObjectCreate(0, "tp2 Line", OBJ_HLINE, 0, Time[0], tp2); ObjectSetInteger(0, "tp2 Line", OBJPROP_STYLE, STYLE_DASHDOTDOT); ObjectSetInteger(0, "tp2 Line", OBJPROP_COLOR, TakeProfitColor ); ObjectSetInteger(0, "tp2 Line", OBJPROP_STYLE, TakeProfitStyle ); ObjectSetInteger(0, "tp2 Line", OBJPROP_WIDTH, TakeProfitWidth ); } else { ObjectMove(0, "tp2 Line", 0, Time[0], tp2); } //---- if(ObjectFind(0, "tp3") != 0) { ObjectCreate(0, "tp3", OBJ_TEXT, 0, Time[0], tp3); ObjectSetTextMQL4("tp3", " PROFIT TARGET 3", FontSize, FontName, TextColor); } else { ObjectMove(0, "tp3", 0, Time[0], tp3); } //---- if(ObjectFind(0, "tp3 Line") != 0) { ObjectCreate(0, "tp3 Line", OBJ_HLINE, 0, Time[0], tp3); ObjectSetInteger(0, "tp3 Line", OBJPROP_STYLE, STYLE_DASHDOTDOT); ObjectSetInteger(0, "tp3 Line", OBJPROP_COLOR, TakeProfitColor ); ObjectSetInteger(0, "tp3 Line", OBJPROP_STYLE, TakeProfitStyle ); ObjectSetInteger(0, "tp3 Line", OBJPROP_WIDTH, TakeProfitWidth ); } else { ObjectMove(0, "tp3 Line", 0, Time[0], tp3); } prevfb = fb; prevfs = fs; prevtgttime = Time[0]; } } //---- return(rates_total); } int IndicatorCountedMQL4(int prev_calculated) { if(prev_calculated>0) return(prev_calculated-1); if(prev_calculated==0) return(0); return(0); } bool ObjectSetTextMQL4(string name, string text, int font_size, string font="", color text_color=clrNONE) { int tmpObjType=(int)ObjectGetInteger(0,name,OBJPROP_TYPE); if(tmpObjType!=OBJ_LABEL && tmpObjType!=OBJ_TEXT) return(false); if(StringLen(text)>0 && font_size>0) { if(ObjectSetString(0,name,OBJPROP_TEXT,text)==true && ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size)==true) { if((StringLen(font)>0) && ObjectSetString(0,name,OBJPROP_FONT,font)==false) return(false); if(ObjectSetInteger(0,name,OBJPROP_COLOR,text_color)==false) return(false); return(true); } return(false); } return(false); } int TimeDayMQL4(datetime date) { MqlDateTime tm; TimeToStruct(date,tm); return(tm.day); } int TimeDayOfYearMQL4(datetime date) { MqlDateTime tm; TimeToStruct(date,tm); return(tm.day_of_year); } int TimeYearMQL4(datetime date) { MqlDateTime tm; TimeToStruct(date,tm); return(tm.year); } //+------------------------------------------------------------------+ //@version=5 indicator("RoyalPrince [RoyalPrince Indicator ]", overlay=true, max_labels_count=500) //------------------ RoyalPrince TradingView Indicator Https://t.me/RoyalPrinceTrading ----------------------// // Get user settings showBuySell = input(true, "Show Buy & Sell", group="BUY & SELL SIGNALS") sensitivity = input.float(3, "Sensitivity (1-6)", 1, 6, group="BUY & SELL SIGNALS") percentStop = input.float(1, "Stop Loss % (0 to Disable)", 0, group="BUY & SELL SIGNALS") offsetSignal = input.float(5, "Signals Offset", 0, group="BUY & SELL SIGNALS") showRibbon = input(true, "Show Trend Ribbon", group="TREND RIBBON") smooth1 = input.int(5, "Smoothing 1", 1, group="TREND RIBBON") smooth2 = input.int(8, "Smoothing 2", 1, group="TREND RIBBON") showReversal = input(true, "Show Reversals", group="REVERSAL SIGNALS") showPdHlc = input(true, "Show P.D H/L/C", group="PREVIOUS DAY HIGH LOW CLOSE") lineColor = input.color(color.yellow, "Line Colors", group="PREVIOUS DAY HIGH LOW CLOSE") lineWidth = input.int(1, "Width Lines", group="PREVIOUS DAY HIGH LOW CLOSE") lineStyle = input.string("Solid", "Line Style", ["Solid", "Dashed", "Dotted"]) labelSize = input.string("normal", "Label Text Size", ["small", "normal", "large"]) labelColor = input.color(color.yellow, "Label Text Colors") showEmas = input(false, "Show EMAs", group="EMA") srcEma1 = input(close, "Source EMA 1") lenEma1 = input.int(7, "Length EMA 1", 1) srcEma2 = input(close, "Source EMA 2") lenEma2 = input.int(21, "Length EMA 2", 1) srcEma3 = input(close, "Source EMA 3") lenEma3 = input.int(144, "Length EMA 3", 1) showSwing = input(false, "Show Swing Points", group="SWING POINTS") prdSwing = input.int(10, "Swing Point Period", 2, group="SWING POINTS") colorPos = input(color.new(color.green, 50), "Positive Swing Color") colorNeg = input(color.new(color.red, 50), "Negative Swing Color") showDashboard = input(true, "Show Dashboard", group="TREND DASHBOARD") locationDashboard = input.string("Middle Right", "Table Location", ["Top Right", "Middle Right", "Bottom Right", "Top Center", "Middle Center", "Bottom Center", "Top Left", "Middle Left", "Bottom Left"], group="TREND DASHBOARD") tableTextColor = input(color.white, "Table Text Color", group="TREND DASHBOARD") tableBgColor = input(#2A2A2A, "Table Background Color", group="TREND DASHBOARD") sizeDashboard = input.string("Normal", "Table Size", ["Large", "Normal", "Small", "Tiny"], group="TREND DASHBOARD") showRevBands = input.bool(true, "Show Reversal Bands", group="REVERSAL BANDS") lenRevBands = input.int(30, "Length", group="REVERSAL BANDS") // Functions smoothrng(x, t, m) => wper = t * 2 - 1 avrng = ta.ema(math.abs(x - x[1]), t) smoothrng = ta.ema(avrng, wper) * m rngfilt(x, r) => rngfilt = x rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r percWidth(len, perc) => (ta.highest(len) - ta.lowest(len)) * perc / 100 securityNoRep(sym, res, src) => request.security(sym, res, src, barmerge.gaps_off, barmerge.lookahead_on) swingPoints(prd) => pivHi = ta.pivothigh(prd, prd) pivLo = ta.pivotlow (prd, prd) last_pivHi = ta.valuewhen(pivHi, pivHi, 1) last_pivLo = ta.valuewhen(pivLo, pivLo, 1) hh = pivHi and pivHi > last_pivHi ? pivHi : na lh = pivHi and pivHi < last_pivHi ? pivHi : na hl = pivLo and pivLo > last_pivLo ? pivLo : na ll = pivLo and pivLo < last_pivLo ? pivLo : na [hh, lh, hl, ll] f_chartTfInMinutes() => float _resInMinutes = timeframe.multiplier * ( timeframe.isseconds ? 1 : timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60. * 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na) f_kc(src, len, sensitivity) => basis = ta.sma(src, len) span = ta.atr(len) [basis + span * sensitivity, basis - span * sensitivity] wavetrend(src, chlLen, avgLen) => esa = ta.ema(src, chlLen) d = ta.ema(math.abs(src - esa), chlLen) ci = (src - esa) / (0.015 * d) wt1 = ta.ema(ci, avgLen) wt2 = ta.sma(wt1, 3) [wt1, wt2] f_top_fractal(src) => src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and src[2] > src[0] f_bot_fractal(src) => src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and src[2] < src[0] f_fractalize(src) => top = f_top_fractal(src) bot = f_bot_fractal(src) fractal = top ? 1 : bot ? -1 : 0 fractal f_findDivs(src, topLimit, botLimit) => fractal = f_fractalize(src) fractalTop = fractal > 0 and src[2] >= topLimit ? src[2] : na fractalBot = fractal < 0 and src[2] <= botLimit ? src[2] : na highPrev = ta.valuewhen(fractalTop, src[2], 0)[2] highPrice = ta.valuewhen(fractalTop, high[2], 0)[2] lowPrev = ta.valuewhen(fractalBot, src[2], 0)[2] lowPrice = ta.valuewhen(fractalBot, low[2], 0)[2] botFractal = f_bot_fractal(src) bearSignal = fractalTop and high[2] > highPrice and src[2] < highPrev bullSignal = fractalBot and low[2] < lowPrice and src[2] > lowPrev and botFractal [bearSignal, bullSignal] // Get components source = close smrng1 = smoothrng(source, 27, 1.5) smrng2 = smoothrng(source, 55, sensitivity) smrng = (smrng1 + smrng2) / 2 filt = rngfilt(source, smrng) up = 0.0, up := filt > filt[1] ? nz(up[1]) + 1 : filt < filt[1] ? 0 : nz(up[1]) dn = 0.0, dn := filt < filt[1] ? nz(dn[1]) + 1 : filt > filt[1] ? 0 : nz(dn[1]) bullCond = bool(na), bullCond := source > filt and source > source[1] and up > 0 or source > filt and source < source[1] and up > 0 bearCond = bool(na), bearCond := source < filt and source < source[1] and dn > 0 or source < filt and source > source[1] and dn > 0 lastCond = 0, lastCond := bullCond ? 1 : bearCond ? -1 : lastCond[1] bull = bullCond and lastCond[1] == -1 bear = bearCond and lastCond[1] == 1 countBull = ta.barssince(bull) countBear = ta.barssince(bear) trigger = nz(countBull, bar_index) < nz(countBear, bar_index) ? 1 : 0 ribbon1 = ta.sma(close, smooth1) ribbon2 = ta.sma(close, smooth2) rsi = ta.rsi(close, 21) rsiOb = rsi > 70 and rsi > ta.ema(rsi, 10) rsiOs = rsi < 30 and rsi < ta.ema(rsi, 10) dHigh = securityNoRep(syminfo.tickerid, "D", high [1]) dLow = securityNoRep(syminfo.tickerid, "D", low [1]) dClose = securityNoRep(syminfo.tickerid, "D", close[1]) ema1 = ta.ema(srcEma1, lenEma1) ema2 = ta.ema(srcEma2, lenEma2) ema3 = ta.ema(srcEma3, lenEma3) [hh, lh, hl, ll] = swingPoints(prdSwing) ema = ta.ema(close, 144) emaBull = close > ema equal_tf(res) => str.tonumber(res) == f_chartTfInMinutes() and not timeframe.isseconds higher_tf(res) => str.tonumber(res) > f_chartTfInMinutes() or timeframe.isseconds too_small_tf(res) => (timeframe.isweekly and res=="1") or (timeframe.ismonthly and str.tonumber(res) < 10) securityNoRep1(sym, res, src) => bool bull_ = na bull_ := equal_tf(res) ? src : bull_ bull_ := higher_tf(res) ? request.security(sym, res, src, barmerge.gaps_off, barmerge.lookahead_on) : bull_ bull_array = request.security_lower_tf(syminfo.tickerid, higher_tf(res) ? str.tostring(f_chartTfInMinutes()) + (timeframe.isseconds ? "S" : "") : too_small_tf(res) ? (timeframe.isweekly ? "3" : "10") : res, src) if array.size(bull_array) > 1 and not equal_tf(res) and not higher_tf(res) bull_ := array.pop(bull_array) array.clear(bull_array) bull_ TF1Bull = securityNoRep1(syminfo.tickerid, "1" , emaBull) TF3Bull = securityNoRep1(syminfo.tickerid, "3" , emaBull) TF5Bull = securityNoRep1(syminfo.tickerid, "5" , emaBull) TF15Bull = securityNoRep1(syminfo.tickerid, "15" , emaBull) TF30Bull = securityNoRep1(syminfo.tickerid, "30" , emaBull) TF60Bull = securityNoRep1(syminfo.tickerid, "60" , emaBull) TF120Bull = securityNoRep1(syminfo.tickerid, "120" , emaBull) TF240Bull = securityNoRep1(syminfo.tickerid, "240" , emaBull) TF480Bull = securityNoRep1(syminfo.tickerid, "480" , emaBull) TFDBull = securityNoRep1(syminfo.tickerid, "1440", emaBull) [upperKC1, lowerKC1] = f_kc(close, lenRevBands, 3) [upperKC2, lowerKC2] = f_kc(close, lenRevBands, 4) [upperKC3, lowerKC3] = f_kc(close, lenRevBands, 5) [upperKC4, lowerKC4] = f_kc(close, lenRevBands, 6) [wt1, wt2] = wavetrend(hlc3, 9, 12) [wtDivBear1, wtDivBull1] = f_findDivs(wt2, 15, -40) [wtDivBear2, wtDivBull2] = f_findDivs(wt2, 45, -65) wtDivBull = wtDivBull1 or wtDivBull2 wtDivBear = wtDivBear1 or wtDivBear2 // Colors cyan = #00DBFF, cyan30 = color.new(cyan, 70) pink = #E91E63, pink30 = color.new(pink, 70) red = #FF5252, red30 = color.new(red , 70) // Plot off = percWidth(300, offsetSignal) plotshape(showBuySell and bull ? low - off : na, "Buy Label" , shape.labelup , location.absolute, cyan, 0, "Buy" , color.white, size=size.normal) plotshape(showBuySell and bear ? high + off : na, "Sell Label", shape.labeldown, location.absolute, pink, 0, "Sell", color.white, size=size.normal) plotshape(ta.crossover(wt1, wt2) and wt2 <= -53, "Mild Buy" , shape.xcross, location.belowbar, cyan, size=size.tiny) plotshape(ta.crossunder(wt1, wt2) and wt2 >= 53, "Mild Sell", shape.xcross, location.abovebar, pink, size=size.tiny) plotshape(wtDivBull, "Divergence Buy ", shape.triangleup , location.belowbar, cyan, size=size.tiny) plotshape(wtDivBear, "Divergence Sell", shape.triangledown, location.abovebar, pink, size=size.tiny) barcolor(up > dn ? cyan : pink) plotshape(showReversal and rsiOs, "Reversal Buy" , shape.diamond, location.belowbar, cyan30, size=size.tiny) plotshape(showReversal and rsiOb, "Reversal Sell", shape.diamond, location.abovebar, pink30, size=size.tiny) lStyle = lineStyle == "Solid" ? line.style_solid : lineStyle == "Dotted" ? line.style_dotted : line.style_dashed lSize = labelSize == "small" ? size.small : labelSize == "normal" ? size.normal : size.large dHighLine = showPdHlc ? line.new(bar_index, dHigh, bar_index + 1, dHigh , xloc.bar_index, extend.both, lineColor, lStyle, lineWidth) : na, line.delete(dHighLine[1]) dLowLine = showPdHlc ? line.new(bar_index, dLow , bar_index + 1, dLow , xloc.bar_index, extend.both, lineColor, lStyle, lineWidth) : na, line.delete(dLowLine[1]) dCloseLine = showPdHlc ? line.new(bar_index, dClose, bar_index + 1, dClose, xloc.bar_index, extend.both, lineColor, lStyle, lineWidth) : na, line.delete(dCloseLine[1]) dHighLabel = showPdHlc ? label.new(bar_index + 20, dHigh , "Previous Day High", xloc.bar_index, yloc.price, #000000, label.style_none, labelColor, lSize) : na, label.delete(dHighLabel[1]) dLowLabel = showPdHlc ? label.new(bar_index + 20, dLow , "Previous Day Low", xloc.bar_index, yloc.price, #000000, label.style_none, labelColor, lSize) : na, label.delete(dLowLabel[1]) dCloseLabel = showPdHlc ? label.new(bar_index + 20, dClose, "Previous Day Close", xloc.bar_index, yloc.price, #000000, label.style_none, labelColor, lSize) : na, label.delete(dCloseLabel[1]) plot(showEmas ? ema1 : na, "EMA 1", color.green , 2) plot(showEmas ? ema2 : na, "EMA 2", color.purple, 2) plot(showEmas ? ema3 : na, "EMA 3", color.yellow, 2) plotshape(showSwing ? hh : na, "", shape.triangledown, location.abovebar, color.new(color.green, 50), -prdSwing, "HH", colorPos, false) plotshape(showSwing ? hl : na, "", shape.triangleup , location.belowbar, color.new(color.green, 50), -prdSwing, "HL", colorPos, false) plotshape(showSwing ? lh : na, "", shape.triangledown, location.abovebar, color.new(color.red , 50), -prdSwing, "LH", colorNeg, false) plotshape(showSwing ? ll : na, "", shape.triangleup , location.belowbar, color.new(color.red , 50), -prdSwing, "LL", colorNeg, false) srcStop = close atrBand = srcStop * (percentStop / 100) atrStop = trigger ? srcStop - atrBand : srcStop + atrBand lastTrade(src) => ta.valuewhen(bull or bear, src, 0) entry_y = lastTrade(srcStop) stop_y = lastTrade(atrStop) tp1_y = (entry_y - lastTrade(atrStop)) * 1 + entry_y tp2_y = (entry_y - lastTrade(atrStop)) * 2 + entry_y tp3_y = (entry_y - lastTrade(atrStop)) * 3 + entry_y labelTpSl(y, txt, color) => label labelTpSl = percentStop != 0 ? label.new(bar_index + 1, y, txt, xloc.bar_index, yloc.price, color, label.style_label_left, color.white, size.normal) : na label.delete(labelTpSl[1]) labelTpSl(entry_y, "Entry: " + str.tostring(math.round_to_mintick(entry_y)), color.gray) labelTpSl(stop_y , "Stop Loss: " + str.tostring(math.round_to_mintick(stop_y)), color.red) labelTpSl(tp1_y, "Take Profit 1: " + str.tostring(math.round_to_mintick(tp1_y)), color.green) labelTpSl(tp2_y, "Take Profit 2: " + str.tostring(math.round_to_mintick(tp2_y)), color.green) labelTpSl(tp3_y, "Take Profit 3: " + str.tostring(math.round_to_mintick(tp3_y)), color.green) lineTpSl(y, color) => line lineTpSl = percentStop != 0 ? line.new(bar_index - (trigger ? countBull : countBear) + 4, y, bar_index + 1, y, xloc.bar_index, extend.none, color, line.style_solid) : na line.delete(lineTpSl[1]) lineTpSl(entry_y, color.gray) lineTpSl(stop_y, color.red) lineTpSl(tp1_y, color.green) lineTpSl(tp2_y, color.green) lineTpSl(tp3_y, color.green) var dashboard_loc = locationDashboard == "Top Right" ? position.top_right : locationDashboard == "Middle Right" ? position.middle_right : locationDashboard == "Bottom Right" ? position.bottom_right : locationDashboard == "Top Center" ? position.top_center : locationDashboard == "Middle Center" ? position.middle_center : locationDashboard == "Bottom Center" ? position.bottom_center : locationDashboard == "Top Left" ? position.top_left : locationDashboard == "Middle Left" ? position.middle_left : position.bottom_left var dashboard_size = sizeDashboard == "Large" ? size.large : sizeDashboard == "Normal" ? size.normal : sizeDashboard == "Small" ? size.small : size.tiny var dashboard = showDashboard ? table.new(dashboard_loc, 2, 15, tableBgColor, #000000, 2, tableBgColor, 1) : na dashboard_cell(column, row, txt, signal=false) => table.cell(dashboard, column, row, txt, 0, 0, signal ? #000000 : tableTextColor, text_size=dashboard_size) dashboard_cell_bg(column, row, col) => table.cell_set_bgcolor(dashboard, column, row, col) if barstate.islast and showDashboard dashboard_cell(0, 0 , "RoyalPrince Trading") dashboard_cell(0, 1 , "Current Position") dashboard_cell(0, 2 , "Current Trend") dashboard_cell(0, 3 , "Volume") dashboard_cell(0, 4 , "Timeframe") dashboard_cell(0, 5 , "1 min:") dashboard_cell(0, 6 , "3 min:") dashboard_cell(0, 7 , "5 min:") dashboard_cell(0, 8 , "15 min:") dashboard_cell(0, 9 , "30 min:") dashboard_cell(0, 10, "1 H:") dashboard_cell(0, 11, "2 H:") dashboard_cell(0, 12, "4 H:") dashboard_cell(0, 13, "8 H:") dashboard_cell(0, 14, "Daily:") dashboard_cell(1, 0 , "@Rp4000") dashboard_cell(1, 1 , trigger ? "Buy" : "Sell", true), dashboard_cell_bg(1, 1, trigger ? color.green : color.red) dashboard_cell(1, 2 , emaBull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 2, emaBull ? color.green : color.red) dashboard_cell(1, 3 , str.tostring(volume)) dashboard_cell(1, 4 , "Trends") dashboard_cell(1, 5 , TF1Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 5 , TF1Bull ? color.green : color.red) dashboard_cell(1, 6 , TF3Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 6 , TF3Bull ? color.green : color.red) dashboard_cell(1, 7 , TF5Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 7 , TF5Bull ? color.green : color.red) dashboard_cell(1, 8 , TF15Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 8 , TF15Bull ? color.green : color.red) dashboard_cell(1, 9 , TF30Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 9 , TF30Bull ? color.green : color.red) dashboard_cell(1, 10, TF60Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 10, TF60Bull ? color.green : color.red) dashboard_cell(1, 11, TF120Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 11, TF120Bull ? color.green : color.red) dashboard_cell(1, 12, TF240Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 12, TF240Bull ? color.green : color.red) dashboard_cell(1, 13, TF480Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 13, TF480Bull ? color.green : color.red) dashboard_cell(1, 14, TFDBull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 14, TFDBull ? color.green : color.red) plot(showRevBands ? upperKC1 : na, "Rev.Zone Upper 1", red30) plot(showRevBands ? upperKC2 : na, "Rev.Zone Upper 2", red30) plot(showRevBands ? upperKC3 : na, "Rev.Zone Upper 3", red30) plot(showRevBands ? upperKC4 : na, "Rev.Zone Upper 4", red30) plot(showRevBands ? lowerKC4 : na, "Rev.Zone Lower 4", cyan30) plot(showRevBands ? lowerKC3 : na, "Rev.Zone Lower 3", cyan30) plot(showRevBands ? lowerKC2 : na, "Rev.Zone Lower 2", cyan30) plot(showRevBands ? lowerKC1 : na, "Rev.Zone Lower 1", cyan30) fill(plot(showRibbon ? ribbon1 : na, "", na, editable=false), plot(showRibbon ? ribbon2 : na, "", na, editable=false), ribbon1 > ribbon2 ? cyan30 : pink30, "Ribbon Fill Color") // Alerts alert01 = ta.crossover(ribbon1, ribbon2) alert02 = bull alert03 = wtDivBull alert04 = wtDivBear alert05 = bull or bear alert06 = ta.crossover(wt1, wt2) and wt2 <= -53 alert07 = ta.crossunder(wt1, wt2) and wt2 >= 53 alert08 = ta.crossunder(ribbon1, ribbon2) alert09 = rsiOb or rsiOs alert10 = bear alert11 = ta.cross(ribbon1, ribbon2) alerts(sym) => if alert02 or alert03 or alert04 or alert06 or alert07 or alert10 alert_text = alert02 ? "Buy Signal EzAlgo" : alert03 ? "Strong Buy Signal EzAlgo" : alert04 ? "Strong Sell Signal EzAlgo" : alert06 ? "Mild Buy Signal EzAlgo" : alert07 ? "Mild Sell Signal EzAlgo" : "Sell Signal EzAlgo" alert(alert_text, alert.freq_once_per_bar_close) alerts(syminfo.tickerid) alertcondition(alert01, "Blue Trend Ribbon Alert", "Blue Trend Ribbon, TimeFrame={{interval}}") alertcondition(alert02, "Buy Signal", "Buy Signal EzAlgo") alertcondition(alert03, "Divergence Buy Alert", "Strong Buy Signal EzAlgo, TimeFrame={{interval}}") alertcondition(alert04, "Divergence Sell Alert", "Strong Sell Signal EzAlgo, TimeFrame={{interval}}") alertcondition(alert05, "Either Buy or Sell Signal", "EzAlgo Signal") alertcondition(alert06, "Mild Buy Alert", "Mild Buy Signal EzAlgo, TimeFrame={{interval}}") alertcondition(alert07, "Mild Sell Alert", "Mild Sell Signal EzAlgo, TimeFrame={{interval}}") alertcondition(alert08, "Red Trend Ribbon Alert", "Red Trend Ribbon, TimeFrame={{interval}}") alertcondition(alert09, "Reversal Signal", "Reversal Signal") alertcondition(alert10, "Sell Signal", "Sell Signal EzAlgo") alertcondition(alert11, "Trend Ribbon Color Change Alert", "Trend Ribbon Color Change, TimeFrame={{interval}}")