//+------------------------------------------------------------------+ //| AIBRAIN OTC v46.3 - ALL CUBES FIXED | //| Fixed: Neural AI, S/R Levels, Brain, Reversal, NCP | //| Timer right, NCP font14, raw signal no smoothing delay | //+------------------------------------------------------------------+ #property copyright "AIBRAIN ULTIMATE - KM RANA" #property version "46.3" #property strict #property indicator_chart_window #define PFX "AIB9_" #define VER "v46.3" #define LB 18 #define MAX_LEVELS 5 #define MAX_REJ 50 #define LOOKBACK 50 input string SPM_FILE = "KM RANA"; input int HOLD_SEC = 60; input int POS_X = 4; input int POS_Y = 20; input int DASH_W = 660; input bool SHOW_TIMER = true; input bool SHOW_SR_LINES = true; input string ENTRY_MODE = "TIME"; input int FLAG_MIN_SEC = 10; input int FLAG_MAX_SEC = 35; input int TIME_MIN_SEC = 10; input int TIME_MAX_SEC = 35; input int MIN_REMAINING_SEC = 15; input double REVERSAL_PCT = 30.0; input double WICK_PCT = 0.65; input int HRN_CONFIRM_BARS = 2; input bool HA_ALIGN_FILTER = false; input bool CONSENSUS_FILTER = false; input bool ENABLE_NOTIFY = true; input bool FAST_MODE = false; input int BROKER_SPREAD_THRESHOLD= 6; input double OTC_TRAP_WEIGHT = 15.0; input int CROWD_EXTREME_PCT = 70; input bool ENABLE_BROKER_KILLER = true; input bool ENABLE_SESSION_FILTER = true; input bool ENABLE_SPIKE_FILTER = true; input bool ENABLE_LAST_SEC_BLOCK = true; input bool ENABLE_RISK_CONTROL = true; input bool ENABLE_ENTRY_ZONE = true; input bool ML_ADAPTIVE = true; input bool VOLUME_PROFILE_TRAP = true; input bool MTF_CONFIRM = false; input bool ENABLE_TELEGRAM = false; input string TELEGRAM_TOKEN = ""; input string TELEGRAM_CHAT_ID = ""; input string TRADE_MODE = "NORMAL"; input string STRATEGY_MODE = "TRAP_ONLY"; input int STRATEGY_THRESHOLD = 75; input int MAX_LOSS_STREAK = 2; input double MIN_CONFIDENCE = 75.0; input bool ENABLE_RISK_LOCK = true; input double PATTERN_TOLERANCE_PIPS = 8.0; input int MIN_PATTERN_SEPARATION = 5; input bool SHOW_COMMON_POINTS = true; input double COMMON_POINT_TOL_PIPS = 15.0; input bool SHOW_WICK_REJECT_LINES = true; input int WICK_MIN_TOUCHES = 1; input double WICK_ZONE_PIPS = 15.0; input int WICK_EXPIRE_BARS = 60; input bool ENABLE_BB_PULLBACK = true; input int BB_PERIOD = 20; input double BB_DEVIATION = 2.0; input int BB_SIGNAL_EXPIRE_BARS = 5; input bool ENABLE_MTG = true; input int NCP_OpenNoiseSeconds = 3; input int NCP_KillZoneSeconds = 55; input double NCP_MaxSpreadPips = 4.0; input int NCP_ATRPeriod = 14; input double NCP_MinATRPips = 0.4; input int NCP_FastEMA = 3; input int NCP_MidEMA = 7; input int NCP_SlowEMA = 15; input bool NCP_UseM5Confirm = true; input bool NCP_UseVolume = true; input double NCP_RoundStepPips = 10.0; input double NCP_RoundTolPips = 4.0; input int NCP_MinProbMedium = 57; input int NCP_MinProbStrong = 63; input int NCP_MinProbExtreme = 70; input bool NCP_UseRSINorm = true; input int NCP_RSIPeriod = 10; input double NCP_RSIBase = 50.0; input double NCP_RSIM5Target = 45.0; input double NCP_RSIM15Target = 40.0; input bool ENABLE_LEARNING = true; input string MEMORY_FILE_NAME = "NCP_Brain_v7.csv"; input int MIN_TRADES_TO_LEARN = 15; input double LEARNING_STEP = 0.025; input bool ENABLE_TRAP_DETECTION = true; input int TRAP_LOOKBACK = 30; #define NEON_GREEN C'0,255,100' #define NEON_RED C'255,40,80' #define NEON_YELLOW C'255,220,0' #define NEON_ORANGE C'255,120,0' #define NEON_CYAN C'0,255,200' #define NEON_PURPLE C'200,0,255' #define NEON_PINK C'255,80,180' #define NEON_BLUE C'0,200,255' #define NEON_LIME C'80,255,80' #define NEON_GOLD C'255,180,0' #define DARK_BLUE_NEON C'0,100,255' #define NEON_WHITE C'220,230,255' #define CGR C'160,170,190' #define BB_GREY C'180,180,190' #define BG_DARK1 C'6,8,16' #define BG_DARK2 C'10,14,24' #define BG_DARK3 C'14,20,32' #define BG_DARK4 C'18,26,40' struct HTFLevel{ double price; string timeframe; string type; datetime time; int strength; bool isRoundNumber; }; //--- GLOBALS string g_haM1="",g_haM5="",g_haBoth=""; color g_haM1Color=clrGray,g_haM5Color=clrGray; static double NW[36]; static double g_rsc=0,g_tfa=3; static datetime g_spm_t=0,g_last_bar=0; double ResLevels[MAX_LEVELS],SupLevels[MAX_LEVELS]; int resCount=0,supCount=0; datetime lastSRBar=0; static double g_nearest_res=0,g_nearest_sup=0; static string g_brk_str="NO BRK"; static color g_brk_color=CGR; struct RejLevel{double price;int touches;}; static RejLevel g_rj[MAX_REJ]; static int g_rj_cnt=0; static double g_hrn_price=0; static bool g_hrn_is_sup=true; static int g_hrn_brk_bars=0; static datetime g_hrn_scan_bar=0; static string g_hrn_str="--"; static double g_hrn_score=0; static bool g_hrn_confirmed_break=false; static int g_otcCallPct=50,g_otcPutPct=50; static string g_pairNames[8],g_pairSigs[8]; static double g_pairConfs[8]; static int g_pairCount=0; static double g_frozen_gProb=50,g_frozen_rProb=50; static string g_frozen_pAction="UNCERTAIN"; static color g_frozen_pColor=NEON_YELLOW; static double g_calc_gProb=50,g_calc_rProb=50; static string g_calc_pAction="UNCERTAIN"; static color g_calc_pColor=NEON_YELLOW; static double g_gProb=50,g_rProb=50; static string g_pAction="UNCERTAIN"; static color g_pColor=NEON_YELLOW; static datetime g_last_freeze_bar=0; static double g_accuracy=65.0; static int g_acc_correct=0,g_acc_total=0; static datetime g_acc_lastBar=0; static double g_lastPredGreen=50.0; static datetime g_lastPredBar=0; static string g_finalSignal="WAIT"; static color g_finalColor=NEON_YELLOW; static datetime g_signalTime=0; static string g_lastNotified=""; static string g_marketMode="RANGE",g_prevMode=""; static int g_lossStreak=0; static bool g_tradingStopped=false; static string g_strategyType="NONE"; static string g_strategyReason=""; static double qmrA=0,qmrB=0,qmrC=0,qmrD=0; static bool qmrActive=false; static datetime qmrExpire=0; #define MAX_COMMON_PTS 5 static double g_commonPrice[MAX_COMMON_PTS]; static datetime g_commonTime[MAX_COMMON_PTS]; static int g_commonCount=0; static datetime g_commonExpire[MAX_COMMON_PTS]; static string g_commonType[MAX_COMMON_PTS]; static datetime g_lastCommonScan=0; #define MAX_WICK_LINES 5 static double g_wickLinePrice[MAX_WICK_LINES]; static int g_wickLineTouches[MAX_WICK_LINES]; static datetime g_wickLineExpire[MAX_WICK_LINES]; static int g_wickLineCount=0; static datetime g_lastWickScan=0; static bool g_isSideways=false; static string g_tfa_detail=""; static HTFLevel g_htfLevels[50]; static int g_htfLevelCount=0; static bool g_mtfConfirmed=true; static string g_filterStatus="ALL CLEAR"; static string g_adv1="WAIT KAR"; static string g_symbolKey=""; static double g_brokerBias=0.0; // BB PULLBACK static string g_bbSignal="--"; static color g_bbColor=CGR; static double g_bbTouchPrice=0.0; static datetime g_bbSignalTime=0; static int g_bbSignalBars=0; static string g_bbDetail=""; static double g_ha30_open=0.0,g_ha30_close=0.0,g_ha30_high=0.0,g_ha30_low=0.0; static datetime g_ha30_bar=0; #define MAX_BB_LINES 8 static double g_bbLinePrice[MAX_BB_LINES]; static datetime g_bbLineExpire[MAX_BB_LINES]; static string g_bbLineType[MAX_BB_LINES]; static int g_bbLineCount=0; // NCP PRO static string g_mtgState="INIT"; static string g_mtgReason=""; static string g_mtgAction=""; static color g_mtgClr=CGR; static double g_mtgHype=50.0; static double g_mtgBetrayal=50.0; static string g_mtgPattern=""; static int g_mtgBullCount=0; static int g_mtgBearCount=0; static double g_mtgRecovery=0.0; static datetime g_mtg_lastBar=0; static double g_trapScore=0; static double g_callWeight=1.0; static double g_putWeight=1.0; static int g_totalTrades=0; static int g_callTrades=0; static int g_putTrades=0; static int g_callWins=0; static int g_putWins=0; static datetime g_ncpLastSignalTime=0; static string g_ncpLastSignalType=""; static double g_ncpLastEntryPrice=0.0; static bool g_ncpSignalProcessed=true; static double g_smoothCallScore=50.0; static double g_smoothPutScore=50.0; // NEURAL AI - new proper score static double g_neuralScore=50.0; static string g_neuralDetail=""; static color g_neuralColor=NEON_YELLOW; // REVERSAL - new static string g_reversalSignal="--"; static color g_reversalColor=NEON_YELLOW; static string g_reversalDetail=""; //+------------------------------------------------------------------+ // ============================================================ // FIX 1: NEURAL AI — Real multi-indicator consensus // Pehle: hardcoded neural weights se galat result aata tha // Ab: 8 real indicators ka score = accurate Neural AI % // ============================================================ double CalcNeuralAI(){ if(Bars<30){ g_neuralDetail="Bars low"; g_neuralScore=50; return 50; } bool jpy=(StringFind(Symbol(),"JPY")>=0); double pip=jpy?0.01:0.0001; double score=50.0; string det=""; // 1. RSI M1 (weight: 20) double rsi1=iRSI(NULL,PERIOD_M1,14,PRICE_CLOSE,1); if(rsi1>70){score-=20;det+="RSI_OB ";} else if(rsi1>60){score-=10;det+="RSI_hi ";} else if(rsi1<30){score+=20;det+="RSI_OS ";} else if(rsi1<40){score+=10;det+="RSI_lo ";} else{det+="RSI_mid ";} // 2. Stochastic (weight: 15) double stK=iStochastic(NULL,PERIOD_M1,5,3,3,MODE_SMA,0,MODE_MAIN,1); double stD=iStochastic(NULL,PERIOD_M1,5,3,3,MODE_SMA,0,MODE_SIGNAL,1); if(stK>80&&stKstD){score+=15;det+="STO_OS ";} else if(stK>70){score-=7;det+="STO_hi ";} else if(stK<30){score+=7;det+="STO_lo ";} // 3. MACD crossover (weight: 15) double macdM=iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double macdS=iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1); double macdM2=iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double macdS2=iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_SIGNAL,2); if(macdM>macdS&&macdM2<=macdS2){score+=15;det+="MACD^";} else if(macdM=macdS2){score-=15;det+="MACDv";} else if(macdM>macdS){score+=6;det+="MACD+ ";} else if(macdM0){ double uw=(High[1]-MathMax(Open[1],Close[1]))/rng; double lw=(MathMin(Open[1],Close[1])-Low[1])/rng; if(uw>0.65&&Close[1]0.65&&Close[1]>Open[1]){score+=15;det+="LW_KILL ";} else if(uw>0.50){score-=8;det+="UW_hi ";} else if(lw>0.50){score+=8;det+="LW_hi ";} } // 5. EMA alignment M1 (weight: 12) double ema5=iMA(NULL,PERIOD_M1,5,0,MODE_EMA,PRICE_CLOSE,1); double ema13=iMA(NULL,PERIOD_M1,13,0,MODE_EMA,PRICE_CLOSE,1); double ema21=iMA(NULL,PERIOD_M1,21,0,MODE_EMA,PRICE_CLOSE,1); if(ema5>ema13&&ema13>ema21){score+=12;det+="EMA^ ";} else if(ema5ema13){score+=5;det+="EMA+ ";} else if(ema50){ double vr=vol1/volAvg; if(vr>=2.0){if(Close[1]>Open[1])score+=10;else score-=10;det+="VOL2x ";} else if(vr>=1.5){if(Close[1]>Open[1])score+=5;else score-=5;det+="VOL1.5x ";} } // 7. ADX trend strength (weight: 8) double adx=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_MAIN,1); double pDI=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_PLUSDI,1); double mDI=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_MINUSDI,1); if(adx>=25){ if(pDI>mDI+8){score+=8;det+="ADX_U ";} else if(mDI>pDI+8){score-=8;det+="ADX_D ";} } else {det+="ADX_W ";} // 8. HA M1 confirmation (weight: 10) if(g_haM1=="HA BULLISH 1"){score+=10;det+="HA_B";} else if(g_haM1=="HA BEARISH 1"){score-=10;det+="HA_R";} // Clamp to 5-95 score=MathMax(5.0,MathMin(95.0,score)); g_neuralScore=score; g_neuralDetail=det; if(score>=72){g_neuralColor=NEON_ORANGE;} else if(score>=55){g_neuralColor=NEON_GREEN;} else if(score<=35){g_neuralColor=NEON_CYAN;} else{g_neuralColor=NEON_YELLOW;} return score; } //+------------------------------------------------------------------+ // ============================================================ // FIX 2: S/R LEVELS — 50 bar lookback, proper swing detection // Pehle: sirf 10 bars, bahut chota aur unstable tha // Ab: 50 bars swing, multiple touches = strong S/R // ============================================================ void UpdateSR(){ if(Time[0]==lastSRBar) return; lastSRBar=Time[0]; if(Bars<20) return; bool jpy=(StringFind(Symbol(),"JPY")>=0); double pip=jpy?0.01:0.0001; double cur=Close[0]; // Reset arrays resCount=0; supCount=0; // Scan 50 bars for swing highs/lows int lb=MathMin(50,Bars-5); for(int i=2;i<=lb;i++){ // Swing High: highest of 3 bars on each side bool swHigh=true; for(int k=1;k<=3;k++){ if(i-k<0||i+k>=Bars){swHigh=false;break;} if(High[i]<=High[i-k]||High[i]<=High[i+k]){swHigh=false;break;} } if(swHigh&&High[i]>cur+3*pip) AddRes(High[i]); // Swing Low bool swLow=true; for(int k=1;k<=3;k++){ if(i-k<0||i+k>=Bars){swLow=false;break;} if(Low[i]>=Low[i-k]||Low[i]>=Low[i+k]){swLow=false;break;} } if(swLow&&Low[i]cur) AddRes(nR); } if(supCount<1){ double nS=Low[iLowest(NULL,PERIOD_M1,MODE_LOW,20,1)]; if(nS=0); double pip=jpy?0.01:0.0001; double s=0; // 1. Recent candle momentum (5 bars) double momentum=Close[1]-Close[5]; if(momentum>5*pip) s+=4; else if(momentum>2*pip) s+=2; else if(momentum<-5*pip) s-=4; else if(momentum<-2*pip) s-=2; // 2. Wick rejection at extremes for(int i=1;i<=5;i++){ double rg=High[i]-Low[i]; if(rg<=0) continue; double uw=(High[i]-MathMax(Open[i],Close[i]))/rg; double lw=(MathMin(Open[i],Close[i])-Low[i])/rg; if(uw>0.65&&Close[i]0.65&&Close[i]>Open[i]) s-=3.0; // bullish wick = put signal } // 3. Candle streak int bullStrk=0,bearStrk=0; for(int i=1;i<=8;i++){ if(Close[i]>Open[i]){if(bearStrk>0)break;bullStrk++;} else if(Close[i]0)break;bearStrk++;} else break; } if(bullStrk>=4) s-=5; // too many bulls = reversal soon if(bearStrk>=4) s+=5; if(bullStrk>=6) s-=4; if(bearStrk>=6) s+=4; // 4. Volume spike analysis double v1=(double)iVolume(NULL,PERIOD_M1,1); double vAvg=0; for(int i=2;i<=10;i++) vAvg+=iVolume(NULL,PERIOD_M1,i); vAvg/=9.0; if(vAvg>0){ double vr=v1/vAvg; if(vr>2.5){if(Close[1]>Open[1])s-=5;else s+=5;} else if(vr>1.8){if(Close[1]>Open[1])s-=3;else s+=3;} } // 5. RSI extreme double rsi=iRSI(NULL,PERIOD_M1,14,PRICE_CLOSE,1); if(rsi>75) s-=4; else if(rsi>65) s-=2; if(rsi<25) s+=4; else if(rsi<35) s+=2; // 6. Near S/R? if(g_nearest_res>0){ double distR=(g_nearest_res-Close[0])/pip; if(distR<5) s-=4; else if(distR<10) s-=2; } if(g_nearest_sup>0){ double distS=(Close[0]-g_nearest_sup)/pip; if(distS<5) s+=4; else if(distS<10) s+=2; } // 7. OTC crowd % int c=0; for(int i=1;i<=30;i++) if(Close[i]>Open[i])c++; cp=(int)(c*100.0/30.0); if(cp>=72) s-=5; if(cp<=28) s+=5; // 8. Doji zone (indecision) int dj=0; for(int i=1;i<=8;i++){ double bd=MathAbs(Close[i]-Open[i]),rg=High[i]-Low[i]; if(rg>0&&bd=4) s*=1.4; // 9. EMA slope double ema10=iMA(NULL,PERIOD_M1,10,0,MODE_EMA,PRICE_CLOSE,1); double ema10p=iMA(NULL,PERIOD_M1,10,0,MODE_EMA,PRICE_CLOSE,5); if(ema10>ema10p+2*pip) s+=3; else if(ema10=8&&h<=11)||(h>=14&&h<=17)) mul=1.25; if(h>=3&&h<=6) mul=0.80; return s*mul; } //+------------------------------------------------------------------+ // ============================================================ // FIX 4: REVERSAL DETECTION — Proper candle patterns // Pehle: sirf 2 simple conditions = missed many reversals // Ab: 8 patterns — Pin Bar, Engulf, Doji, Hammer, Shooting Star // ============================================================ string DetectReversal(){ if(Bars<10){g_reversalSignal="--";g_reversalColor=NEON_YELLOW;return "--";} bool jpy=(StringFind(Symbol(),"JPY")>=0); double pip=jpy?0.01:0.0001; double rsi=iRSI(NULL,PERIOD_M1,14,PRICE_CLOSE,1); double atr=iATR(NULL,PERIOD_M1,14,1); if(atr<=0){g_reversalSignal="--";return "--";} double rng1=High[1]-Low[1]; double body1=MathAbs(Close[1]-Open[1]); double uw1=(rng1>0)?(High[1]-MathMax(Open[1],Close[1]))/rng1:0; double lw1=(rng1>0)?(MathMin(Open[1],Close[1])-Low[1])/rng1:0; bool bull1=(Close[1]>Open[1]); bool bear1=(Close[1]0.60&&body10.60&&body155){ bearScore+=30; bearReason+="PinBarv ";} // 3. Bullish Engulfing if(bull1&&body1>MathAbs(Close[2]-Open[2])*1.2&&Close[2]atr*0.4){ bullScore+=25; bullReason+="Engulf^ ";} // 4. Bearish Engulfing if(bear1&&body1>MathAbs(Close[2]-Open[2])*1.2&&Close[2]>Open[2]&&body1>atr*0.4){ bearScore+=25; bearReason+="Engulfv ";} // 5. Hammer (bullish) — small body top, long lower wick if(bull1&&lw1>0.55&&uw1<0.15&&rsi<50){ bullScore+=20; bullReason+="Hammer ";} // 6. Shooting Star (bearish) — small body bottom, long upper wick if(bear1&&uw1>0.55&&lw1<0.15&&rsi>50){ bearScore+=20; bearReason+="ShootStar ";} // 7. Morning Star (3-bar bullish reversal) if(Bars>=4){ bool mornStar=(Close[3]Open[1])&&(Close[1]>=(Open[3]+Close[3])/2.0); if(mornStar&&rsi<55){bullScore+=20; bullReason+="MornStar ";} } // 8. Evening Star (3-bar bearish reversal) if(Bars>=4){ bool eveStar=(Close[3]>Open[3])&& (MathAbs(Close[2]-Open[2])<(High[2]-Low[2])*0.3)&& (Close[1]45){bearScore+=20; bearReason+="EveStar ";} } // RSI confirmation bonus if(rsi<30&&bullScore>0){bullScore+=15; bullReason+="RSI_OS ";} if(rsi>70&&bearScore>0){bearScore+=15; bearReason+="RSI_OB ";} // Near S/R bonus if(g_nearest_sup>0&&(Close[0]-g_nearest_sup)/pip<8&&bullScore>0){ bullScore+=15; bullReason+="@SUP ";} if(g_nearest_res>0&&(g_nearest_res-Close[0])/pip<8&&bearScore>0){ bearScore+=15; bearReason+="@RES ";} // Determine result if(bullScore>=40&&bullScore>bearScore){ string strength=(bullScore>=70)?"STRONG":(bullScore>=55)?"GOOD":"WEAK"; g_reversalSignal="BULL REV"; g_reversalColor=NEON_GREEN; g_reversalDetail=bullReason+strength; return "BULL REVERSAL"; } else if(bearScore>=40&&bearScore>bullScore){ string strength=(bearScore>=70)?"STRONG":(bearScore>=55)?"GOOD":"WEAK"; g_reversalSignal="BEAR REV"; g_reversalColor=NEON_RED; g_reversalDetail=bearReason+strength; return "BEAR REVERSAL"; } g_reversalSignal="--"; g_reversalColor=NEON_YELLOW; g_reversalDetail="No pattern"; return ""; } //+------------------------------------------------------------------+ // 30-SEC HA //+------------------------------------------------------------------+ void Calc30SecHA(){ if(Bars<5) return; double haC_prev2=(Open[2]+High[2]+Low[2]+Close[2])/4.0; double haO_prev2=(Open[3]+Close[3])/2.0; double haO_prev=(haO_prev2+haC_prev2)/2.0; double haC_prev=(Open[1]+High[1]+Low[1]+Close[1])/4.0; double haC_cur=(Open[0]+High[0]+Low[0]+Close[0])/4.0; double haO_cur=(haO_prev+haC_prev)/2.0; g_ha30_open=haO_cur; g_ha30_close=haC_cur; g_ha30_high=High[0]; g_ha30_low=Low[0]; g_ha30_bar=Time[0]; } bool Is30SecHABull(){return(g_ha30_close>g_ha30_open);} bool Is30SecHABear(){return(g_ha30_closeplusDI) putConfirm++; if(rsi>=60) putConfirm++; if(rsi>=70) putConfirm++; if(ha30Bull) callConfirm++; if(plusDI>minusDI) callConfirm++; if(rsi<=40) callConfirm++; if(rsi<=30) callConfirm++; if(g_bbSignal!="--"&&g_bbSignalTime>0){ int barsEl=(int)((TimeCurrent()-g_bbSignalTime)/(Period()*60)); if(barsEl>BB_SIGNAL_EXPIRE_BARS){g_bbSignal="--";g_bbColor=NEON_YELLOW;g_bbDetail="";g_bbTouchPrice=0.0;} } bool touchedUpper=(High[1]>=bbUpper1*0.9998); bool touchedLower=(Low[1]<=bbLower1*1.0002); bool wickUpper=(High[1]>bbUpper1&&Close[1]bbLower1); string newSig="--";double tpNew=0;string detNew="";color newClr=NEON_YELLOW; string adxStr="ADX:"+DoubleToString(adx,0); string rsiStr="RSI:"+DoubleToString(rsi,0); if((touchedUpper||wickUpper)&&putConfirm>=2){ newSig="PUT";tpNew=bbUpper1; string conf=(putConfirm>=4)?"STRONG":(putConfirm>=3)?"GOOD":"WEAK"; detNew="BB UP|"+conf+"|"+adxStr+"|"+rsiStr; newClr=(putConfirm>=3)?NEON_RED:NEON_ORANGE; } else if((touchedLower||wickLower)&&callConfirm>=2){ newSig="CALL";tpNew=bbLower1; string conf=(callConfirm>=4)?"STRONG":(callConfirm>=3)?"GOOD":"WEAK"; detNew="BB LO|"+conf+"|"+adxStr+"|"+rsiStr; newClr=(callConfirm>=3)?NEON_GREEN:NEON_CYAN; } if(newSig!="--"){ bool isNew=(newSig!=g_bbSignal||tpNew!=g_bbTouchPrice); if(isNew){g_bbSignal=newSig;g_bbTouchPrice=tpNew;g_bbSignalTime=TimeCurrent();g_bbDetail=detNew;g_bbColor=newClr;AddBBLine(tpNew,newSig);} } else if(g_bbSignal=="--") g_bbColor=NEON_YELLOW; DrawBBLines(bbUpper0,bbLower0,bbMid0); } void DrawBBLines(double upper,double lower,double mid){ if(!ENABLE_BB_PULLBACK) return; string nmU=PFX+"BB_UPPER";SafeDel(nmU); if(upper>0){ObjectCreate(0,nmU,OBJ_HLINE,0,0,upper);ObjectSetInteger(0,nmU,OBJPROP_COLOR,BB_GREY);ObjectSetInteger(0,nmU,OBJPROP_WIDTH,1);ObjectSetInteger(0,nmU,OBJPROP_STYLE,STYLE_DASH);ObjectSetInteger(0,nmU,OBJPROP_BACK,false);} string nmL=PFX+"BB_LOWER";SafeDel(nmL); if(lower>0){ObjectCreate(0,nmL,OBJ_HLINE,0,0,lower);ObjectSetInteger(0,nmL,OBJPROP_COLOR,BB_GREY);ObjectSetInteger(0,nmL,OBJPROP_WIDTH,1);ObjectSetInteger(0,nmL,OBJPROP_STYLE,STYLE_DASH);ObjectSetInteger(0,nmL,OBJPROP_BACK,false);} string nmM=PFX+"BB_MID";SafeDel(nmM); if(mid>0){ObjectCreate(0,nmM,OBJ_HLINE,0,0,mid);ObjectSetInteger(0,nmM,OBJPROP_COLOR,C'100,100,110');ObjectSetInteger(0,nmM,OBJPROP_WIDTH,1);ObjectSetInteger(0,nmM,OBJPROP_STYLE,STYLE_DOT);ObjectSetInteger(0,nmM,OBJPROP_BACK,false);} } void AddBBLine(double price,string sigType){ if(price<=0) return; for(int i=0;i0&&TimeCurrent()>g_bbLineExpire[0]){g_bbLineCount=0;return;} if(g_bbLineCount<=0) return; string nm=PFX+"BB_TOUCH_0",lbl=PFX+"BB_TOUCH_LBL_0"; ObjectCreate(0,nm,OBJ_HLINE,0,0,g_bbLinePrice[0]);ObjectSetInteger(0,nm,OBJPROP_COLOR,BB_GREY);ObjectSetInteger(0,nm,OBJPROP_WIDTH,2);ObjectSetInteger(0,nm,OBJPROP_STYLE,STYLE_SOLID);ObjectSetInteger(0,nm,OBJPROP_BACK,false); if(Bars>3){string txt=(g_bbLineType[0]=="CALL")?"BB^ CALL":"BBv PUT";color lc=(g_bbLineType[0]=="CALL")?NEON_GREEN:NEON_RED;ObjectCreate(0,lbl,OBJ_TEXT,0,Time[3],g_bbLinePrice[0]);ObjectSetText(lbl,txt,8,"Arial Bold",lc);ObjectSetInteger(0,lbl,OBJPROP_BACK,false);} } //+------------------------------------------------------------------+ // NCP LEARNING ENGINE //+------------------------------------------------------------------+ void LoadBrainMemory(){ if(!ENABLE_LEARNING) return; int h=FileOpen(MEMORY_FILE_NAME,FILE_READ|FILE_CSV|FILE_SHARE_READ); if(h!=INVALID_HANDLE){ if(FileSize(h)>10){ g_totalTrades=(int)FileReadNumber(h);g_callTrades=(int)FileReadNumber(h);g_putTrades=(int)FileReadNumber(h); g_callWins=(int)FileReadNumber(h);g_putWins=(int)FileReadNumber(h); g_callWeight=FileReadNumber(h);g_putWeight=FileReadNumber(h); if(g_callWeight<0.2||g_callWeight>1.8) g_callWeight=1.0; if(g_putWeight<0.2||g_putWeight>1.8) g_putWeight=1.0; } FileClose(h); } } void SaveBrainMemory(){ if(!ENABLE_LEARNING) return; int h=FileOpen(MEMORY_FILE_NAME,FILE_WRITE|FILE_CSV|FILE_SHARE_WRITE); if(h!=INVALID_HANDLE){FileWrite(h,g_totalTrades);FileWrite(h,g_callTrades);FileWrite(h,g_putTrades);FileWrite(h,g_callWins);FileWrite(h,g_putWins);FileWrite(h,g_callWeight);FileWrite(h,g_putWeight);FileClose(h);} } void UpdateBrain(string sig,bool win){ if(!ENABLE_LEARNING) return; g_totalTrades++; if(sig=="CALL"){g_callTrades++;if(win)g_callWins++;} else if(sig=="PUT"){g_putTrades++;if(win)g_putWins++;} if(g_totalTrades0)?(double)g_callWins/g_callTrades:0.5;double adaptive=adj*(wr-0.5)*2.0;if(win)g_callWeight=MathMin(1.8,g_callWeight+adj+adaptive);else g_callWeight=MathMax(0.3,g_callWeight-adj*1.5+adaptive);if(g_callTrades0)?(double)g_putWins/g_putTrades:0.5;double adaptive=adj*(wr-0.5)*2.0;if(win)g_putWeight=MathMin(1.8,g_putWeight+adj+adaptive);else g_putWeight=MathMax(0.3,g_putWeight-adj*1.5+adaptive);if(g_putTradessigOpen); else if(g_ncpLastSignalType=="PUT") win=(sigCloseOpen[i])&&(Close[i-1]=Open[i-1])&&(Open[i]<=Close[i-1]); bool bearEngulf=(Close[i]Open[i-1])&&(Close[i]<=Open[i-1])&&(Open[i]>=Close[i-1]); if(i-3>=1){if(bullEngulf&&Close[i-3]Close[i-2])trapScore+=3.0;} double rng=High[i-1]-Low[i-1];if(rng<=0)continue; double uw=(High[i-1]-MathMax(Open[i-1],Close[i-1]))/rng; double lw=(MathMin(Open[i-1],Close[i-1])-Low[i-1])/rng; if(uw>0.6&&Close[i-1]0.6&&Close[i-1]>Open[i-1])trapScore+=1.5; } return MathMin(100,trapScore); } //+------------------------------------------------------------------+ // NCP PRO MAIN — FIX: raw score for signal, smooth for display //+------------------------------------------------------------------+ void CalculateMTG(){ if(!ENABLE_MTG||Bars<50){g_mtgState="OFF";g_mtgReason="";g_mtgClr=CGR;return;} bool jpy=(StringFind(Symbol(),"JPY")>=0); double pip=jpy?0.01:0.0001; CheckPreviousResult(); int sec=(int)(TimeCurrent()-Time[0]); if(sec=NCP_KillZoneSeconds){g_mtgState="END";g_mtgReason="Late";g_mtgClr=NEON_ORANGE;g_mtgHype=50;g_mtgBetrayal=50;return;} double spPips=MarketInfo(Symbol(),MODE_SPREAD)*Point/pip; if(spPips>NCP_MaxSpreadPips){g_mtgState="SPREAD";g_mtgReason=DoubleToString(spPips,1)+"p";g_mtgClr=NEON_ORANGE;g_mtgHype=50;g_mtgBetrayal=50;return;} double atr=iATR(Symbol(),PERIOD_M1,NCP_ATRPeriod,1); double atrPips=atr/pip; if(atrPipseM&&eM>eS),dnTrend=(eFeS),dnBias=(eFh5M&&h5M>h5S);h5Dn=(h5F0)?NCP_RSIBase/NCP_RSIM5Target:1.0; double nM15=(NCP_RSIM15Target>0)?NCP_RSIBase/NCP_RSIM15Target:1.0; double r1=iRSI(NULL,0,NCP_RSIPeriod,PRICE_CLOSE,1); double r5=iRSI(NULL,PERIOD_M5,NCP_RSIPeriod,PRICE_CLOSE,1); double r15=iRSI(NULL,PERIOD_M15,NCP_RSIPeriod,PRICE_CLOSE,1); double n5v=r5*nM5,n15v=r15*nM15; int rBullCt=(r1>NCP_RSIBase?1:0)+(n5v>NCP_RSIBase?1:0)+(n15v>NCP_RSIBase?1:0); int rBearCt=(r1=2),rBear2=(rBearCt>=2); double stK=iStochastic(Symbol(),PERIOD_M1,5,3,3,MODE_SMA,0,MODE_MAIN,1); bool stOS=(stK<25),stOB=(stK>75); double macdM=iMACD(NULL,0,8,17,5,PRICE_CLOSE,MODE_MAIN,1); double macdS=iMACD(NULL,0,8,17,5,PRICE_CLOSE,MODE_SIGNAL,1); double macdM2=iMACD(NULL,0,8,17,5,PRICE_CLOSE,MODE_MAIN,2); double macdS2=iMACD(NULL,0,8,17,5,PRICE_CLOSE,MODE_SIGNAL,2); bool macdBull=(macdM>macdS),macdBear=(macdMmacdS&&macdM2<=macdS2); bool macdCrossDn=(macdM=macdS2); double body1=MathAbs(Close[1]-Open[1]),rng1=High[1]-Low[1]; if(rng1<=0){g_mtgState="WAIT";return;} double uwPct=(High[1]-MathMax(Open[1],Close[1]))/rng1; double lwPct=(MathMin(Open[1],Close[1])-Low[1])/rng1; double bPct=body1/rng1; bool bull1=(Close[1]>Open[1]),bear1=(Close[1]=0.5&&body1>atr*0.3); bool sBear=(bear1&&bPct>=0.5&&body1>atr*0.3); bool rejUp=(uwPct>0.40&&bPct<0.50); bool rejDn=(lwPct>0.40&&bPct<0.50); bool doji=(bPct<0.20); double mom1=(Close[1]-Close[2])/pip,mom3=(Close[1]-Close[4])/pip; bool bMom=(mom1>0.8&&mom3>1.5),brMom=(mom1<-0.8&&mom3<-1.5); double hh3=MathMax(High[2],MathMax(High[3],High[4])); double ll3=MathMin(Low[2],MathMin(Low[3],Low[4])); bool bkUp=(Close[1]>hh3&&body1>atr*0.25); bool bkDn=(Close[1]atr*0.25); bool fkUp=(High[1]>hh3&&Close[1]ll3); int bullRun=0,bearRun=0; for(int i=1;i<=6&&iOpen[i]){if(bearRun>0)break;bullRun++;}else if(Close[i]0)break;bearRun++;}else break;} double rndSt=NCP_RoundStepPips*pip,rndTl=NCP_RoundTolPips*pip; double bs=MathFloor(Close[1]/rndSt)*rndSt; bool rrUp=false,rrDn=false; for(int k=-1;k<=1;k++){double lv=bs+k*rndSt;if(MathAbs(Close[1]-lv)<=rndTl){if(High[1]>lv&&Close[1]lv+pip)rrDn=true;break;}} double v1=(double)Volume[1],vAvg=0; for(int i=2;i<=11;i++) vAvg+=(double)Volume[i]; vAvg/=10.0; bool hiVol=(NCP_UseVolume&&vAvg>0&&v1>vAvg*1.2); bool loVol=(NCP_UseVolume&&vAvg>0&&v1=3){pS+=14;cS-=7;}if(bearRun>=3){cS+=14;pS-=7;} if(bullRun>=4){pS+=8;}if(bearRun>=4){cS+=8;} if(rrUp){pS+=10;cS-=5;}if(rrDn){cS+=10;pS-=5;} if(NCP_UseVolume){if(hiVol){if(bull1)cS+=7;if(bear1)pS+=7;}if(loVol){cS-=2;pS-=2;}} double tBull=0,tBear=0; for(int t=2;t<=60&&tr*0.55&&Close[t]r*0.55&&Close[t]>Open[t])tBull+=1.2;} if(tBull>tBear+2.0)cS+=MathMin(12.0,(tBull-tBear)); if(tBear>tBull+2.0)pS+=MathMin(12.0,(tBear-tBull)); int bC=0,brC=0; if(upTrend||upBias)bC++;if(dnTrend||dnBias)brC++; if(h5Up)bC++;if(h5Dn)brC++;if(rBull2)bC++;if(rBear2)brC++; if(stOS)bC++;if(stOB)brC++;if(macdBull||macdCrossUp)bC++;if(macdBear||macdCrossDn)brC++; if(bMom)bC++;if(brMom)brC++;if(sBull)bC++;if(sBear)brC++; if(rejDn)bC++;if(rejUp)brC++;if(bkUp||fkDn)bC++;if(bkDn||fkUp)brC++; if(rrDn)bC++;if(rrUp)brC++;if(hiVol&&bull1)bC++;if(hiVol&&bear1)brC++; if(bearRun>=3)bC++;if(bullRun>=3)brC++; if(bC>=4)cS+=5;if(brC>=4)pS+=5;if(bC>=6)cS+=5;if(brC>=6)pS+=5;if(bC>=8)cS+=4;if(brC>=8)pS+=4; cS=MathMax(1.0,cS);pS=MathMax(1.0,pS); double tot=cS+pS;cS=(cS/tot)*100.0;pS=100.0-cS; if(ENABLE_LEARNING&&g_totalTrades>=MIN_TRADES_TO_LEARN){ double wCap=MathMax(0.6,g_callWeight),wPap=MathMax(0.6,g_putWeight); cS*=wCap;pS*=wPap;tot=cS+pS;if(tot>0){cS=(cS/tot)*100.0;pS=100.0-cS;} } g_trapScore=0; if(ENABLE_TRAP_DETECTION){ g_trapScore=CalculateBrokerTrap(cS,pS); if(g_trapScore>75){if(cS>pS){pS+=22;cS-=12;}else{cS+=22;pS-=12;}tot=cS+pS;cS=(cS/tot)*100.0;pS=100.0-cS;} } // FIX: Smooth sirf display ke liye, raw cS/pS signal ke liye double sf=0.50; g_smoothCallScore=g_smoothCallScore*(1.0-sf)+cS*sf; g_smoothPutScore=g_smoothPutScore*(1.0-sf)+pS*sf; double st2=g_smoothCallScore+g_smoothPutScore; if(st2>0){g_smoothCallScore=(g_smoothCallScore/st2)*100.0;g_smoothPutScore=100.0-g_smoothCallScore;} // Display = smoothed g_mtgHype=NormalizeDouble(g_smoothCallScore,1); g_mtgBetrayal=NormalizeDouble(g_smoothPutScore,1); double edge=MathAbs(cS-pS); string str="WEAK"; if(edge>=26)str="EXTREME";else if(edge>=18)str="STRONG";else if(edge>=10)str="MEDIUM"; g_mtgPattern=str;g_mtgBullCount=bC;g_mtgBearCount=brC;g_mtgRecovery=NormalizeDouble(atrPips,1); string rsiStr=""; if(NCP_UseRSINorm)rsiStr="R1:"+DoubleToString(r1,0)+" T:"+DoubleToString(g_trapScore,0); int minP=NCP_MinProbMedium; if(str=="STRONG")minP=NCP_MinProbStrong; if(str=="EXTREME")minP=NCP_MinProbExtreme; if(Time[0]!=g_ncpLastSignalTime){g_ncpLastSignalTime=Time[0];g_ncpSignalProcessed=false;} bool isTrap=(ENABLE_TRAP_DETECTION&&g_trapScore>75); // Signal = raw cS/pS (no smoothing delay) if(cS>=minP&&cS>pS){ g_mtgState=isTrap?"PUT TRAP":"CALL"; g_mtgReason=rsiStr; g_mtgAction=isTrap?"PUT "+DoubleToString(g_trapScore,0)+"% TRAP!":"CALL "+DoubleToString(cS,1)+"% ["+str+"]"; g_mtgClr=isTrap?NEON_PURPLE:(str=="EXTREME")?NEON_GREEN:(str=="STRONG")?NEON_LIME:NEON_CYAN; if(!g_ncpSignalProcessed){g_ncpLastSignalType=isTrap?"PUT":"CALL";g_ncpLastSignalTime=Time[0];} } else if(pS>=minP&&pS>cS){ g_mtgState=isTrap?"CALL TRAP":"PUT"; g_mtgReason=rsiStr; g_mtgAction=isTrap?"CALL "+DoubleToString(g_trapScore,0)+"% TRAP!":"PUT "+DoubleToString(pS,1)+"% ["+str+"]"; g_mtgClr=isTrap?NEON_PURPLE:(str=="EXTREME")?NEON_RED:(str=="STRONG")?C'255,60,60':NEON_ORANGE; if(!g_ncpSignalProcessed){g_ncpLastSignalType=isTrap?"CALL":"PUT";g_ncpLastSignalTime=Time[0];} } else { g_mtgState="WAIT";g_mtgReason=rsiStr; string edgeDir=(cS>pS)?">C":">P"; g_mtgAction=edgeDir+" "+DoubleToString(MathMax(cS,pS),0)+"%"; g_mtgClr=NEON_YELLOW;g_ncpSignalProcessed=true; } } //+------------------------------------------------------------------+ // HA CANDLE //+------------------------------------------------------------------+ void CalcHA(){ if(Bars<10) return; ArraySetAsSeries(Open,true);ArraySetAsSeries(High,true);ArraySetAsSeries(Low,true);ArraySetAsSeries(Close,true); static double haO1[500],haC1[500];static datetime lb1=0; ArraySetAsSeries(haO1,true);ArraySetAsSeries(haC1,true); datetime c1=iTime(NULL,PERIOD_M1,0); if(c1!=lb1){lb1=c1;int lim=MathMin(iBars(NULL,PERIOD_M1),500); for(int i=lim-1;i>=0;i--){haC1[i]=(Open[i]+High[i]+Low[i]+Close[i])/4.0;if(i==lim-1)haO1[i]=(Open[i]+Close[i])/2.0;else haO1[i]=(haO1[i+1]+haC1[i+1])/2.0;}} double d1=MathAbs(haC1[1]-haO1[1]),r1=High[1]-Low[1]; bool dz=(r1>0&&d1haO1[1]),be1=(!dz&&haC1[1]=10){ static double haO5[200],haC5[200];static datetime lb5=0; ArraySetAsSeries(haO5,true);ArraySetAsSeries(haC5,true); datetime c5=iTime(NULL,PERIOD_M5,0); if(c5!=lb5){lb5=c5;int lim=MathMin(iBars(NULL,PERIOD_M5),200); for(int i=lim-1;i>=0;i--){double o=iOpen(NULL,PERIOD_M5,i),h=iHigh(NULL,PERIOD_M5,i),l=iLow(NULL,PERIOD_M5,i),c=iClose(NULL,PERIOD_M5,i);haC5[i]=(o+h+l+c)/4.0;if(i==lim-1)haO5[i]=(o+c)/2.0;else haO5[i]=(haO5[i+1]+haC5[i+1])/2.0;}} double d5=MathAbs(haC5[1]-haO5[1]),r5=iHigh(NULL,PERIOD_M5,1)-iLow(NULL,PERIOD_M5,1); bool dz5=(r5>0&&d5haO5[1]),be5=(!dz5&&haC5[1]=0);double pip=jpy?0.01:0.0001;double tol=pipTol*pip;for(int i=ObjectsTotal()-1;i>=0;i--){string nm=ObjectName(i);if((int)ObjectGetInteger(0,nm,OBJPROP_TYPE)==OBJ_HLINE){double lp=ObjectGetDouble(0,nm,OBJPROP_PRICE);if(MathAbs(lp-price)=12&&h<16){sC=NEON_GOLD;return "LON+NY";}if(h>=7&&h<9){sC=NEON_CYAN;return "ASI+LON";}if(h>=7&&h<16){sC=NEON_GREEN;return "LONDON";}if(h>=12&&h<21){sC=NEON_BLUE;return "NEW YORK";}if(h>=0&&h<9){sC=NEON_ORANGE;return "ASIA";}sC=C'100,100,120';return "SYDNEY";} bool IsSessionActive(){int h=TimeHour(TimeGMT());return(h>=7&&h<=21);} bool IsBigCandle(int s){if(Bars<20)return false;double a=iATR(NULL,PERIOD_M1,14,0);return(a>0&&(High[s]-Low[s])>a*1.8);} bool CheckMTFConfirmation(){if(!MTF_CONFIRM)return true;bool m1Bull=(Close[1]>Open[1]);bool m5Bull=false,m15Bull=false;if(iBars(NULL,PERIOD_M5)>=3)m5Bull=(iClose(NULL,PERIOD_M5,1)>iOpen(NULL,PERIOD_M5,1));if(iBars(NULL,PERIOD_M15)>=3)m15Bull=(iClose(NULL,PERIOD_M15,1)>iOpen(NULL,PERIOD_M15,1));int bullCount=0,bearCount=0;if(m1Bull)bullCount++;else bearCount++;if(m5Bull)bullCount++;else bearCount++;if(m15Bull)bullCount++;else bearCount++;g_mtfConfirmed=(bullCount>=2||bearCount>=2);return g_mtfConfirmed;} double CalcAdvancedTFA(string &detail){ if(Bars<30){detail="Bars low";return 3.0;} double score=0;string p=""; double adx=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_MAIN,1);double adxSc=(adx>=25)?1.0:(adx>=20)?0.6:(adx>=15)?0.3:0.1;score+=adxSc;p+="ADX:"+((adxSc>=0.6)?"+":"-")+" "; double v1=iVolume(NULL,PERIOD_M1,1),vA=0;for(int i=2;i<=6;i++)vA+=iVolume(NULL,PERIOD_M1,i);vA=(vA>0)?vA/5.0:1;double vr=v1/vA;double volSc=(vr>=2.0)?1.0:(vr>=1.5)?0.7:(vr>=1.1)?0.4:0.1;score+=volSc;p+="VOL:"+((volSc>=0.5)?"+":"-")+" "; double rsi=iRSI(NULL,PERIOD_M1,14,PRICE_CLOSE,1);double rsiSc=0.2;if(rsi>=60||rsi<=40)rsiSc=1.0;else if(rsi>=55||rsi<=45)rsiSc=0.6;score+=rsiSc;p+="RSI:"+((rsiSc>=0.6)?"+":"-")+" "; double atr=iATR(NULL,PERIOD_M1,14,1),cs=High[1]-Low[1],atrSc=0.2;if(atr>0){double r=cs/atr;if(r>=0.7&&r<=1.5)atrSc=1.0;else if(r>=0.5&&r<=2.0)atrSc=0.6;else atrSc=0.3;}score+=atrSc;p+="ATR:"+((atrSc>=0.6)?"+":"-")+" "; double body=MathAbs(Close[1]-Open[1]),range=High[1]-Low[1],bdySc=0.2;if(range>0){double br=body/range;if(br>=0.6)bdySc=1.0;else if(br>=0.4)bdySc=0.6;else if(br>=0.2)bdySc=0.3;}score+=bdySc;p+="BODY:"+((bdySc>=0.6)?"+":"-")+" "; double sesSc=IsSessionActive()?1.0:0.4;score+=sesSc;p+="SES:"+((sesSc>=0.7)?"+":"-"); double finalScore=MathMin(6.0,score);int rounded=(int)MathRound(finalScore); string dir="MIX"; if(g_haM1=="HA BULLISH 1"&&g_haM5=="HA BULLISH 5")dir="STRONG UP"; else if(g_haM1=="HA BEARISH 1"&&g_haM5=="HA BEARISH 5")dir="STRONG DOWN"; else if(g_haM1=="HA BULLISH 1")dir="UP"; else if(g_haM1=="HA BEARISH 1")dir="DOWN"; detail=p+" | "+IntegerToString(rounded)+"/6 "+dir;g_tfa_detail=detail;return finalScore; } double CalcAdvancedMicroAI(){ if(Bars<20)return 50.0;double score=50.0; for(int i=1;i<=5;i++){double r=High[i]-Low[i];if(r<=0)continue;double uw=(High[i]-MathMax(Open[i],Close[i]))/r,lw=(MathMin(Open[i],Close[i])-Low[i])/r,w=(6.0-i)/5.0;if(uw>0.60)score-=w*15;if(lw>0.60)score+=w*15;} double pos5=0;for(int i=1;i<=5;i++){double r=High[i]-Low[i];if(r<=0)continue;pos5+=(Close[i]-Low[i])/r;}score+=(pos5/5.0-0.5)*20.0; int gc=0,rc=0;for(int i=1;i<=8;i++){if(Close[i]>Open[i])gc++;else if(Close[i]0){double vr=vl1/vA;if(vr>1.5&&Close[1]>Open[1])score+=8;if(vr>1.5&&Close[1]65)score-=10;if(r1>r5&&Close[1]Close[5])score-=6; return MathMax(5.0,MathMin(95.0,score)); } double VolumeTrapScore(){ if(!VOLUME_PROFILE_TRAP||Bars<50)return 0; double cur=Close[0],hi=High[iHighest(NULL,0,MODE_HIGH,50,1)],lo=Low[iLowest(NULL,0,MODE_LOW,50,1)]; double rg=hi-lo;if(rg<=0)return 0;int zn=5;double zs=rg/zn;double vz[5]={0,0,0,0,0};int zc[5]={0,0,0,0,0}; for(int i=1;i<=50;i++){double p=Close[i];int z=(int)((p-lo)/zs);if(z<0)z=0;if(z>=zn)z=zn-1;vz[z]+=Volume[i];zc[z]++;} for(int z=0;z0)vz[z]/=zc[z]; int cz=(int)((cur-lo)/zs);if(cz<0)cz=0;if(cz>=zn)cz=zn-1; double wr=((High[1]-MathMax(Open[1],Close[1]))+(MathMin(Open[1],Close[1])-Low[1]))/(High[1]-Low[1]+0.00001); double vr=(double)Volume[1]/(vz[cz]+0.001); if(vr>2.0&&wr>0.65)return 25;if(vr>1.8&&wr>0.55)return 15;return 0; } int CalcAdvancedMicroTrap(){ if(Bars<20)return 0;int score=0;double r=High[1]-Low[1]; if(r>0){double uw=(High[1]-MathMax(Open[1],Close[1]))/r,lw=(MathMin(Open[1],Close[1])-Low[1])/r;if(uw>0.65)score+=30;else if(uw>0.50)score+=15;if(lw>0.65)score+=20;else if(lw>0.50)score+=10;} double v1=(double)iVolume(NULL,PERIOD_M1,1),v2=(double)iVolume(NULL,PERIOD_M1,2); if(v2>0&&v1/v2>2.0)score+=25;else if(v2>0&&v1/v2>1.5)score+=12; double rsi=iRSI(NULL,PERIOD_M1,14,PRICE_CLOSE,1);if(rsi>78||rsi<22)score+=20;else if(rsi>72||rsi<28)score+=10; if((High[1]>g_nearest_res&&Close[1]g_nearest_sup))score+=25; bool aG=(Close[1]>Open[1]&&Close[2]>Open[2]&&Close[3]>Open[3]),aR=(Close[1]BROKER_SPREAD_THRESHOLD*1.5)score+=10; score+=(int)VolumeTrapScore();return MathMin(100,score); } double UltimateTrapScore(){ double wr=((High[1]-MathMax(Open[1],Close[1]))+(MathMin(Open[1],Close[1])-Low[1]))/(High[1]-Low[1]+0.00001); double v1=(double)iVolume(NULL,PERIOD_M1,1),v2=(double)iVolume(NULL,PERIOD_M1,2); double avg=v2>0?v2:1.0,vr=v1/avg,rsi=iRSI(NULL,PERIOD_M1,14,PRICE_CLOSE,1),sc=0.0; if(wr>0.65)sc+=40;if(vr>2.0)sc+=30;if(rsi>75||rsi<25)sc+=20; if((High[1]>g_nearest_res&&Close[1]g_nearest_sup))sc+=25; sc+=VolumeTrapScore();return MathMin(100.0,sc); } bool IsBrokerForce(double dummy=0){int sd=0;for(int i=1;i<=3;i++){if(Close[i]>Open[i])sd++;else sd--;}double v1=(double)iVolume(NULL,PERIOD_M1,1),v2=(double)iVolume(NULL,PERIOD_M1,2);double sp=(double)MarketInfo(Symbol(),MODE_SPREAD);return(MathAbs(sd)==3&&v1>v2*2.0&&sp>BROKER_SPREAD_THRESHOLD);} string CalcAdvancedMarketBias(color &bC,double brain,double rsc){ if(Bars<30){bC=NEON_YELLOW;return "CALCULATING";} double score=0;bool jpy=(StringFind(Symbol(),"JPY")>=0);double pip=jpy?0.01:0.0001; double pc=Close[0]-Close[10];if(pc>5*pip)score+=4;else if(pc>2*pip)score+=2;else if(pc<-5*pip)score-=4;else if(pc<-2*pip)score-=2; double hh1=High[iHighest(NULL,PERIOD_M1,MODE_HIGH,5,1)],hh2=High[iHighest(NULL,PERIOD_M1,MODE_HIGH,5,6)]; double ll1=Low[iLowest(NULL,PERIOD_M1,MODE_LOW,5,1)],ll2=Low[iLowest(NULL,PERIOD_M1,MODE_LOW,5,6)]; if(hh1>hh2&&ll1>ll2)score+=4;else if(hh1hh2)score+=2;else if(hh1ema20p)score+=3;else if(ema20ema50)score+=3;else score-=3; int gC=0,rC=0;for(int i=1;i<=10;i++){if(Close[i]>Open[i])gC++;else if(Close[i]=7)score+=3;else if(rC>=7)score-=3;else if(gC>=5)score+=1;else if(rC>=5)score-=1; bool m1B=(g_haM1=="HA BULLISH 1"),m1Be=(g_haM1=="HA BEARISH 1"),m5B=(g_haM5=="HA BULLISH 5"),m5Be=(g_haM5=="HA BEARISH 5"); if(m1B&&m5B)score+=4;else if(m1Be&&m5Be)score-=4;else if(m1B)score+=2;else if(m1Be)score-=2; double adx=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_MAIN,1),pDI=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_PLUSDI,1),mDI=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_MINUSDI,1); if(adx>20){if(pDI>mDI+5)score+=4;else if(mDI>pDI+5)score-=4;} if(brain>3)score-=2;else if(brain<-3)score+=2; if(Close[1]>Open[1])score+=1;else if(Close[1]2)score+=1;else if(rsc<-2)score-=1; if(score>=12){bC=NEON_GREEN;return "STRONG BULL";}if(score>=7){bC=NEON_GREEN;return "BULLISH";}if(score>=3){bC=NEON_CYAN;return "LIGHT BULL";} if(score<=-12){bC=NEON_RED;return "STRONG BEAR";}if(score<=-7){bC=NEON_RED;return "BEARISH";}if(score<=-3){bC=NEON_ORANGE;return "LIGHT BEAR";} bC=NEON_YELLOW;return "NEUTRAL"; } void CalcAdvancedPrediction(double &gP,double &rP,string &reason,color &pC){ if(Bars<50){gP=50;rP=50;reason="Bars low";pC=NEON_YELLOW;return;} bool jpy=(StringFind(Symbol(),"JPY")>=0);double pip=jpy?0.01:0.0001; double green=0,red=0; double body1=MathAbs(Close[1]-Open[1]),range1=High[1]-Low[1]; if(range1>0){double uw=High[1]-MathMax(Open[1],Close[1]),lw=MathMin(Open[1],Close[1])-Low[1];if(uw>range1*0.60&&Close[1]>Open[1])red+=22;else if(lw>range1*0.60&&Close[1]0.55){if(uw>lw)red+=12;else green+=12;}} double rsi=iRSI(NULL,PERIOD_M1,14,PRICE_CLOSE,1),cci=iCCI(NULL,PERIOD_M1,14,PRICE_TYPICAL,1),stochK=iStochastic(NULL,PERIOD_M1,5,3,3,MODE_SMA,0,MODE_MAIN,1); int os=0,ob=0;if(rsi<30)os++;else if(rsi>70)ob++;if(cci<-120)os++;else if(cci>120)ob++;if(stochK<20)os++;else if(stochK>80)ob++; if(os>=3)green+=18;else if(os>=2)green+=12;else if(ob>=3)red+=18;else if(ob>=2)red+=12; double rsiPrev=iRSI(NULL,PERIOD_M1,14,PRICE_CLOSE,5); double low1=Low[iLowest(NULL,PERIOD_M1,MODE_LOW,5,1)],low2=Low[iLowest(NULL,PERIOD_M1,MODE_LOW,5,6)]; double high1=High[iHighest(NULL,PERIOD_M1,MODE_HIGH,5,1)],high2=High[iHighest(NULL,PERIOD_M1,MODE_HIGH,5,6)]; if(low1rsiPrev&&rsi<45)green+=15;if(high1>high2&&rsi55)red+=15; double v1=iVolume(NULL,PERIOD_M1,1),vAvg=0;for(int i=2;i<=10;i++)vAvg+=iVolume(NULL,PERIOD_M1,i);vAvg=(vAvg>0)?vAvg/9.0:1.0; double vol_ratio=(vAvg>0)?v1/vAvg:1.0; if(vol_ratio>2.0){if(Close[1]>Open[1])red+=20;else green+=20;}else if(vol_ratio>1.5){if(Close[1]>Open[1])red+=12;else green+=12;}else if(vol_ratio>1.2){if(Close[1]>Open[1])green+=5;else red+=5;} double m1_haC1=(Open[1]+High[1]+Low[1]+Close[1])/4.0,m1_haC2=(Open[2]+High[2]+Low[2]+Close[2])/4.0; double m1_haO2=(Open[3]+Close[3])/2.0,m1_haO1=(m1_haO2+m1_haC2)/2.0;bool haBull1=(m1_haC1>m1_haO1); double haStr1=MathAbs(m1_haC1-m1_haO1)/(High[1]-Low[1]+0.00001); bool haBull5=false; if(iBars(NULL,PERIOD_M5)>=5){double o1=iOpen(NULL,PERIOD_M5,1),h1=iHigh(NULL,PERIOD_M5,1),l1=iLow(NULL,PERIOD_M5,1),c1=iClose(NULL,PERIOD_M5,1);double o2=iOpen(NULL,PERIOD_M5,2),h2=iHigh(NULL,PERIOD_M5,2),l2=iLow(NULL,PERIOD_M5,2),c2=iClose(NULL,PERIOD_M5,2);double o3=iOpen(NULL,PERIOD_M5,3),c3=iClose(NULL,PERIOD_M5,3);double haC1_5=(o1+h1+l1+c1)/4.0,haC2_5=(o2+h2+l2+c2)/4.0,haO2_5=(o3+c3)/2.0,haO1_5=(haO2_5+haC2_5)/2.0;haBull5=(haC1_5>haO1_5);} if(haBull1&&haBull5)green+=15;else if(!haBull1&&!haBull5)red+=15;else if(haBull1&&haStr1>0.5)green+=8;else if(!haBull1&&haStr1>0.5)red+=8; double adx=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_MAIN,1),plusDI=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_PLUSDI,1),minusDI=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_MINUSDI,1); double diDiff=plusDI-minusDI; if(adx>25){if(diDiff>8)green+=12;else if(diDiff>4)green+=8;else if(diDiff<-8)red+=12;else if(diDiff<-4)red+=8;}else if(adx>15){if(plusDI>minusDI)green+=4;else red+=4;}else{if(Close[1]>Open[1])red+=3;else green+=3;} double sup=Low[iLowest(NULL,PERIOD_M1,MODE_LOW,20,2)],res=High[iHighest(NULL,PERIOD_M1,MODE_HIGH,20,2)]; double dR=(res-Close[0])/pip,dS=(Close[0]-sup)/pip; if(dR<8&&dR>=0)red+=12;else if(dR<15&&dR>=0)red+=6;if(dS<8&&dS>=0)green+=12;else if(dS<15&&dS>=0)green+=6; if(g_hrn_price>0){double dH=MathAbs(Close[0]-g_hrn_price)/pip;if(dH<5){if(Close[0]>g_hrn_price)red+=8;else green+=8;}} double macdMain=iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_MAIN,1),macdSig=iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1); double macdPrev=iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_MAIN,2),macdSigPrev=iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_SIGNAL,2); if(macdMain>macdSig&&macdPrev<=macdSigPrev)green+=10;else if(macdMain=macdSigPrev)red+=10;else if(macdMain>macdSig)green+=5;else if(macdMain=75&&!haBull1)red+=15;else if(g_otcPutPct>=75&&haBull1)green+=15;else if(g_otcCallPct>=65&&!haBull1)red+=8;else if(g_otcPutPct>=65&&haBull1)green+=8; if(ENABLE_BB_PULLBACK&&g_bbSignal=="CALL")green+=12;else if(ENABLE_BB_PULLBACK&&g_bbSignal=="PUT")red+=12; double diff=MathMax(-100.0,MathMin(100.0,green-red)); gP=MathMax(8.0,MathMin(92.0,50.0+diff*0.65));rP=100.0-gP; double dom=MathMax(gP,rP); if(dom>=82){reason=(gP>rP)?"STRONG GREEN":"STRONG RED";pC=(gP>rP)?NEON_GREEN:NEON_RED;} else if(dom>=72){reason=(gP>rP)?"GREEN":"RED";pC=(gP>rP)?NEON_GREEN:NEON_RED;} else if(dom>=60){reason=(gP>rP)?"WEAK GREEN":"WEAK RED";pC=(gP>rP)?NEON_CYAN:NEON_ORANGE;} else{reason="WAIT";pC=NEON_YELLOW;} } string DetectMyStrategy(){ int cc=g_otcCallPct,cp=g_otcPutPct,thr=STRATEGY_THRESHOLD; if(STRATEGY_MODE=="BOTH"||STRATEGY_MODE=="TRAP_ONLY"){if(cc>=thr&&g_haM1=="HA BEARISH 1"){g_strategyType="TRAP";g_strategyReason="CALL "+IntegerToString(cc)+"% + HA RED";return "PUT";}if(cp>=thr&&g_haM1=="HA BULLISH 1"){g_strategyType="TRAP";g_strategyReason="PUT "+IntegerToString(cp)+"% + HA GREEN";return "CALL";}} if(STRATEGY_MODE=="BOTH"||STRATEGY_MODE=="TREND_ONLY"){if(cc>=thr&&g_haM1=="HA BULLISH 1"){g_strategyType="TREND";g_strategyReason="CALL "+IntegerToString(cc)+"% + HA GREEN";return "CALL";}if(cp>=thr&&g_haM1=="HA BEARISH 1"){g_strategyType="TREND";g_strategyReason="PUT "+IntegerToString(cp)+"% + HA RED";return "PUT";}} g_strategyType="NONE";g_strategyReason="Wait "+IntegerToString(thr)+"% + HA";return "WAIT"; } void CalcOTCCrowd(){ int cS=0,pS=0;int weights[15];for(int w=0;w<15;w++)weights[w]=15-w*2;for(int w=0;w<15;w++)if(weights[w]<1)weights[w]=1; for(int i=1;i<=15&&i0.70&&Close[i]0.70&&Close[i]>Open[i])pS+=4*wgt;if(uw>0.55&&Close[i]0.55&&Close[i]>Open[i])pS+=2*wgt;if(Close[i]>Open[i])cS+=1*wgt;else if(Close[i]=rP){g_otcCallPct=MathMax(50,rC);g_otcPutPct=100-g_otcCallPct;}else{g_otcPutPct=MathMax(50,rP);g_otcCallPct=100-g_otcPutPct;}} } void CalcPrediction(double brain,double nb,int cp,double mai,int mts,double rsc,bool bf,double mw){ string ms=DetectMyStrategy();bool sA=(ms!="WAIT"); if(sA&&g_strategyType=="TRAP"){if(ms=="PUT"){g_gProb=12.0;g_rProb=88.0;g_pAction="PUT TRAP!";g_pColor=NEON_PURPLE;g_calc_gProb=g_gProb;g_calc_rProb=g_rProb;g_calc_pAction=g_pAction;g_calc_pColor=g_pColor;return;}if(ms=="CALL"){g_gProb=88.0;g_rProb=12.0;g_pAction="CALL TRAP!";g_pColor=NEON_PURPLE;g_calc_gProb=g_gProb;g_calc_rProb=g_rProb;g_calc_pAction=g_pAction;g_calc_pColor=g_pColor;return;}} double tS=UltimateTrapScore();bool bF2=IsBrokerForce(); if(TRADE_MODE=="HUNT"){if(tS<85){g_gProb=50;g_rProb=50;g_pAction="HUNT: WAIT";g_pColor=NEON_YELLOW;g_calc_gProb=50;g_calc_rProb=50;g_calc_pAction=g_pAction;g_calc_pColor=g_pColor;return;}} if(ENABLE_BROKER_KILLER&&(tS>=85||(tS>=75&&bF2))&&g_marketMode!="TREND"){g_gProb=15;g_rProb=85;g_pAction="TRAP DETECTED";g_pColor=NEON_PURPLE;g_calc_gProb=15;g_calc_rProb=85;g_calc_pAction=g_pAction;g_calc_pColor=g_pColor;return;} double gS=0,rS=0,ab=MathMax(0.70,MathMin(1.30,g_accuracy/65.0)); if(IsSidewaysMarket()){bool jpy=(StringFind(Symbol(),"JPY")>=0);double pip=jpy?0.01:0.0001;bool nR=(g_nearest_res>0&&(g_nearest_res-Close[0])<8*pip),nS=(g_nearest_sup>0&&(Close[0]-g_nearest_sup)<8*pip);if(!nR&&!nS){g_gProb=50;g_rProb=50;g_pAction="SIDEWAYS";g_pColor=NEON_YELLOW;g_calc_gProb=50;g_calc_rProb=50;g_calc_pAction=g_pAction;g_calc_pColor=g_pColor;return;}if(nR)rS+=20;if(nS)gS+=20;} if(sA&&g_strategyType=="TREND"){double sw=50.0;if(ms=="CALL"){gS+=sw*ab;g_pAction="TREND: CALL!";g_pColor=NEON_GREEN;}else if(ms=="PUT"){rS+=sw*ab;g_pAction="TREND: PUT!";g_pColor=NEON_RED;}} if(g_haM1=="HA BULLISH 1"&&g_haM5=="HA BULLISH 5")gS+=60;else if(g_haM1=="HA BEARISH 1"&&g_haM5=="HA BEARISH 5")rS+=60;else if(g_haM1=="HA BULLISH 1")gS+=30;else if(g_haM1=="HA BEARISH 1")rS+=30; if(HA_ALIGN_FILTER&&g_haBoth=="MIXED"){gS*=0.5;rS*=0.5;} gS+=(nb-50)/50.0*22*ab;rS-=(nb-50)/50.0*22*ab; double bn=MathMax(-1.0,MathMin(1.0,brain/10.0));gS+=bn*15*ab;rS-=bn*15*ab; bool jpy=(StringFind(Symbol(),"JPY")>=0);double pip=jpy?0.01:0.0001; if(g_nearest_res>0&&(g_nearest_res-Close[0])<10*pip)rS+=12;if(g_nearest_sup>0&&(Close[0]-g_nearest_sup)<10*pip)gS+=12; double rsi1=iRSI(NULL,PERIOD_M1,14,PRICE_CLOSE,1);if(rsi1>70)rS+=6;if(rsi1<30)gS+=6; double sn=MathMax(-1.0,MathMin(1.0,rsc/3.0));gS+=sn*8*ab;rS-=sn*8*ab; if(ENABLE_BB_PULLBACK){if(g_bbSignal=="CALL")gS+=18*ab;else if(g_bbSignal=="PUT")rS+=18*ab;} int sk=StreakReversalSignal();if(sk==1)gS+=18;if(sk==-1)rS+=18; double adxV=GetADXStrength();int adxD=GetADXDirection();if(adxV>25){if(adxD==1)gS+=12;if(adxD==-1)rS+=12;}if(adxV<15){gS*=0.7;rS*=0.7;} int vs=SmartVolumeSignal();if(vs==1)gS+=12;if(vs==-1)rS+=12; if(!IsVolatilityGood()){gS*=0.5;rS*=0.5;} double diff=MathMax(-100.0,MathMin(100.0,gS-rS)); g_gProb=MathMax(8.0,MathMin(92.0,50.0+(diff/1.8)));g_rProb=100.0-g_gProb; if(sA&&g_strategyType=="TREND"){if(ms=="CALL"){g_gProb=MathMax(g_gProb,85.0);g_rProb=100.0-g_gProb;}if(ms=="PUT"){g_rProb=MathMax(g_rProb,85.0);g_gProb=100.0-g_rProb;}g_gProb=MathMin(92.0,MathMax(8.0,g_gProb));g_rProb=100.0-g_gProb;} double dom=MathMax(g_gProb,g_rProb); if(dom>=82){if(g_gProb>g_rProb){if(!sA){g_pAction="GREEN";g_pColor=NEON_GREEN;}}else{if(!sA){g_pAction="RED";g_pColor=NEON_RED;}}} else if(dom>=75){if(g_gProb>g_rProb){if(!sA){g_pAction="GREEN";g_pColor=NEON_CYAN;}}else{if(!sA){g_pAction="RED";g_pColor=NEON_ORANGE;}}} else{if(!sA){g_pAction="WAIT";g_pColor=NEON_YELLOW;}} g_calc_gProb=g_gProb;g_calc_rProb=g_rProb;g_calc_pAction=g_pAction;g_calc_pColor=g_pColor; } void DetectCommonPoints(){ if(!SHOW_COMMON_POINTS){g_commonCount=0;return;} if(Time[0]==g_lastCommonScan)return;g_lastCommonScan=Time[0];g_commonCount=0; datetime nowBar=Time[0];int periodSec=PeriodSeconds(PERIOD_M1); double m5h=iHigh(NULL,PERIOD_M5,iHighest(NULL,PERIOD_M5,MODE_HIGH,10,1)); double m5l=iLow(NULL,PERIOD_M5,iLowest(NULL,PERIOD_M5,MODE_LOW,10,1)); if(m5l>0&&g_commonCount0&&g_hrn_is_sup&&g_commonCount0&&g_commonCount0&&!g_hrn_is_sup&&g_commonCount=0;i--)if(TimeCurrent()>g_commonExpire[i]){for(int j=i;jg_commonExpire[i])continue;if(IsLineNearby(g_commonPrice[i],8.0))continue; string id=PFX+"COMMON_"+IntegerToString(i),idL=PFX+"COMMON_L_"+IntegerToString(i),idH=PFX+"COMMON_HL_"+IntegerToString(i);color zc=DARK_BLUE_NEON; ObjectCreate(0,idH,OBJ_HLINE,0,0,g_commonPrice[i]);ObjectSetInteger(0,idH,OBJPROP_COLOR,zc);ObjectSetInteger(0,idH,OBJPROP_WIDTH,3);ObjectSetInteger(0,idH,OBJPROP_STYLE,STYLE_SOLID);ObjectSetInteger(0,idH,OBJPROP_BACK,false); ObjectCreate(0,id,OBJ_TEXT,0,Time[0],g_commonPrice[i]);ObjectSetText(id,"*",16,"Arial",zc);ObjectSetInteger(0,id,OBJPROP_BACK,false); string lbl=(g_commonType[i]=="CALL")?"^ CALL ZONE":"v PUT ZONE"; ObjectCreate(0,idL,OBJ_TEXT,0,Time[0]+PeriodSeconds(PERIOD_M1)*3,g_commonPrice[i]);ObjectSetText(idL,lbl,10,"Arial Bold",zc);ObjectSetInteger(0,idL,OBJPROP_BACK,false);} } void DetectWickRejections(){ g_isSideways=IsSidewaysMarket();if(!SHOW_WICK_REJECT_LINES){g_wickLineCount=0;return;} if(Time[0]==g_lastWickScan)return;g_lastWickScan=Time[0]; bool jpy=(StringFind(Symbol(),"JPY")>=0);double pip=jpy?0.01:0.0001;double zone=WICK_ZONE_PIPS*pip*2;double cur=Close[0]; g_wickLineCount=0;datetime now=Time[0],expT=now+PeriodSeconds(PERIOD_M1)*WICK_EXPIRE_BARS*2; for(int i=1;i<=40&&irg*0.30){rl=High[i];if(MathAbs(cur-rl)rg*0.30){rl=Low[i];if(MathAbs(cur-rl)=0;i--)if(TimeCurrent()>g_wickLineExpire[i]){for(int j=i;j=0);double pip=jpy?0.01:0.0001;double cur=Close[0]; for(int i=0;ig_wickLineExpire[i])continue;if(MathAbs(cur-g_wickLinePrice[i])/pip>20.0)continue;if(IsLineNearby(g_wickLinePrice[i],5.0))continue; string id=PFX+"WICK_"+IntegerToString(i),idL=PFX+"WICK_L_"+IntegerToString(i);color lc=C'0,180,255'; ObjectCreate(0,id,OBJ_HLINE,0,0,g_wickLinePrice[i]);ObjectSetInteger(0,id,OBJPROP_COLOR,lc);ObjectSetInteger(0,id,OBJPROP_WIDTH,2);ObjectSetInteger(0,id,OBJPROP_STYLE,STYLE_DOT);ObjectSetInteger(0,id,OBJPROP_BACK,false); string lbl="W"+IntegerToString(g_wickLineTouches[i])+"x"; ObjectCreate(0,idL,OBJ_TEXT,0,Time[0]+PeriodSeconds(PERIOD_M1)*2,g_wickLinePrice[i]);ObjectSetText(idL,lbl,9,"Arial Bold",lc);ObjectSetInteger(0,idL,OBJPROP_BACK,false);} } double GetWickRejectSignal(){if(!g_isSideways||g_wickLineCount==0)return 0;double sc=0;bool jpy=(StringFind(Symbol(),"JPY")>=0);double pip=jpy?0.01:0.0001;for(int i=0;i=0);double pip=jpy?0.01:0.0001;for(int i=0;ig_commonExpire[i])continue;double d=MathAbs(Close[0]-g_commonPrice[i])/pip;if(d<8){if(g_commonType[i]=="CALL")sc+=25;else sc-=25;}}return MathMax(-30,MathMin(30,sc));} void DetectHiddenLevels(){g_htfLevelCount=0;bool jpy=(StringFind(Symbol(),"JPY")>=0);double pip=jpy?0.01:0.0001;double curP=Close[0];double rU=MathCeil(curP/(10*pip))*(10*pip),rD=MathFloor(curP/(10*pip))*(10*pip);if(MathAbs(curP-rU)/pip<=15)AddLevel(rU,"ROUND","RESISTANCE",TimeCurrent(),8,true);if(MathAbs(curP-rD)/pip<=15)AddLevel(rD,"ROUND","SUPPORT",TimeCurrent(),8,true);DetectHTFLevels(PERIOD_M5,"M5",3,pip);DetectHTFLevels(PERIOD_M15,"M15",5,pip);DetectHTFLevels(PERIOD_M30,"M30",7,pip);DetectHTFLevels(PERIOD_H1,"H1",9,pip);SortLevelsByStrength();} void DetectHTFLevels(ENUM_TIMEFRAMES tf,string tfN,int bS,double pip){int bars=MathMin(50,iBars(NULL,tf));if(bars<10)return;double curP=Close[0];for(int i=2;i=iBars(NULL,tf))return false;if(iHigh(NULL,tf,p-i)>=h||iHigh(NULL,tf,p+i)>=h)return false;}return true;} bool IsSwingLow(ENUM_TIMEFRAMES tf,int p,int lb){double l=iLow(NULL,tf,p);for(int i=1;i<=lb;i++){if(p-i<0||p+i>=iBars(NULL,tf))return false;if(iLow(NULL,tf,p-i)<=l||iLow(NULL,tf,p+i)<=l)return false;}return true;} void AddLevel(double price,string tf,string type,datetime time,int strength,bool isRound){if(g_htfLevelCount>=50)return;bool jpy=(StringFind(Symbol(),"JPY")>=0);double pip=jpy?0.01:0.0001;for(int i=0;i=0);double pip=jpy?0.01:0.0001;if(MathAbs(Close[0]-g_htfLevels[i].price)/pip>30)continue;if(IsLineNearby(g_htfLevels[i].price,5.0))continue;string nm=PFX+"HTF_LEVEL_"+IntegerToString(drawn);color lc=g_htfLevels[i].isRoundNumber?NEON_PURPLE:(StringFind(g_htfLevels[i].type,"SUPPORT")>=0?NEON_GREEN:NEON_RED);ObjectCreate(0,nm,OBJ_HLINE,0,0,g_htfLevels[i].price);ObjectSetInteger(0,nm,OBJPROP_COLOR,lc);ObjectSetInteger(0,nm,OBJPROP_WIDTH,1);ObjectSetInteger(0,nm,OBJPROP_STYLE,STYLE_DOT);ObjectSetInteger(0,nm,OBJPROP_BACK,false);string ln=nm+"_LBL";ObjectCreate(0,ln,OBJ_TEXT,0,Time[0],g_htfLevels[i].price);ObjectSetText(ln,StringFormat("%s %s S:%d",g_htfLevels[i].timeframe,g_htfLevels[i].type,g_htfLevels[i].strength),9,"Arial",lc);drawn++;}} void SafeDel(string id){if(ObjectFind(0,id)>=0)ObjectDelete(0,id);} void DrawHLine(string id,double price,color clr,int width,int style){if(price<=0)return;SafeDel(id);ObjectCreate(0,id,OBJ_HLINE,0,0,price);ObjectSetInteger(0,id,OBJPROP_COLOR,clr);ObjectSetInteger(0,id,OBJPROP_WIDTH,width);ObjectSetInteger(0,id,OBJPROP_STYLE,style);ObjectSetInteger(0,id,OBJPROP_BACK,false);} void HideSPM(){for(int i=ObjectsTotal()-1;i>=0;i--){string nm=ObjectName(i);if(StringFind(nm,PFX)==0)continue;if(StringFind(nm,PFX+"candle_timer")>=0)continue;int tp=(int)ObjectGetInteger(0,nm,OBJPROP_TYPE);if(tp==OBJ_LABEL||tp==OBJ_RECTANGLE_LABEL||tp==OBJ_TEXT)ObjectDelete(0,nm);}} void NuclearDeleteAll(){for(int i=ObjectsTotal()-1;i>=0;i--){string nm=ObjectName(i);if(StringFind(nm,PFX+"candle_timer")>=0)continue;int tp=(int)ObjectGetInteger(0,nm,OBJPROP_TYPE);if(tp==OBJ_HLINE||tp==OBJ_LABEL||tp==OBJ_RECTANGLE_LABEL||tp==OBJ_TEXT)ObjectDelete(0,nm);}} void DelDashboard(){for(int i=ObjectsTotal()-1;i>=0;i--){string nm=ObjectName(i);if(StringFind(nm,PFX)!=0)continue;if(StringFind(nm,"HRN_LINE")>=0)continue;if(StringFind(nm,"HRN_LBL")>=0)continue;if(StringFind(nm,"candle_timer")>=0)continue;if(StringFind(nm,"HTF_LEVEL")>=0)continue;if(StringFind(nm,"COMMON_")>=0)continue;if(StringFind(nm,"WICK_")>=0)continue;if(StringFind(nm,"BB_")>=0)continue;ObjectDelete(nm);}} void LoadMLWeights(){if(!ML_ADAPTIVE)return;g_symbolKey=Symbol();string fn="ML_weights_"+g_symbolKey+".dat";int h=FileOpen(fn,FILE_READ|FILE_TXT);if(h!=INVALID_HANDLE){string d=FileReadString(h);FileClose(h);g_brokerBias=StringToDouble(d);if(g_brokerBias<-0.5)g_brokerBias=-0.5;if(g_brokerBias>0.5)g_brokerBias=0.5;}else g_brokerBias=0.0;} void SaveMLWeights(){if(!ML_ADAPTIVE)return;string fn="ML_weights_"+g_symbolKey+".dat";int h=FileOpen(fn,FILE_WRITE|FILE_TXT);if(h!=INVALID_HANDLE){FileWriteString(h,DoubleToString(g_brokerBias,6));FileClose(h);}} void UpdateMLWeights(bool win){if(!ML_ADAPTIVE)return;double lr=0.02;if(win)g_brokerBias+=lr*(g_frozen_gProb/100.0);else g_brokerBias-=lr*(g_frozen_rProb/100.0);if(g_brokerBias>0.5)g_brokerBias=0.5;if(g_brokerBias<-0.5)g_brokerBias=-0.5;SaveMLWeights();} void UpdateAccuracy(){if(Bars<5||Time[0]==g_acc_lastBar)return;g_acc_lastBar=Time[0];if(g_lastPredBar==Time[1]&&MathAbs(g_lastPredGreen-50.0)>10.0){bool aG=(Close[1]>Open[1]),pG=(g_lastPredGreen>50.0),win=(aG==pG);if(win){g_acc_correct++;g_lossStreak=0;}else g_lossStreak++;g_acc_total++;if(g_acc_total>0)g_accuracy=MathMax(40.0,MathMin(90.0,(double)g_acc_correct/g_acc_total*100.0));if(ML_ADAPTIVE&&g_lastPredGreen>50.0&&g_lastPredGreen<100.0)UpdateMLWeights(win);}g_lastPredGreen=g_frozen_gProb;g_lastPredBar=Time[0];} double ValidateHistoricalAccuracy(){if(Bars<55)return 65.0;int cr=0,tt=0;for(int i=10;i<=50&&i+1Open[j])gc++;double pG=(gc>2)?65.0:35.0;bool aG=(Close[i]>Open[i]);if((pG>55&&aG)||(pG<45&&!aG))cr++;tt++;}return tt>0?(double)cr/tt*100.0:65.0;} void UpdateWeights(){} string DetectMarketMode(double brain,double rsc,int cp,double nb){double atr=iATR(NULL,PERIOD_M1,14,1),avgR=(High[1]-Low[1]+High[2]-Low[2]+High[3]-Low[3])/3.0;bool hV=(avgR>0&&atr/avgR>1.3);if(MathAbs(brain)>=3.5&&MathAbs(rsc)>=1.5&&hV)return "TREND";if(cp>=70||cp<=30)return "REVERSAL";if(nb>=70||nb<=30)return "TREND";return "RANGE";} bool IsSidewaysMarket(){if(Bars<30)return false;double adx=GetADXStrength();if(adx<25)return true;double h20=High[iHighest(NULL,PERIOD_M1,MODE_HIGH,20,1)],l20=Low[iLowest(NULL,PERIOD_M1,MODE_LOW,20,1)];double r20=h20-l20;double atr=iATR(NULL,PERIOD_M1,14,1);if(atr>0&&r20=0);double mr=jpy?0.30:0.0030;if(tr0&&(High[0]-Low[0])Open[i]){if(r>0)break;g++;}else if(Close[i]0)break;r++;}else break;}if(g>=4)return -1;if(r>=4)return 1;return 0;} double GetADXStrength(){if(Bars<20)return 0;return iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_MAIN,1);} int GetADXDirection(){if(Bars<20)return 0;double p=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_PLUSDI,1),m=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_MINUSDI,1);if(p>m+5)return 1;if(m>p+5)return -1;return 0;} int SmartVolumeSignal(){if(Bars<15)return 0;double v1=(double)iVolume(NULL,PERIOD_M1,1),avg=0;for(int i=2;i<=10;i++)avg+=iVolume(NULL,PERIOD_M1,i);avg/=9.0;if(avg==0)return 0;double vr=v1/avg;if(vr<1.8)return 0;bool g=(Close[1]>Open[1]);if(vr>2.5&&g)return 1;if(vr>2.5&&!g)return -1;if(vr>3.0&&g&&High[1]-Close[1]>Close[1]-Low[1])return -1;if(vr>3.0&&!g&&Close[1]-Low[1]>High[1]-Close[1])return 1;return 0;} void AddRNLevel(double &arr[],int &cnt,double lv){if(cnt>=100)return;for(int i=0;i=level-tol&&l<=level+tol){touches++;if(l<=level+tol&&c>level+tol){ru++;double bdy=MathMin(o,c),lw=bdy-l,rng=h-l;if(rng>0&&lw>rng*0.5)score+=5;}if(h>=level-tol&&c0&&uw>rng*0.5)score+=5;}}}score+=touches*3;score+=ru*8+rd*8;if(touches>=4)score+=15;else if(touches>=3)score+=10;else if(touches>=2)score+=5;return score;} double FindBestHiddenRoundNumber(double curPrice){ bool jpy=(StringFind(Symbol(),"JPY")>=0);double pip=jpy?0.01:0.0001;int dg=(int)MarketInfo(Symbol(),MODE_DIGITS);if(dg<=0)dg=5; double levels[];int levelCount=0;ArrayResize(levels,100); double b100=MathFloor(curPrice/(100*pip))*(100*pip);for(int i=-1;i<=2;i++)AddRNLevel(levels,levelCount,b100+i*100*pip); double b50=MathFloor(curPrice/(50*pip))*(50*pip);for(int i=-2;i<=3;i++)AddRNLevel(levels,levelCount,b50+i*50*pip); double b25=MathFloor(curPrice/(25*pip))*(25*pip);for(int i=-3;i<=4;i++)AddRNLevel(levels,levelCount,b25+i*25*pip); double b10=MathFloor(curPrice/(10*pip))*(10*pip);for(int i=-5;i<=6;i++)AddRNLevel(levels,levelCount,b10+i*10*pip); double b5=MathFloor(curPrice/(5*pip))*(5*pip);for(int i=-4;i<=5;i++)AddRNLevel(levels,levelCount,b5+i*5*pip); double bestLevel=0,bestScore=-1; for(int i=0;i60)continue;double dp=(dist>40)?20:(dist>30)?10:(dist>20)?5:0;double sc=ScoreRoundNumber(lv,pip)-dp;if(sc<5)continue;if(sc>bestScore){bestScore=sc;bestLevel=lv;}} if(bestLevel==0){double n10=MathRound(curPrice/(10*pip))*(10*pip);bestLevel=n10;} g_hrn_score=bestScore;return NormalizeDouble(bestLevel,dg);} void UpdateHRN(){ if(Bars=0);double pip=jpy?0.01:0.0001;int dg=(int)MarketInfo(Symbol(),MODE_DIGITS);if(dg<=0)dg=5; if(Time[0]!=g_hrn_scan_bar){double nH=FindBestHiddenRoundNumber(Close[0]);if(g_hrn_price==0||MathAbs(nH-g_hrn_price)>2*pip){g_hrn_price=nH;g_hrn_is_sup=(Close[0]>g_hrn_price);g_hrn_brk_bars=0;g_hrn_confirmed_break=false;}g_hrn_scan_bar=Time[0];} double tol=1*pip; if(g_hrn_is_sup){if(Bars>=3){bool c1b=(Close[1]=3){bool c1a=(Close[1]>g_hrn_price+tol),c2a=(Close[2]>g_hrn_price+tol);if(c1a&&c2a){g_hrn_confirmed_break=true;g_hrn_brk_bars=HRN_CONFIRM_BARS;}else if(c1a)g_hrn_brk_bars=1;else g_hrn_brk_bars=0;}} if(g_hrn_brk_bars>=HRN_CONFIRM_BARS){double nH=FindBestHiddenRoundNumber(Close[0]);if(MathAbs(nH-g_hrn_price)>3*pip){g_hrn_price=nH;g_hrn_is_sup=(Close[0]>g_hrn_price);g_hrn_brk_bars=0;g_hrn_confirmed_break=false;}else{g_hrn_is_sup=(Close[0]>g_hrn_price);g_hrn_brk_bars=0;g_hrn_confirmed_break=false;}} g_hrn_str=DoubleToString(NormalizeDouble(g_hrn_price,dg),dg); color hrnColor=g_hrn_is_sup?NEON_GREEN:NEON_RED;if(g_hrn_brk_bars==1)hrnColor=NEON_YELLOW; DrawHLine(PFX+"HRN_LINE",g_hrn_price,hrnColor,3,STYLE_SOLID); string ln=PFX+"HRN_LBL";SafeDel(ln);string typeStr=g_hrn_is_sup?"SUP":"RES";string confStr=(g_hrn_brk_bars==1)?" [1/2]":(g_hrn_confirmed_break?" [SHIFTING]":""); ObjectCreate(0,ln,OBJ_TEXT,0,Time[0]+Period()*60*2,g_hrn_price);ObjectSetText(ln,"HRN "+typeStr+" "+g_hrn_str+confStr,10,"Arial Bold",hrnColor);ObjectSetInteger(0,ln,OBJPROP_BACK,false);} void AddRes(double lv){if(lv<=0)return;for(int i=0;i=MAX_LEVELS){for(int i=0;i=MAX_LEVELS){for(int i=0;icur&&(ResLevels[i]-cur)0&&pC>g_nearest_res&&pO<=g_nearest_res){g_brk_str="BRK UP!";g_brk_color=NEON_GREEN;}else if(g_nearest_sup>0&&pC=g_nearest_sup){g_brk_str="BRK DOWN!";g_brk_color=NEON_RED;}} //+------------------------------------------------------------------+ // TIMER — quarter candle right //+------------------------------------------------------------------+ void UpdateTimer(){ if(!SHOW_TIMER) return; string nm=PFX+"candle_timer"; int ps=Period()*60; int el=(int)(TimeCurrent()-Time[0]); int rem=ps-el;if(rem<=0)rem=ps;if(rem>ps)rem=ps; int mm=rem/60,ss=rem%60; string t=(mm>0?IntegerToString(mm)+":":"")+(ss<10?"0":"")+IntegerToString(ss)+"s"; double atrVal=iATR(NULL,PERIOD_M1,14,0); double offset=(atrVal>0)?atrVal*0.25:Point*30; datetime tPos=Time[0]+(Period()*60/4); double pPos=High[0]+offset; if(ObjectFind(0,nm)<0){ObjectCreate(0,nm,OBJ_TEXT,0,tPos,pPos);ObjectSetInteger(0,nm,OBJPROP_BACK,false);ObjectSetInteger(0,nm,OBJPROP_SELECTABLE,false);ObjectSetInteger(0,nm,OBJPROP_HIDDEN,false);} ObjectSetInteger(0,nm,OBJPROP_TIME,tPos);ObjectSetDouble(0,nm,OBJPROP_PRICE,pPos); ObjectSetText(nm,t,11,"Arial Bold",NEON_YELLOW); } void InitNW(){NW[0]=0.852;NW[1]=0.724;NW[2]=0.913;NW[3]=0.681;NW[4]=0.795;NW[5]=0.836;NW[6]=0.772;NW[7]=0.894;NW[8]=0.623;NW[9]=0.748;NW[10]=0.887;NW[11]=0.716;NW[12]=0.661;NW[13]=0.829;NW[14]=0.753;NW[15]=0.942;NW[16]=0.784;NW[17]=0.697;NW[18]=0.871;NW[19]=0.735;NW[20]=0.813;NW[21]=0.768;NW[22]=0.932;NW[23]=0.674;NW[24]=0.845;NW[25]=0.709;NW[26]=0.888;NW[27]=0.651;NW[28]=0.921;NW[29]=0.743;NW[30]=0.802;NW[31]=0.867;NW[32]=1.24;NW[33]=-0.93;NW[34]=1.15;NW[35]=-1.08;} void Bx(string id,int x,int y,int w,int h,color bg,color bd){string n=PFX+id;if(ObjectFind(0,n)<0)ObjectCreate(0,n,OBJ_RECTANGLE_LABEL,0,0,0);ObjectSetInteger(0,n,OBJPROP_XDISTANCE,x);ObjectSetInteger(0,n,OBJPROP_YDISTANCE,y);ObjectSetInteger(0,n,OBJPROP_XSIZE,w);ObjectSetInteger(0,n,OBJPROP_YSIZE,h);ObjectSetInteger(0,n,OBJPROP_BGCOLOR,bg);ObjectSetInteger(0,n,OBJPROP_BORDER_TYPE,BORDER_FLAT);ObjectSetInteger(0,n,OBJPROP_COLOR,bd);ObjectSetInteger(0,n,OBJPROP_BACK,false);} void Tx(string id,int x,int y,string txt,color tc,int fs,bool bold){string n=PFX+id;if(ObjectFind(0,n)<0)ObjectCreate(0,n,OBJ_LABEL,0,0,0);ObjectSetInteger(0,n,OBJPROP_XDISTANCE,x);ObjectSetInteger(0,n,OBJPROP_YDISTANCE,y);ObjectSetText(n,txt,fs,bold?"Arial Bold":"Arial",tc);ObjectSetInteger(0,n,OBJPROP_BACK,false);} void NeonBar(string id,int x,int y,int w,int h,double pct,color fc){Bx(id+"_bg",x,y,w,h,BG_DARK4,BG_DARK4);int fw=(int)(pct/100.0*w);if(fw<4)fw=4;if(fw>w)fw=w;Bx(id+"_f",x,y,fw,h,fc,fc);} void Cube(string id,int x,int y,int w,int h,color bc,color bg,string lbl,color lc,string val,color vc,int vfs){Bx(id,x,y,w,h,bg,bc);if(StringLen(lbl)>0)Tx(id+"_l",x+10,y+6,lbl,lc,11,true);if(StringLen(val)>0)Tx(id+"_v",x+10,y+38,val,vc,vfs,true);} void DrawOtherPairsCube(int x,int y,int w,int h){ Bx("c20",x,y,w,h,BG_DARK2,NEON_GOLD);Tx("c20_l",x+8,y+4,"OTHER PAIRS",NEON_CYAN,10,true); if(g_pairCount==0){Tx("c20_v0",x+8,y+30,"No signals yet",CGR,10,false);return;} int lY=24; for(int i=0;ih-4)break; string sp=g_pairNames[i];if(StringLen(sp)>9)sp=StringSubstr(sp,0,9); int qScore=(int)g_pairConfs[i]; string qLabel=(qScore>=80)?"[S]":(qScore>=65)?"[G]":(qScore>=50)?"[M]":"[W]"; bool isCallSig=(g_mtgState=="CALL"||g_mtgState=="CALL TRAP"); bool isPutSig=(g_mtgState=="PUT"||g_mtgState=="PUT TRAP"); bool ncpMatch=((isCallSig&&g_pairSigs[i]=="CALL")||(isPutSig&&g_pairSigs[i]=="PUT")); color dc;string prefix=""; if(ncpMatch){dc=NEON_PURPLE;prefix="* ";}else{dc=(g_pairSigs[i]=="CALL")?NEON_GREEN:NEON_RED;} Tx("c20_p"+IntegerToString(i),x+8,y+lY,prefix+sp+" "+g_pairSigs[i]+" "+IntegerToString(qScore)+qLabel,dc,10,true); lY+=20; } } void DrawOTCQuickCube(int x,int y,int w,int h){ Bx("c_quick",x,y,w,h,BG_DARK2,NEON_LIME);Tx("c_quick_l",x+8,y+2,"OTC QUICK",NEON_CYAN,10,true); int age=(int)(TimeCurrent()-Time[0]);int ps=Period()*60;int rem=ps-age;if(rem<0)rem=0; int mm=rem/60,ss2=rem%60;string tl=(mm>0?IntegerToString(mm)+"m ":"")+IntegerToString(ss2)+"s"; Tx("c_quick_t",x+8,y+20,"Time: "+tl,NEON_GOLD,11,true); double spread=MarketInfo(Symbol(),MODE_SPREAD);color spC=(spread<=BROKER_SPREAD_THRESHOLD)?NEON_GREEN:NEON_ORANGE; Tx("c_quick_s",x+8,y+38,"Spread: "+DoubleToString(spread,0),spC,10,true); double volLast=(double)iVolume(NULL,PERIOD_M1,1),volPrev=(double)iVolume(NULL,PERIOD_M1,2); double volRatio=(volPrev>0)?volLast/volPrev:1.0; bool candleBull=(Close[1]>Open[1]),candleBear=(Close[1]=2.0){vColor=NEON_GREEN;vText="UP "+DoubleToString(volRatio,1)+"x HI";}else if(volRatio>=1.3){vColor=NEON_LIME;vText="UP "+DoubleToString(volRatio,1)+"x MD";}else{vColor=NEON_CYAN;vText="UP "+DoubleToString(volRatio,1)+"x LO";}} else if(candleBear){if(volRatio>=2.0){vColor=NEON_RED;vText="DN "+DoubleToString(volRatio,1)+"x HI";}else if(volRatio>=1.3){vColor=NEON_ORANGE;vText="DN "+DoubleToString(volRatio,1)+"x MD";}else{vColor=NEON_PINK;vText="DN "+DoubleToString(volRatio,1)+"x LO";}} else{vColor=NEON_YELLOW;vText="DOJI "+DoubleToString(volRatio,1)+"x";} Tx("c_quick_v",x+8,y+56,vText,vColor,11,true); string es=GetEntryStatus();color eC=GetEntryColor();Tx("c_quick_e",x+8,y+76,es,eC,10,true); } string GetEntryStatus(){int age=(int)(TimeCurrent()-Time[0]);int ps=Period()*60;int rem=ps-age;if(rem<0)rem=0;string ms=DetectMyStrategy();if(ms!="WAIT"){string type=(g_strategyType=="TRAP")?"TRAP":"TREND";if(ENTRY_MODE=="FLAG"){if(ageFLAG_MAX_SEC)return type+" LATE";return type+" OPEN "+IntegerToString(rem)+"s";}if(ageTIME_MAX_SEC)return type+" CLOSED";return type+" OPEN "+IntegerToString(age)+"s";}if(ENTRY_MODE=="FLAG"){if(ageFLAG_MAX_SEC)return "LATE";return "OPEN "+IntegerToString(rem)+"s left";}if(ageTIME_MAX_SEC)return "CLOSED";return "OPEN "+IntegerToString(age)+"s";} color GetEntryColor(){string s=GetEntryStatus();if(StringFind(s,"TRAP OPEN")>=0)return NEON_PURPLE;if(StringFind(s,"TREND OPEN")>=0)return NEON_LIME;if(StringFind(s,"OPEN")>=0)return NEON_GREEN;if(StringFind(s,"WAIT")>=0)return NEON_YELLOW;if(StringFind(s,"LATE")>=0||StringFind(s,"EXPIRED")>=0||StringFind(s,"CLOSED")>=0)return NEON_ORANGE;return NEON_RED;} bool DirectionOK(){if(!ENABLE_ENTRY_ZONE)return true;double cur=Close[0],lo=Low[0],hi=High[0],rg=hi-lo;if(rg==0)return true;double pos=(cur-lo)/rg*100.0;if(MathMax(g_calc_gProb,g_calc_rProb)>=85)return true;string ms=DetectMyStrategy();if(ms=="CALL")return(pos>REVERSAL_PCT);if(ms=="PUT")return(pos<(100.0-REVERSAL_PCT));if(StringFind(g_adv1,"CALL")>=0)return(pos>REVERSAL_PCT&&(hi-cur)=0)return(pos<(100.0-REVERSAL_PCT)&&(cur-lo)80&&Close[0]80&&Close[0]>Open[0])return false;return true;} bool ConsensusOK(){if(!CONSENSUS_FILTER)return true;string ms=DetectMyStrategy();if(ms=="WAIT")return true;bool haAgree=false;if(ms=="CALL"&&(g_haM1=="HA BULLISH 1"||g_haBoth=="BOTH BULL"))haAgree=true;if(ms=="PUT"&&(g_haM1=="HA BEARISH 1"||g_haBoth=="BOTH BEAR"))haAgree=true;return haAgree;} void SendTelegramAlert(string message){if(!ENABLE_TELEGRAM)return;if(StringLen(TELEGRAM_TOKEN)<10||StringLen(TELEGRAM_CHAT_ID)<5)return;string url="https://api.telegram.org/bot"+TELEGRAM_TOKEN+"/sendMessage?chat_id="+TELEGRAM_CHAT_ID+"&text="+message;char post[];char result_data[];string result_headers;int timeout=5000;int res=WebRequest("GET",url,"",timeout,post,result_data,result_headers);if(res==-1)Print("Telegram failed: ",GetLastError());} //+------------------------------------------------------------------+ // MAIN DRAW //+------------------------------------------------------------------+ void Draw(){ HideSPM();DelDashboard(); int W=DASH_W,G=8,CW=(W-2*G)/3,CH=110,cx=POS_X+G,yy=POS_Y; int cp=0;double brain=BrainSc(cp); // Use new Neural AI function double nb=CalcNeuralAI(); double mw=((High[1]-MathMax(Open[1],Close[1]))+(MathMin(Open[1],Close[1])-Low[1]))/(High[1]-Low[1]+0.00001); bool bf=IsBrokerForce(); g_marketMode=DetectMarketMode(brain,g_rsc,cp,nb); if(StringLen(g_prevMode)>0&&g_prevMode!=g_marketMode){g_signalTime=0;g_finalSignal="WAIT";} g_prevMode=g_marketMode; CalcOTCCrowd();UpdateAccuracy();UpdateWeights(); double mai=CalcAdvancedMicroAI();int mts=CalcAdvancedMicroTrap(); CalcPrediction(brain,nb,cp,mai,mts,g_rsc,bf,mw); UpdateRiskControl();CheckMTFConfirmation(); double tfaScore=CalcAdvancedTFA(g_tfa_detail); color ha1C=(g_haM1=="HA BULLISH 1")?NEON_GREEN:(g_haM1=="HA BEARISH 1")?NEON_RED:NEON_YELLOW; color ha5C=(g_haM5=="HA BULLISH 5")?NEON_GREEN:(g_haM5=="HA BEARISH 5")?NEON_RED:NEON_YELLOW; color biasClr;string biasStr=CalcAdvancedMarketBias(biasClr,brain,g_rsc); color stratC=(g_strategyType=="TRAP")?NEON_PURPLE:(g_strategyType=="TREND")?NEON_GREEN:CGR; string stratSig=""; if(g_strategyType=="TRAP"||g_strategyType=="TREND"){if(StringFind(g_strategyReason,"CALL")>=0)stratSig="CALL";else if(StringFind(g_strategyReason,"PUT")>=0)stratSig="PUT";} string stratLabel=(g_strategyType=="TRAP")?"TRAP "+stratSig:(g_strategyType=="TREND")?"TREND "+stratSig:"NO STRATEGY"; // Signal cube string finalSig=g_finalSignal;color sigC=NEON_YELLOW; if(ENABLE_BB_PULLBACK&&g_bbSignal!="--"&&(finalSig=="WAIT"||finalSig=="")){finalSig="BB "+g_bbSignal;sigC=g_bbColor;} else{if(finalSig=="CALL")sigC=NEON_GREEN;else if(finalSig=="PUT")sigC=NEON_RED;else if(finalSig=="WEAK CALL")sigC=NEON_CYAN;else if(finalSig=="WEAK PUT")sigC=NEON_ORANGE;else sigC=NEON_YELLOW;} // ROW 1 Cube("c1",cx,yy,CW,CH,NEON_CYAN,BG_DARK2,"PAIR",NEON_CYAN,Symbol(),NEON_BLUE,13); Bx("c2",cx+CW+G,yy,CW,CH,BG_DARK2,sigC);Tx("c2_l",cx+CW+G+10,yy+4,"SIGNAL",NEON_CYAN,10,true);Tx("c2_v",cx+CW+G+10,yy+26,finalSig,sigC,13,true); if(ENABLE_BB_PULLBACK){string ha30Txt=Is30SecHABull()?"HA30:BULL":Is30SecHABear()?"HA30:BEAR":"HA30:DOJI";color ha30C=Is30SecHABull()?NEON_GREEN:Is30SecHABear()?NEON_RED:NEON_YELLOW;Tx("c2_ha30",cx+CW+G+10,yy+60,ha30Txt,ha30C,9,false);if(g_bbSignal!="--")Tx("c2_bb",cx+CW+G+10,yy+78,g_bbDetail,g_bbColor,9,false);} double gP,rP;string rsn;color pClr; CalcAdvancedPrediction(gP,rP,rsn,pClr); g_frozen_gProb=gP;g_frozen_rProb=rP;g_frozen_pAction=rsn;g_frozen_pColor=pClr;g_last_freeze_bar=Time[0]; Bx("c_pred",cx+2*(CW+G),yy,CW,CH,BG_DARK2,pClr);Tx("c_pred_l",cx+2*(CW+G)+10,yy+4,"NEXT CANDLE",NEON_CYAN,10,true); int bW=CW-20,gBW=(int)(gP/100.0*bW),rBW=(int)(rP/100.0*bW);if(gBW<3)gBW=3;if(rBW<3)rBW=3; Bx("c_pred_gbg",cx+2*(CW+G)+10,yy+22,bW,7,BG_DARK4,BG_DARK4);Bx("c_pred_gfg",cx+2*(CW+G)+10,yy+22,gBW,7,NEON_GREEN,NEON_GREEN); Tx("c_pred_gp",cx+2*(CW+G)+10,yy+31,"G:"+DoubleToString(gP,0)+"%",NEON_GREEN,11,true); Bx("c_pred_rbg",cx+2*(CW+G)+10,yy+48,bW,7,BG_DARK4,BG_DARK4);Bx("c_pred_rfg",cx+2*(CW+G)+10,yy+48,rBW,7,NEON_RED,NEON_RED); Tx("c_pred_rp",cx+2*(CW+G)+10,yy+57,"R:"+DoubleToString(rP,0)+"%",NEON_RED,11,true); Tx("c_pred_a",cx+2*(CW+G)+10,yy+76,rsn,pClr,11,true);NeonBar("c_pred_b",cx+2*(CW+G)+10,yy+92,bW,7,MathMax(gP,rP),pClr); yy+=CH+G; // ROW 2 — FIX: Neural AI now uses real CalcNeuralAI() Bx("c7",cx,yy,CW,CH,BG_DARK2,g_neuralColor); Tx("c7_l",cx+10,yy+4,"NEURAL AI",NEON_CYAN,10,true); Tx("c7_v",cx+10,yy+26,DoubleToString(nb,1)+"%",g_neuralColor,18,true); // Show indicator breakdown string nd=g_neuralDetail;if(StringLen(nd)>26)nd=StringSubstr(nd,0,25); Tx("c7_det",cx+10,yy+68,nd,CGR,8,false); NeonBar("c7b",cx+12,yy+92,CW-24,7,nb,g_neuralColor); Bx("c8",cx+CW+G,yy,CW,CH,BG_DARK2,NEON_CYAN);Tx("c8_l",cx+CW+G+10,yy+4,"CROWD",NEON_CYAN,10,true); Tx("c8_c",cx+CW+G+10,yy+24,"CALL "+IntegerToString(g_otcCallPct)+"%",NEON_RED,14,true); Tx("c8_p",cx+CW+G+10,yy+54,"PUT "+IntegerToString(g_otcPutPct)+"%",NEON_GREEN,14,true); Tx("c8_b",cx+CW+G+10,yy+86,"OTC Crowd",NEON_GOLD,9,false); color sClr=CGR;string sName=GetCurrentSession(sClr);bool isAct=IsSessionActive(); Bx("c_ses",cx+2*(CW+G),yy,CW,CH,BG_DARK2,sClr);Tx("c_ses_l",cx+2*(CW+G)+10,yy+4,"SESSION",NEON_CYAN,10,true); Tx("c_ses_v",cx+2*(CW+G)+10,yy+22,sName,sClr,14,true); int gH=TimeHour(TimeGMT()),gMn=TimeMinute(TimeGMT()); Tx("c_ses_t",cx+2*(CW+G)+10,yy+54,"GMT "+(gH<10?"0":"")+IntegerToString(gH)+":"+(gMn<10?"0":"")+IntegerToString(gMn),NEON_WHITE,11,false); Tx("c_ses_s",cx+2*(CW+G)+10,yy+76,isAct?"ACTIVE":"LOW VOL",isAct?NEON_GREEN:NEON_ORANGE,11,true); yy+=CH+G; // ROW 3 DrawOtherPairsCube(cx,yy,CW,CH);DrawOTCQuickCube(cx+CW+G,yy,CW,CH); // Brain cube — FIX: improved BrainSc Bx("c_brain_r3",cx+2*(CW+G),yy,CW,CH,BG_DARK3,NEON_CYAN); Tx("c_brain_r3_l",cx+2*(CW+G)+10,yy+5,"BRAIN",NEON_CYAN,10,true); color brainClr3=(brain>0)?NEON_GREEN:NEON_RED; Tx("c_brain_r3_v",cx+2*(CW+G)+10,yy+28,(brain>=0?"+":"")+DoubleToString(brain,1),brainClr3,22,true); Tx("c_brain_r3_s",cx+2*(CW+G)+10,yy+72,stratLabel,stratC,10,false); NeonBar("c_brain_r3_b",cx+2*(CW+G)+12,yy+92,CW-24,7,MathMin(100,MathAbs(brain)*8+50),(brain>0)?NEON_GREEN:NEON_RED); yy+=CH+G; // ROW 4 int CH4=120; color maC;if(mai>72)maC=NEON_ORANGE;else if(mai>55)maC=NEON_YELLOW;else if(mai>45)maC=NEON_CYAN;else maC=NEON_GREEN; Cube("c_mai",cx,yy,CW,CH4,maC,BG_DARK2,"MICRO AI",NEON_CYAN,DoubleToString(mai,0)+"%",maC,16);NeonBar("c_mai_b",cx+12,yy+104,CW-24,7,mai,maC); color mtsC=(mts>=90)?NEON_PURPLE:(mts>=75)?NEON_RED:(mts>=50)?NEON_ORANGE:NEON_GREEN; Cube("c_mts",cx+CW+G,yy,CW,CH4,mtsC,BG_DARK2,"MICRO TRAP",NEON_CYAN,"SCORE "+IntegerToString(mts),mtsC,14);NeonBar("c_mts_b",cx+CW+G+12,yy+104,CW-24,7,MathMin(100,mts),mtsC); int tfaInt=(int)tfaScore;color tfaColor;string tfaLabel; if(tfaInt>=5){tfaLabel="STRONG";tfaColor=NEON_GREEN;}else if(tfaInt>=4){tfaLabel="GOOD";tfaColor=NEON_LIME;}else if(tfaInt>=3){tfaLabel="MEDIUM";tfaColor=NEON_YELLOW;}else if(tfaInt>=2){tfaLabel="WEAK";tfaColor=NEON_ORANGE;}else{tfaLabel="POOR";tfaColor=C'100,100,120';} color tfaBC=tfaColor;string dirTxt=""; if(g_haM1=="HA BEARISH 1"){tfaBC=NEON_RED;dirTxt="[DOWN]";}else if(g_haM1=="HA BULLISH 1"){tfaBC=NEON_GREEN;dirTxt="[UP]";}else dirTxt="[MIX]"; Bx("c_tfa",cx+2*(CW+G),yy,CW,CH4,BG_DARK3,tfaBC);Tx("c_tfa_l",cx+2*(CW+G)+10,yy+4,"TFA SCORE",NEON_CYAN,10,true); Tx("c_tfa_v",cx+2*(CW+G)+10,yy+22,IntegerToString(tfaInt)+"/6 "+tfaLabel,tfaBC,12,true);Tx("c_tfa_dir",cx+2*(CW+G)+10,yy+44,dirTxt,tfaBC,11,true); string tdet=g_tfa_detail;int pp=StringFind(tdet," | ");string td1=(pp>=0)?StringSubstr(tdet,0,pp):tdet;string td2=(pp>=0)?StringSubstr(tdet,pp+3):""; if(StringLen(td1)>24)td1=StringSubstr(td1,0,23);if(StringLen(td2)>24)td2=StringSubstr(td2,0,23); Tx("c_tfa_d1",cx+2*(CW+G)+10,yy+62,td1,CGR,8,false);if(StringLen(td2)>0)Tx("c_tfa_d2",cx+2*(CW+G)+10,yy+76,td2,CGR,8,false); int tfaFW=(int)((double)tfaInt/6.0*(CW-20));if(tfaFW<2)tfaFW=2;if(tfaFW>CW-20)tfaFW=CW-20; Bx("c_tfa_bb",cx+2*(CW+G)+10,yy+104,CW-20,7,BG_DARK4,BG_DARK4);Bx("c_tfa_bf",cx+2*(CW+G)+10,yy+104,tfaFW,7,tfaBC,tfaBC); yy+=CH4+G; // ROW 5 — NCP (font14 fix) + MARKET BIAS + S/R int CH5=120; if(ENABLE_MTG){ bool isTrap=(g_mtgState=="PUT TRAP"||g_mtgState=="CALL TRAP"); color mtgC=g_mtgClr;if(mtgC==CGR||mtgC==clrGray)mtgC=C'55,65,85'; color borderC=isTrap?NEON_PURPLE:mtgC; Bx("c_mtg",cx,yy,CW,CH5,BG_DARK2,borderC); string runStr="";if(g_mtgBullCount>=2)runStr=" "+IntegerToString(g_mtgBullCount)+"G-RUN";else if(g_mtgBearCount>=2)runStr=" "+IntegerToString(g_mtgBearCount)+"R-RUN"; Tx("c_mtg_l",cx+10,yy+4,"NCP PRO"+runStr,NEON_PURPLE,9,true); int stateFS=isTrap?11:13;Tx("c_mtg_s",cx+10,yy+18,g_mtgState,mtgC,stateFS,true); int cW2=(int)(g_mtgHype/100.0*(CW-22));if(cW2<2)cW2=2;if(cW2>CW-22)cW2=CW-22; color cBarC=(g_mtgHype>=g_mtgBetrayal)?NEON_GREEN:C'35,70,35'; Bx("c_mtg_cbb",cx+10,yy+38,CW-22,7,BG_DARK4,BG_DARK4);Bx("c_mtg_cbf",cx+10,yy+38,cW2,7,cBarC,cBarC); Tx("c_mtg_ct",cx+10,yy+47,"C: "+DoubleToString(g_mtgHype,1)+"%",NEON_GREEN,14,true); int pW2=(int)(g_mtgBetrayal/100.0*(CW-22));if(pW2<2)pW2=2;if(pW2>CW-22)pW2=CW-22; color pBarC=(g_mtgBetrayal>g_mtgHype)?NEON_RED:C'70,25,25'; Bx("c_mtg_pbb",cx+10,yy+66,CW-22,7,BG_DARK4,BG_DARK4);Bx("c_mtg_pbf",cx+10,yy+66,pW2,7,pBarC,pBarC); Tx("c_mtg_pt",cx+10,yy+75,"P: "+DoubleToString(g_mtgBetrayal,1)+"%",NEON_RED,14,true); string actD=g_mtgAction;if(StringLen(actD)>24)actD=StringSubstr(actD,0,23); color actC=isTrap?NEON_PURPLE:(g_mtgState=="CALL")?NEON_GREEN:(g_mtgState=="PUT")?NEON_RED:NEON_YELLOW; Tx("c_mtg_a",cx+10,yy+94,actD,actC,9,true); string rsnD=(StringLen(g_mtgReason)>0)?g_mtgReason:g_mtgPattern;if(StringLen(rsnD)>24)rsnD=StringSubstr(rsnD,0,23); Tx("c_mtg_r",cx+10,yy+108,rsnD,CGR,8,false); } else { double frac=CalcAdvancedFractal();color frC=(frac>=75)?NEON_RED:(frac>=50)?NEON_ORANGE:(frac>=25)?NEON_YELLOW:NEON_GREEN;string frT=(frac>=75)?"TRAP ZONE!":(frac>=50)?"WARNING":(frac>=25)?"CAUTION":"CLEAR"; Cube("c_frc",cx,yy,CW,CH5,frC,BG_DARK2,"FRACTAL",NEON_CYAN,frT,frC,13);NeonBar("c_frc_b",cx+12,yy+104,CW-24,7,frac,frC); } double CalcAdvancedFractal(); Bx("c_bias",cx+CW+G,yy,CW,CH5,BG_DARK2,biasClr);Tx("c_bias_l",cx+CW+G+10,yy+4,"MARKET BIAS",NEON_CYAN,10,true); string bStr=biasStr;if(StringLen(bStr)>13)bStr=StringSubstr(bStr,0,12); Tx("c_bias_v",cx+CW+G+10,yy+22,bStr,biasClr,13,true); Tx("c_bias_m",cx+CW+G+10,yy+52,"MODE: "+g_marketMode,(g_marketMode=="TREND")?NEON_GREEN:(g_marketMode=="REVERSAL")?NEON_RED:NEON_YELLOW,10,false); color accC=(g_accuracy>=70)?NEON_GREEN:(g_accuracy>=60)?NEON_YELLOW:NEON_RED; Tx("c_bias_a",cx+CW+G+10,yy+72,"ACC: "+DoubleToString(g_accuracy,1)+"%",accC,10,false); NeonBar("c_bias_b",cx+CW+G+10,yy+88,CW-20,7,g_accuracy,accC); // S/R — FIX: 50 bar improved levels int dg_sr=(int)MarketInfo(Symbol(),MODE_DIGITS);if(dg_sr<=0)dg_sr=5; Bx("c18",cx+2*(CW+G),yy,CW,CH5,BG_DARK2,NEON_CYAN);Tx("c18_l",cx+2*(CW+G)+10,yy+4,"S/R LEVELS",NEON_CYAN,10,true); Tx("c18_r",cx+2*(CW+G)+10,yy+24,"R: "+(g_nearest_res>0?DoubleToString(g_nearest_res,dg_sr):"--"),NEON_RED,13,true); Tx("c18_s",cx+2*(CW+G)+10,yy+54,"S: "+(g_nearest_sup>0?DoubleToString(g_nearest_sup,dg_sr):"--"),NEON_GREEN,13,true); Tx("c18_b",cx+2*(CW+G)+10,yy+86,g_brk_str,g_brk_color,11,true); yy+=CH5+G; // ROW 6 — WICKS, HA, REVERSAL (FIX: improved reversal) int CH6=120; color wickC=(mw>0.70)?NEON_RED:(mw>0.50)?NEON_ORANGE:NEON_GREEN; Bx("c15",cx,yy,CW,CH6,BG_DARK2,wickC);Tx("c15_l",cx+10,yy+4,"WICKS",NEON_CYAN,10,true); Tx("c15_v",cx+10,yy+26,DoubleToString(mw,2),wickC,18,true); Tx("c15_b",cx+10,yy+62,(mw>0.70)?"KILL SHOT":(mw>0.50)?"HIGH":"LOW",wickC,11,false); NeonBar("c15_bar",cx+10,yy+80,CW-20,7,mw*100,wickC); Bx("c_ha",cx+CW+G,yy,CW,CH6,BG_DARK2,ha1C);Tx("c_ha_l",cx+CW+G+10,yy+4,"HA CANDLES",NEON_CYAN,10,true); string haM1txt=g_haM1,haM5txt=g_haM5;if(StringLen(haM1txt)>16)haM1txt=StringSubstr(haM1txt,3);if(StringLen(haM5txt)>16)haM5txt=StringSubstr(haM5txt,3); Tx("c_ha_m1",cx+CW+G+10,yy+24,"M1: "+haM1txt,ha1C,11,true);Tx("c_ha_m5",cx+CW+G+10,yy+50,"M5: "+haM5txt,ha5C,11,true); string haComb="";color haCombC=NEON_YELLOW; if(g_haM1=="HA BULLISH 1"&&g_haM5=="HA BULLISH 5"){haComb="BOTH BULL";haCombC=NEON_GREEN;}else if(g_haM1=="HA BEARISH 1"&&g_haM5=="HA BEARISH 5"){haComb="BOTH BEAR";haCombC=NEON_RED;}else if(g_haBoth=="MIXED")haComb="MIXED";else haComb=g_haBoth; Tx("c_ha_c",cx+CW+G+10,yy+76,haComb,haCombC,11,true); // REVERSAL — FIX: new proper function string revStr=DetectReversal(); Bx("c_reason",cx+2*(CW+G),yy,CW,CH6,BG_DARK2,g_reversalColor); Tx("c_reason_l",cx+2*(CW+G)+10,yy+4,"REVERSAL",NEON_CYAN,10,true); Tx("c_reason_v",cx+2*(CW+G)+10,yy+28,(StringLen(g_reversalSignal)>0&&g_reversalSignal!="--")?g_reversalSignal:"No pattern",g_reversalColor,12,true); if(StringLen(g_reversalDetail)>0){string rd2=g_reversalDetail;if(StringLen(rd2)>22)rd2=StringSubstr(rd2,0,21);Tx("c_reason_d",cx+2*(CW+G)+10,yy+54,rd2,g_reversalColor,9,false);} yy+=CH6+G; // BB PULLBACK ROW if(ENABLE_BB_PULLBACK){ int bbRowH=52;color bbRowBorder=(g_bbSignal=="CALL")?NEON_GREEN:(g_bbSignal=="PUT")?NEON_RED:BB_GREY; Bx("c_bb_row",cx,yy,W-2*G,bbRowH,BG_DARK3,bbRowBorder); string ha30Str=Is30SecHABull()?"BULL":Is30SecHABear()?"BEAR":"DOJI";color ha30C2=Is30SecHABull()?NEON_GREEN:Is30SecHABear()?NEON_RED:NEON_YELLOW; double adxD=iADX(NULL,PERIOD_M1,14,PRICE_CLOSE,MODE_MAIN,1);double rsiD=iRSI(NULL,PERIOD_M1,14,PRICE_CLOSE,1); double bbU2=iBands(NULL,PERIOD_M1,BB_PERIOD,BB_DEVIATION,0,PRICE_CLOSE,MODE_UPPER,0);double bbL2=iBands(NULL,PERIOD_M1,BB_PERIOD,BB_DEVIATION,0,PRICE_CLOSE,MODE_LOWER,0); int dg3=(int)MarketInfo(Symbol(),MODE_DIGITS);if(dg3<=0)dg3=5; Tx("c_bb_row_l",cx+10,yy+4,"BB("+IntegerToString(BB_PERIOD)+") PULLBACK",BB_GREY,9,true); Tx("c_bb_ha2",cx+190,yy+4,"HA30:"+ha30Str,ha30C2,9,true);Tx("c_bb_adx",cx+310,yy+4,"ADX:"+DoubleToString(adxD,0),adxD>=20?NEON_LIME:CGR,9,false); Tx("c_bb_rsi",cx+390,yy+4,"RSI:"+DoubleToString(rsiD,0),(rsiD>=70||rsiD<=30)?NEON_RED:CGR,9,false); if(bbU2>0&&bbL2>0){Tx("c_bb_u2",cx+470,yy+4,"U:"+DoubleToString(bbU2,dg3),NEON_ORANGE,8,false);Tx("c_bb_d2",cx+570,yy+4,"L:"+DoubleToString(bbL2,dg3),NEON_CYAN,8,false);} if(g_bbSignal!="--"){string sigTxt="BB "+g_bbSignal+" | "+g_bbDetail;if(StringLen(sigTxt)>60)sigTxt=StringSubstr(sigTxt,0,58)+"..";Tx("c_bb_sig2",cx+10,yy+22,sigTxt,g_bbColor,10,true);} else Tx("c_bb_sig2",cx+10,yy+22,"Waiting for BB touch + 2+ confirmations...",CGR,9,false); yy+=bbRowH+G; } // BOTTOM ROW int bottomW=(W-2*G-2*G)/3,bottomH=106;yy+=4;int x1=cx; Bx("c_hrn",x1,yy,bottomW,bottomH,BG_DARK2,NEON_PINK);Tx("c_hrn_l",x1+8,yy+4,"HRN LEVEL",NEON_PINK,10,true);Tx("c_hrn_v",x1+8,yy+22,g_hrn_str,NEON_PINK,13,true); Tx("c_hrn_t",x1+8,yy+46,g_hrn_is_sup?"SUPPORT":"RESISTANCE",NEON_PINK,10,false); color scoreC=(g_hrn_score>=30)?NEON_GREEN:(g_hrn_score>=15)?NEON_YELLOW:NEON_ORANGE; Tx("c_hrn_sc",x1+8,yy+62,"Score: "+DoubleToString(g_hrn_score,0),scoreC,10,false); Tx("c_hrn_b",x1+8,yy+78,"Brk "+IntegerToString(g_hrn_brk_bars)+"/"+IntegerToString(HRN_CONFIRM_BARS),NEON_PINK,10,false); Tx("c_hrn_s",x1+8,yy+94,g_isSideways?"SIDEWAYS":"TRENDING",g_isSideways?NEON_YELLOW:NEON_GREEN,9,false); int x2=x1+bottomW+G; Bx("c5",x2,yy,bottomW,bottomH,BG_DARK3,NEON_CYAN);Tx("c5_l",x2+10,yy+12,"SPM",NEON_CYAN,10,true); Tx("c5_v",x2+10,yy+44,(g_rsc>=0?"+":"")+DoubleToString(g_rsc,1),(g_rsc>0)?NEON_GREEN:NEON_RED,22,true); int x3=x2+bottomW+G; Bx("c_strat_b",x3,yy,bottomW,bottomH,BG_DARK3,stratC);Tx("c_strat_b_l",x3+10,yy+6,"STRATEGY",NEON_CYAN,10,true); Tx("c_strat_b_v",x3+10,yy+30,stratLabel,stratC,11,true);Tx("c_strat_b_r",x3+10,yy+60,g_strategyReason,CGR,8,false); yy+=bottomH+5; // FILTER BAR int fsW=W-2*G;color fsC=(g_filterStatus=="ALL CLEAR")?NEON_GREEN:(StringFind(g_filterStatus,"ACTIVE")>=0)?NEON_LIME:(StringFind(g_filterStatus,"LOCK")>=0)?NEON_RED:NEON_ORANGE; Bx("c_filter",cx,yy,fsW,22,BG_DARK3,fsC);Tx("c_filter_v",cx+10,yy+4,"FILTER: "+g_filterStatus,fsC,11,true); HideSPM();ChartRedraw(); } double CalcAdvancedFractal(){if(Bars<15)return 0;double score=0;for(int i=2;i<=8&&i+2High[i-1]&&High[i]>High[i-2]&&High[i]>High[i+1]&&High[i]>High[i+2]){double d=(High[i]-Close[0])/Point;if(d<50&&d>-10)score+=35;}if(Low[i]-10)score+=25;}}int dj=0;for(int i=1;i<=6;i++){double b=MathAbs(Close[i]-Open[i]),rg=High[i]-Low[i];if(rg>0&&b=3)score+=25;double r1=High[1]-Low[1];if(r1>0){double uw1=(High[1]-MathMax(Open[1],Close[1]))/r1,lw1=(MathMin(Open[1],Close[1])-Low[1])/r1;if(uw1>0.70||lw1>0.70)score+=20;}return MathMin(100,score);} void UpdateRiskControl(){static datetime llt=0;if(ENABLE_RISK_LOCK){if(g_lossStreak>=MAX_LOSS_STREAK){g_tradingStopped=true;llt=TimeCurrent();g_filterStatus="RISK LOCK "+IntegerToString(g_lossStreak)+"L";}if(g_tradingStopped&&TimeCurrent()-llt>3600){g_tradingStopped=false;g_lossStreak=0;g_filterStatus="RISK UNLOCK";}}} void FinalSignalEngine(double brain,int cp,int mts){ g_filterStatus="ALL CLEAR"; if(ENABLE_RISK_CONTROL&&g_tradingStopped){g_finalSignal="WAIT";g_finalColor=NEON_ORANGE;g_filterStatus="RISK LOCKED";if(TimeCurrent()-g_signalTime>HOLD_SEC)g_signalTime=TimeCurrent();return;} if(ENABLE_SESSION_FILTER&&!IsSessionActive()){g_finalSignal="WAIT";g_finalColor=NEON_ORANGE;g_filterStatus="SESSION OFF";if(TimeCurrent()-g_signalTime>HOLD_SEC)g_signalTime=TimeCurrent();return;} if(MTF_CONFIRM&&!g_mtfConfirmed){g_finalSignal="WAIT";g_finalColor=NEON_ORANGE;g_filterStatus="MTF NO CONF";if(TimeCurrent()-g_signalTime>HOLD_SEC)g_signalTime=TimeCurrent();return;} if(ENABLE_SPIKE_FILTER&&IsBigCandle(1)){g_finalSignal="WAIT";g_finalColor=NEON_ORANGE;g_filterStatus="SPIKE BLOCK";if(TimeCurrent()-g_signalTime>HOLD_SEC)g_signalTime=TimeCurrent();return;} if(ENABLE_LAST_SEC_BLOCK){int age=(int)(TimeCurrent()-Time[0]);int ps=Period()*60;int rem=ps-age;if(rem<0)rem=0;if(remHOLD_SEC)g_signalTime=TimeCurrent();return;}} double conf=MathMax(g_calc_gProb,g_calc_rProb); if(confHOLD_SEC)g_signalTime=TimeCurrent();return;} bool reverseSignal=(g_accuracy<45.0&&g_acc_total>20);if(reverseSignal)g_filterStatus="REVERSE MODE"; string ms=DetectMyStrategy(); if(ms!="WAIT"){ if(CONSENSUS_FILTER&&!ConsensusOK()){g_finalSignal="WAIT";g_finalColor=NEON_ORANGE;g_filterStatus="NO CONSENSUS";if(TimeCurrent()-g_signalTime>HOLD_SEC)g_signalTime=TimeCurrent();return;} if(ENABLE_ENTRY_ZONE&&!DirectionOK()){g_finalSignal="WAIT";g_finalColor=NEON_ORANGE;g_filterStatus="BAD ENTRY ZONE";if(TimeCurrent()-g_signalTime>HOLD_SEC)g_signalTime=TimeCurrent();return;} if(!EntryPrecisionOK()){g_finalSignal="WAIT";g_finalColor=NEON_ORANGE;g_filterStatus="PRECISION FAIL";if(TimeCurrent()-g_signalTime>HOLD_SEC)g_signalTime=TimeCurrent();return;} if(reverseSignal){if(ms=="CALL")ms="PUT";else if(ms=="PUT")ms="CALL";} g_finalSignal=ms;g_finalColor=(ms=="CALL")?NEON_GREEN:NEON_RED;g_filterStatus=(g_strategyType=="TRAP")?"TRAP ACTIVE":"TREND ACTIVE"; if(TimeCurrent()-g_signalTime>HOLD_SEC||g_finalSignal=="WAIT"){g_finalSignal=ms;g_signalTime=TimeCurrent();} SendSignalNotification(ms,conf);return; } double th=FAST_MODE?70:68;string rawSignal="WAIT"; if(g_calc_gProb>th)rawSignal="CALL";else if(g_calc_rProb>th)rawSignal="PUT";else if(g_calc_gProb>60)rawSignal="WEAK CALL";else if(g_calc_rProb>60)rawSignal="WEAK PUT"; if(reverseSignal){if(rawSignal=="CALL")rawSignal="PUT";else if(rawSignal=="PUT")rawSignal="CALL";else if(rawSignal=="WEAK CALL")rawSignal="WEAK PUT";else if(rawSignal=="WEAK PUT")rawSignal="WEAK CALL";} g_finalSignal=rawSignal; if((g_finalSignal=="CALL"||g_finalSignal=="PUT")&&ENABLE_ENTRY_ZONE&&!DirectionOK()){g_finalSignal="WAIT";g_finalColor=NEON_ORANGE;g_filterStatus="BAD ENTRY ZONE";if(TimeCurrent()-g_signalTime>HOLD_SEC)g_signalTime=TimeCurrent();return;} if((g_finalSignal=="CALL"||g_finalSignal=="PUT")&&!EntryPrecisionOK()){g_finalSignal="WAIT";g_finalColor=NEON_ORANGE;g_filterStatus="PRECISION FAIL";if(TimeCurrent()-g_signalTime>HOLD_SEC)g_signalTime=TimeCurrent();return;} if(TimeCurrent()-g_signalTime>HOLD_SEC||g_finalSignal=="WAIT")g_signalTime=TimeCurrent(); if(g_finalSignal=="CALL"){g_finalColor=NEON_GREEN;g_filterStatus="GREEN SIGNAL";SendSignalNotification("CALL",conf);} else if(g_finalSignal=="PUT"){g_finalColor=NEON_RED;g_filterStatus="RED SIGNAL";SendSignalNotification("PUT",conf);} else if(g_finalSignal=="WEAK CALL"){g_finalColor=NEON_CYAN;g_filterStatus="WEAK GREEN";} else if(g_finalSignal=="WEAK PUT"){g_finalColor=NEON_ORANGE;g_filterStatus="WEAK RED";} else g_finalColor=NEON_YELLOW; } void SendSignalNotification(string sig,double conf){if(!ENABLE_NOTIFY)return;string msg=Symbol()+" | "+sig+" | "+DoubleToString(conf,0)+"% | "+g_filterStatus;if(msg==g_lastNotified)return;g_lastNotified=msg;if(ENABLE_TELEGRAM)SendTelegramAlert("AIBRAIN\n"+Symbol()+"\n"+sig+"\nConf: "+DoubleToString(conf,0)+"%\n"+g_filterStatus);Print(msg);} void BroadcastSignal(){double conf=MathMax(g_frozen_gProb,g_frozen_rProb);if(conf<55)return;string fn="OTC_Signals_Master.txt",pair=Symbol();string sig=(g_frozen_gProb>g_frozen_rProb)?"CALL":"PUT";int exp=(int)(TimeCurrent()+65);string line=pair+"|"+sig+"|"+DoubleToString(conf,0)+"|"+IntegerToString((int)TimeCurrent())+"|"+IntegerToString(exp);int h=FileOpen(fn,FILE_READ|FILE_WRITE|FILE_TXT|FILE_SHARE_READ|FILE_SHARE_WRITE);if(h==INVALID_HANDLE){h=FileOpen(fn,FILE_WRITE|FILE_TXT|FILE_SHARE_READ|FILE_SHARE_WRITE);if(h==INVALID_HANDLE)return;FileWriteString(h,line+"\n");FileClose(h);return;}string content="";while(!FileIsEnding(h)){string ex=FileReadString(h);if(StringLen(ex)>10&&StringFind(ex,pair+"|")!=0)content+=ex+"\n";}content=line+"\n"+content;string lns[];int cnt=0,pos=0;int f=StringFind(content,"\n",pos);while(f!=-1&&cnt<100){ArrayResize(lns,cnt+1);lns[cnt]=StringSubstr(content,pos,f-pos);cnt++;pos=f+1;f=StringFind(content,"\n",pos);}if(pos50){content="";for(int i=0;i<50;i++)if(StringLen(lns[i])>10)content+=lns[i]+"\n";}FileSeek(h,0,SEEK_SET);FileWriteString(h,content);FileFlush(h);FileClose(h);} int CalcPairQuality(string pair,string &outSig,string &outDetail){double o1=iOpen(pair,PERIOD_M1,1),h1=iHigh(pair,PERIOD_M1,1),l1=iLow(pair,PERIOD_M1,1),c1=iClose(pair,PERIOD_M1,1);double o2=iOpen(pair,PERIOD_M1,2),h2=iHigh(pair,PERIOD_M1,2),l2=iLow(pair,PERIOD_M1,2),c2=iClose(pair,PERIOD_M1,2);double o3=iOpen(pair,PERIOD_M1,3),c3=iClose(pair,PERIOD_M1,3);if(o1==0||c1==0||o2==0||c2==0||o3==0||c3==0){outSig="WAIT";return 0;}double haC1=(o1+h1+l1+c1)/4.0,haC2=(o2+h2+l2+c2)/4.0,haO2=(o3+c3)/2.0,haO1=(haO2+haC2)/2.0;bool haM1Bull=(haC1>haO1),haM1Bear=(haC10)?haBody/haRange:0;double m5_o1=iOpen(pair,PERIOD_M5,1),m5_h1=iHigh(pair,PERIOD_M5,1),m5_l1=iLow(pair,PERIOD_M5,1),m5_c1=iClose(pair,PERIOD_M5,1);double m5_o2=iOpen(pair,PERIOD_M5,2),m5_h2=iHigh(pair,PERIOD_M5,2),m5_l2=iLow(pair,PERIOD_M5,2),m5_c2=iClose(pair,PERIOD_M5,2);double m5_o3=iOpen(pair,PERIOD_M5,3),m5_c3=iClose(pair,PERIOD_M5,3);bool haM5Bull=false,haM5Bear=false;if(m5_o1>0&&m5_c1>0&&m5_o2>0&&m5_c2>0&&m5_o3>0&&m5_c3>0){double m5haC1=(m5_o1+m5_h1+m5_l1+m5_c1)/4.0,m5haC2=(m5_o2+m5_h2+m5_l2+m5_c2)/4.0,m5haO2=(m5_o3+m5_c3)/2.0,m5haO1=(m5haO2+m5haC2)/2.0;haM5Bull=(m5haC1>m5haO1);haM5Bear=(m5haC10)?vol1/vol2:1.0,spread=(double)MarketInfo(pair,MODE_SPREAD);int bullStreak=0,bearStreak=0;for(int i=1;i<=4;i++){double ci=iClose(pair,PERIOD_M1,i),oi=iOpen(pair,PERIOD_M1,i);if(ci==0||oi==0)break;if(ci>oi){if(bearStreak>0)break;bullStreak++;}else if(ci0)break;bearStreak++;}else break;}bool bullDir=false,bearDir=false;if(haM1Bull&&haM5Bull)bullDir=true;else if(haM1Bear&&haM5Bear)bearDir=true;else if(haM1Bull&&rsi<45)bullDir=true;else if(haM1Bear&&rsi>55)bearDir=true;else{outSig="WAIT";return 0;}int score=0;string det="";if(bullDir&&haM1Bull){int s=(haStrength>0.6)?25:(haStrength>0.4)?18:12;score+=s;det+="HA1+";}if(bearDir&&haM1Bear){int s=(haStrength>0.6)?25:(haStrength>0.4)?18:12;score+=s;det+="HA1+";}if(bullDir&&haM5Bull){score+=15;det+="HA5+";}else if(bearDir&&haM5Bear){score+=15;det+="HA5+";}else det+="HA5-";if(bullDir){if(rsi<30){score+=20;det+="RSI_OS ";}else if(rsi<40){score+=14;det+="RSI_low ";}else if(rsi<50){score+=8;det+="RSI_mid ";}else{score+=2;det+="RSI_hi ";}}else{if(rsi>70){score+=20;det+="RSI_OB ";}else if(rsi>60){score+=14;det+="RSI_hi ";}else if(rsi>50){score+=8;det+="RSI_mid ";}else{score+=2;det+="RSI_lo ";}}if(volRatio>=2.0){score+=15;det+="VOL_HI ";}else if(volRatio>=1.5){score+=10;det+="VOL_MD ";}else if(volRatio>=1.1){score+=5;det+="VOL_LO ";}int streak=(bullDir)?bullStreak:bearStreak;if(streak>=3){score+=15;det+="STK"+IntegerToString(streak);}else if(streak>=2){score+=10;det+="STK"+IntegerToString(streak);}else if(streak>=1){score+=5;det+="STK1";}if(spread<=3)score+=10;else if(spread<=6)score+=6;else if(spread<=10)score+=3;outSig=bullDir?"CALL":"PUT";outDetail=det;return MathMin(100,score);} void ScanSignals(){g_pairCount=0;string fn="OTC_Signals_Master.txt",cur=Symbol();int h=FileOpen(fn,FILE_READ|FILE_TXT|FILE_SHARE_READ);if(h==INVALID_HANDLE)return;datetime now=TimeCurrent();string tmpNames[8];string tmpSigs[8];double tmpConfs[8];int tmpScores[8];string tmpDetails[8];int tmpCount=0;while(!FileIsEnding(h)&&tmpCount<8){string ln=FileReadString(h);if(StringLen(ln)<15)continue;int p1=StringFind(ln,"|"),p2=StringFind(ln,"|",p1+1),p3=StringFind(ln,"|",p2+1),p4=StringFind(ln,"|",p3+1);if(p1<0||p2<0||p3<0||p4<0)continue;string pair=StringSubstr(ln,0,p1);if(pair==cur)continue;string sig=StringSubstr(ln,p1+1,p2-p1-1);double conf=StringToDouble(StringSubstr(ln,p2+1,p3-p2-1));int expTime=(int)StringToInteger(StringSubstr(ln,p4+1));if(conf<60)continue;if(expTime<(int)(now-20))continue;string qSig="WAIT",qDetail="";int qScore=CalcPairQuality(pair,qSig,qDetail);if(qSig!=sig)continue;if(qScore<45)continue;tmpNames[tmpCount]=pair;tmpSigs[tmpCount]=sig;tmpConfs[tmpCount]=conf;tmpScores[tmpCount]=qScore;tmpDetails[tmpCount]=qDetail;tmpCount++;}FileClose(h);for(int i=0;ig_frozen_rProb)?"CALL":"PUT";int sameDir=0;double boostTotal=0;for(int i=0;i=60){sameDir++;boostTotal+=tmpScores[i];}}if(sameDir>=2&&!g_tradingStopped){double boost=MathMin(12.0,boostTotal/50.0);if(curPred=="CALL"){g_calc_gProb+=boost;g_calc_rProb-=boost;}else{g_calc_rProb+=boost;g_calc_gProb-=boost;}g_calc_gProb=MathMax(8.0,MathMin(92.0,g_calc_gProb));g_calc_rProb=100.0-g_calc_gProb;if(StringFind(g_filterStatus,"BOOST")<0)g_filterStatus="PAIR BOOST+"+DoubleToString(boost,0)+"%";}} void ReadSPM(){datetime cb=Time[0];if(cb==g_last_bar&&TimeCurrent()-g_spm_t<5)return;double v1=iCustom(NULL,PERIOD_M1,SPM_FILE,0,0),v2=iCustom(NULL,PERIOD_M1,SPM_FILE,1,0);if(v1!=EMPTY_VALUE&&v1!=0){double sm=0.7;g_rsc=g_rsc*(1.0-sm)+v1*sm;}if(v2!=EMPTY_VALUE&&v2!=0){double sm=0.7;g_tfa=g_tfa*(1.0-sm)+v2*sm;}g_last_bar=cb;g_spm_t=TimeCurrent();} //+------------------------------------------------------------------+ int OnInit(){ InitNW();NuclearDeleteAll(); resCount=0;supCount=0;lastSRBar=0;g_hrn_price=0;g_hrn_brk_bars=0;g_hrn_scan_bar=0;g_hrn_score=0;g_hrn_confirmed_break=false;g_nearest_res=0;g_nearest_sup=0;g_rj_cnt=0;g_pairCount=0; g_marketMode="RANGE";g_prevMode="";g_last_freeze_bar=0;g_lastNotified=""; g_accuracy=ValidateHistoricalAccuracy();g_acc_correct=0;g_acc_total=0;g_acc_lastBar=0; g_lastPredGreen=50.0;g_lastPredBar=0;g_lossStreak=0;g_tradingStopped=false; g_strategyType="NONE";g_frozen_gProb=50;g_frozen_rProb=50;g_calc_gProb=50;g_calc_rProb=50; g_commonCount=0;g_wickLineCount=0;g_tfa_detail="";g_htfLevelCount=0;g_mtfConfirmed=true;g_filterStatus="ALL CLEAR"; g_symbolKey="";g_brokerBias=0.0; g_bbSignal="--";g_bbColor=NEON_YELLOW;g_bbTouchPrice=0.0;g_bbSignalTime=0;g_bbSignalBars=0;g_bbDetail=""; g_mtgHype=50;g_mtgBetrayal=50;g_mtgRecovery=0;g_mtgState="INIT";g_mtgReason="";g_mtgAction="";g_mtgClr=CGR;g_mtg_lastBar=0;g_mtgPattern="";g_mtgBullCount=0;g_mtgBearCount=0;g_trapScore=0; g_smoothCallScore=50.0;g_smoothPutScore=50.0;g_callWeight=1.0;g_putWeight=1.0; g_totalTrades=0;g_callTrades=0;g_putTrades=0;g_callWins=0;g_putWins=0; g_ncpLastSignalTime=0;g_ncpLastSignalType="";g_ncpLastEntryPrice=0.0;g_ncpSignalProcessed=true; if(ENABLE_LEARNING)LoadBrainMemory(); g_ha30_open=0;g_ha30_close=0;g_ha30_high=0;g_ha30_low=0;g_ha30_bar=0;g_bbLineCount=0; g_neuralScore=50;g_neuralDetail="";g_neuralColor=NEON_YELLOW; g_reversalSignal="--";g_reversalColor=NEON_YELLOW;g_reversalDetail=""; LoadMLWeights();EventSetTimer(1); Print("=== AIBRAIN v46.3 ALL CUBES FIXED ==="); Print("FIX 1: Neural AI = 8 real indicators (RSI,STO,MACD,Wick,EMA,Vol,ADX,HA)"); Print("FIX 2: S/R Levels = 50 bar swing detection (3-bar confirmation)"); Print("FIX 3: Brain Score = 10 factors (momentum,wick,streak,volume,rsi,sr,crowd,doji,ema,session)"); Print("FIX 4: Reversal = 8 patterns (PinBar,Engulf,Hammer,ShootStar,MornStar,EveStar+RSI+SR)"); Print("FIX 5: NCP = raw score signal, smooth display, font14"); Print("FIX 6: Timer = quarter candle right"); Print("=========================================="); return INIT_SUCCEEDED; } void OnDeinit(const int r){EventKillTimer();Comment("");for(int i=ObjectsTotal()-1;i>=0;i--){string nm=ObjectName(i);if(StringFind(nm,PFX)==0)ObjectDelete(nm);}} void OnTimer(){ if(Bars<50)return; static datetime last5min=0; if(Time[0]/300!=last5min/300){DetectHiddenLevels();last5min=Time[0];} ReadSPM();CalcHA();UpdateHRN();UpdateSR(); DetectCommonPoints();DetectWickRejections(); DrawCommonPoints();DrawWickRejectLines();DrawHiddenLevels();DrawNearestSR(); if(ENABLE_BB_PULLBACK)DetectBBPullback(); if(ENABLE_MTG)CalculateMTG(); int cp=0;double brain=BrainSc(cp);double nb=CalcNeuralAI();double mw=((High[1]-MathMax(Open[1],Close[1]))+(MathMin(Open[1],Close[1])-Low[1]))/(High[1]-Low[1]+0.00001);bool bf=IsBrokerForce(); double mai=CalcAdvancedMicroAI();int mts=CalcAdvancedMicroTrap(); CalcPrediction(brain,nb,cp,mai,mts,g_rsc,bf,mw); ScanSignals();FinalSignalEngine(brain,cp,mts);BroadcastSignal(); UpdateTimer();Draw(); } 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[]){return(rates_total);} //+------------------------------------------------------------------+