//+------------------------------------------------------------------+ #property copyright "SYNK Trading" #property link "https://t.me/synkproppassing" #property strict #property icon "\\Files\\skynk.ico" #include #include #import "kernel32.dll" int CreateFileW(string Filename,int AccessMode,int ShareMode,int PassAsZero,int CreationMode,int FlagsAndAttributes,int AlsoPassAsZero); int GetFileSize(int FileHandle,int PassAsZero); int SetFilePointer(int FileHandle,int Distance,int &PassAsZero[],int FromPosition); int ReadFile(int FileHandle,uchar &BufferPtr[],int BufferLength,int &BytesRead[],int PassAsZero); int CloseHandle(int FileHandle); #import string Ordercomment=""; int Slippage=3; int Retries=10; bool AutoTrade=true; bool ecnBroker=false; enum OPBySignal { ON=0, OFF=1, }; //--- input parameters extern string Version__ = "----------------------------------------------------------------";//Prometheus extern string Version1__ = "------------------------Prometheus----------------------------";//By extern string Version2__ = "----------------------------------------------------------------";//SYNK Trading input OPBySignal OpenWithSignal=OFF; // Averaging Signal input bool CloseWithSignal=false; // Close Current Trade With Opposite Signal input int DistanceInPoints=0; // Distance In Points input double MartingaleFactor=1; // Martingale Factor extern string ConfigLOTE__ = "---------------------------Config Lots-----------------------------------";//. input int MagicNo=1234;// Magic Number (Do not keep the same number) input double LotSize=0.01;// Lot Size input int risk=0;//0 = Fixed Lots (Recommended) extern string Config__ = "---------------------------Config TP/SL----------------------------------";//. input int MaxOpenedTrades=5;// Max Opened Trades input double TP=150;//Target Profit input bool AlignTP=true;//Align All TP input double SL=500;// Stop Loss extern string TrailingStop__ = "--------------------Trailling Stop--------------------------------------";//. input bool UseTralling=false;//UseTralling input double TrallingStart=10;//Trailing Start in Pips input double LockProfit=5;//Lock Profit in Pips extern string TimeFilter__ = "-------------------------Time Filter--------------------------------------";//. input bool UseTimeFilter=false;//Time Filter input string StartTime="00:00";//Start Time input string EndTime="15:00";//Stop Time //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool jamOP(){ bool Oc=false; if(UseTimeFilter){ string j1 = TimeToStr(TimeCurrent(), TIME_DATE) + " " + StartTime; string j2 = TimeToStr(TimeCurrent(), TIME_DATE) + " " + EndTime; if(TimeCurrent()>=StrToTime(j1)&&TimeCurrent()expDate) { /// //ExpertRemove(); /// return(INIT_FAILED); } //------------------------------------------------------ { //--- g_Point=Point; if(Digits==5 || Digits==3) { g_Point *= 10; Slippage*=10; } ChartSetInteger(0,17,0,0); ChartSetInteger(0,0,1); string account_server=AccountInfoString(3); if(account_server=="") { account_server="default"; } datapath=TerminalInfoString(3)+"\\history\\" +account_server+"\\"+Symbol()+"240"+".hst"; ReadFileHst(datapath); //--- //m_filters_on = ""; //m_initpainel = true; return(INIT_SUCCEEDED); } } //+--------------- //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //----------------------------Tampilan EA-----------------------------------------------// Display_Info(); double SetPoint=g_Point; if(UseTralling && TrallingStart>0 && LockProfitTrallingStart*SetPoint){ if(Bid-((TrallingStart-LockProfit)*SetPoint) > OrderStopLoss()){ xx=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-((TrallingStart-LockProfit)*SetPoint),OrderTakeProfit(),0,Green); } } }} double rts=rata_price(1); for(int iTrade2=0;iTrade2TrallingStart*SetPoint){ if(Ask+((TrallingStart-LockProfit)*SetPoint) < OrderStopLoss() || OrderStopLoss()==0){ xx=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+((TrallingStart-LockProfit)*SetPoint),OrderTakeProfit(),0,Gold); } } } } } static datetime previousBar; if(previousBar!=Time[0]) { previousBar=Time[0]; ChartRedraw(); } else { return; } if(iVolume(Symbol(),PERIOD_H4,0)>iVolume(Symbol(),PERIOD_H4,1)) return; //********************************** if(!BytesToRead>0) return; int pos = -1 ; for(int i = 0 ; i < BytesToRead - 1 ; i++) { if(!(data[i][0]Open[0]) Comment("BUY - ", data[pos][1]); if(data[pos][1]150)return; int i; int TB=0,TS=0; for (i=0;i0) { if(CheckMarketBuyOrders()<70 && CheckMarketSellOrders()<70){ if(data[pos][1]>Open[0] && OpenWithSignal == OFF) if(IsBuyPinbar() && TB0)){ double BuySL=NormalizeDouble(Ask - SL*g_Point,Digits); double BuyTP=NormalizeDouble(Ask + TP*g_Point,Digits); if(AccountFreeMarginCheck(Symbol(),OP_BUY,GetLots())>0) { ticket=OrderSend(Symbol(),OP_BUY,GetLots(),Ask,Slippage,BuySL,BuyTP,"",MagicNo,0,clrGreen); if(AlignTP){ModifyTP(0,rata_price(0)+TP*g_Point);} CloseSell(); } } if(data[pos][1]0)){ double SellSL=NormalizeDouble(Bid + SL*g_Point,Digits); double SellTP=NormalizeDouble(Bid - TP*g_Point,Digits); if(AccountFreeMarginCheck(Symbol(),OP_SELL,GetLots())>0) { ticket=OrderSend(Symbol(),OP_SELL,GetLots(),Bid,Slippage,SellSL,SellTP,"",MagicNo,0,clrGreen); if(AlignTP){ModifyTP(1,rata_price(1)-TP*g_Point);} CloseBuy(); } } } } //----------------------OP----By Signal----------------------------------------------------------------- if(CountTrades()==0 ) { if(data[pos][1]>Open[0] && OpenWithSignal == ON) { if(IsBuyPinbar() && CountTrades()< MaxOpenedTrades ) { ticket = OrderSend(Symbol(), OP_BUY, GetLots(), Ask,10, 0,0,"", MagicNo,clrGreen); bool OPbuy=false; OPbuy=OrderModify(ticket,OrderOpenPrice(),Ask-SL*g_Point,Ask+(TP*g_Point),0,clrGreen); } } } if (CountTrades()==0 ) { if(data[pos][1]Open[0] && OpenWithSignal == ON) { if(IsBuyPinbar() && Sell > 0 ) { CloseSell(); } } if(data[pos][1] 0 ) { CloseBuy(); } } } //------------------------------Averaging Signal-------------------------------------------- if(OpenWithSignal == ON && CountTradesBuy()>=1&& CountTradesBuy() < MaxOpenedTrades && AlignTP ==false) { myAvg(); } if(OpenWithSignal == ON && CountTradesSell()>=1 && CountTradesSell()< MaxOpenedTrades && AlignTP ==False) { myAvg(); } //------------------------------------------------------------------------------------------- if(OpenWithSignal == ON && CountTradesBuy()>=1&& CountTradesBuy() < MaxOpenedTrades && AlignTP ==True) { myAvg1(); } if(OpenWithSignal == ON && CountTradesSell()>=1 && CountTradesSell()< MaxOpenedTrades && AlignTP ==True) { myAvg1(); } //------------------------------------------------------------------------------------------- return; } int xx=0; //+------------------------------------------------------------------+ int CountTrades(){ int count=0; for(int trade=OrdersTotal()-1;trade>=0;trade--){ int resulttrade=OrderSelect(trade,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNo)continue; if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo){ if(OrderType()==OP_SELL || OrderType()==OP_BUY){count++;}}} return(count);} int CountTradesBuy(){ int count=0; for(int trade=OrdersTotal()-1;trade>=0;trade--){ int resulttradebuy=OrderSelect(trade,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNo)continue; if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo){ if(OrderType()==OP_BUY){count++;}}} return(count);} //----+ int CountTradesSell(){ int count=0; for(int trade=OrdersTotal()-1;trade>=0;trade--){ int resulttradesell=OrderSelect(trade,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNo)continue; if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNo){ if(OrderType()==OP_SELL ){count++;}}} return(count);} //------------------------------------------------------------------------ void myAvg(){ int iCount = 0; double LastOP = 0; double LastLots = 0; bool LastIsBuy = false; int iTotalBuy = 0; int iTotalSell = 0; double Spread = 0.0; Spread= MarketInfo(Symbol(), MODE_SPREAD); int pos = -1 ; for(int i = 0 ; i < BytesToRead - 1 ; i++) { if(!(data[i][0]OrderOpenPrice()) {LastOP=OrderOpenPrice();} if(LastLotsOpen[0]) { if(IsBuyPinbar() && Bid<=LastOP-(DistanceInPoints*Point )){ ticket=OrderSend(Symbol(),OP_BUY,NormalizeDouble((LastLots* MartingaleFactor ),2),Ask,Slippage,0,0,"",MagicNo,0,clrGreen); bool LiB2=false; LiB2=OrderModify(ticket,OrderOpenPrice(),Ask-SL*g_Point,Ask+(TP*g_Point),0,clrGreen); LastIsBuy=false; return; } } } /* Jika arah Price adalah Sell...., Periksa nilai Ask (*/ else if(!LastIsBuy) { if(data[pos][1]=LastOP+(DistanceInPoints*Point )){ ticket =OrderSend(Symbol(),OP_SELL,NormalizeDouble((LastLots* MartingaleFactor ),2),Bid,Slippage,0,0,"",MagicNo,0,clrRed); bool LiB=false; LiB=OrderModify(ticket,OrderOpenPrice(),Bid+SL*g_Point,Bid-(TP*g_Point),0,clrRed); return; } } } } //---------------------------------------------------------------------------------------------- void myAvg1(){ int iCount = 0; double LastOP = 0; double LastLots = 0; bool LastIsBuy = false; int iTotalBuy = 0; int iTotalSell = 0; double Spread = 0.0; Spread= MarketInfo(Symbol(), MODE_SPREAD); int pos = -1 ; for(int i = 0 ; i < BytesToRead - 1 ; i++) { if(!(data[i][0]OrderOpenPrice()) {LastOP=OrderOpenPrice();} if(LastLotsOpen[0]) { if(IsBuyPinbar() && Bid<=LastOP-(DistanceInPoints*Point )){ ticket=OrderSend(Symbol(),OP_BUY,NormalizeDouble((LastLots* MartingaleFactor ),2),Ask,Slippage,0,0,"",MagicNo,0,clrGreen); hitung(); tpsl(); LastIsBuy=false; return; } } } /* Jika arah Price adalah Sell...., Periksa nilai Ask (*/ else if(!LastIsBuy) { if(data[pos][1]=LastOP+(DistanceInPoints*Point )){ ticket =OrderSend(Symbol(),OP_SELL,NormalizeDouble((LastLots* MartingaleFactor ),2),Bid,Slippage,0,0,"",MagicNo,0,clrRed); hitung(); tpsl(); return; } } } } //---------------------------------------------------------------------------------------------- void hitung() { Buy = 0; lotbuy = 0; lotsbuy = 0; Sell = 0; lotsell = 0; lotssell = 0; SUM = 0; SWAP = 0; profitbuy = 0; profitsell = 0; sumbuy = 0; sumsell = 0; bepbuy = 0; bepsell = 0; lowlotbuy = 9999; lowlotsell = 9999; hisell = 0; lobuy = 999999999; for (int i = 0; i < OrdersTotal(); i++) { bool hitung1=false; hitung1=OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() ) { continue; } if (OrderType() == OP_BUY ) { Buy++; OP++; lotbuy = OrderLots(); profitbuy += OrderProfit(); lotsbuy += OrderLots(); lowlotbuy = MathMin(lowlotbuy, OrderLots()); sumbuy += OrderLots() * OrderOpenPrice(); lobuy = MathMin(lobuy, OrderOpenPrice()); } // sell if (OrderType() == OP_SELL ) { Sell++; OP++; lotsell = OrderLots(); profitsell += OrderProfit(); lotssell += OrderLots(); lowlotsell = MathMin(lowlotsell, OrderLots()); sumsell += OrderLots() * OrderOpenPrice(); hisell = MathMax(hisell, OrderOpenPrice()); } } if (lotsbuy > 0) { bepbuy = sumbuy / lotsbuy; } if (lotssell > 0) { bepsell = sumsell / lotssell; } } // end hitung double ND(double p) { return(NormalizeDouble(p, Digits)); } bool ClsAll; bool ClsAll2; bool ClsAll3; bool BEPSL; bool OPbuyTPSL; bool BTPSL; bool OPsellTPSL; bool TPSL1; void tpsl( ) { for (int i = OrdersTotal() - 1; i >= 0; i--) { //bool TPSL1=false; TPSL1=OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() ) { continue; } if (OrderType() == OP_BUY ) { double oTPB = (bepbuy + TP * Point ) * (TP > 0); double oSLB = OrderStopLoss(); if (SL_BEP_minus > 0) oSLB = (bepbuy - SL_BEP_minus * Point ); if (Buy == 1) { oTPB = ND(OrderOpenPrice() + TP * Point ) * (TP > 0); if ( StopLoss > 0) oSLB = (OrderOpenPrice() - StopLoss * Point ); } oTPB = ND(oTPB); oSLB = ND(oSLB); if (Bid >= oTPB && oTPB > 0) //bool BEPSL=false; BEPSL=OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, CLR_NONE); if (Bid <= oSLB) //bool OPbuyTPSL=false; OPbuyTPSL=OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, CLR_NONE); if (ND(OrderTakeProfit()) != oTPB || ND(OrderStopLoss()) != oSLB) { if (!OrderModify(OrderTicket(), OrderOpenPrice(), oSLB, oTPB, OrderExpiration())) { Print(IntegerToHexString(OrderTicket()) + " MODIFY TP @ " + DoubleToStr(oTPB, Digits) + " SL @ " + DoubleToStr(oSLB, Digits) + " "); } } { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } if (OrderType() == OP_SELL ) { double oTPS = (bepsell - TP* Point ) * (TP> 0); double oSLS = OrderStopLoss(); if (SL_BEP_minus > 0) oSLS = (bepsell + SL_BEP_minus * Point ); if (Sell == 1) { oTPS = (OrderOpenPrice() - TP * Point ) * (TP> 0); if ( StopLoss > 0) oSLS = (OrderOpenPrice() + StopLoss * Point ); } oTPS = ND(oTPS); oSLS = ND(oSLS); if (Ask <= oTPS) // bool BTPSL=false; BTPSL=OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, CLR_NONE); if (Ask >= oSLS && oSLS > 0) // bool OPsellTPSL=false; OPsellTPSL=OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, CLR_NONE); if (ND(OrderTakeProfit()) != oTPS || ND(OrderStopLoss()) != oSLS) { if (!OrderModify(OrderTicket(), OrderOpenPrice(), oSLS, oTPS, OrderExpiration())) { Print(IntegerToString(OrderTicket()) + "MODIFY TP @ " + DoubleToStr(oTPS, Digits) + " SL @ " + DoubleToStr(oSLS, Digits) + " "); } } { Print("OrderSend() error - ", ErrorDescription(GetLastError())); } } } } //----------------------------------------------------------------------------------------------- void ReadFileHst(string FileName) { int j=0;; string strFileContents; int Handle; int LogFileSize; int movehigh[1]= {0}; uchar buffer[]; int nNumberOfBytesToRead; int read[1]= {0}; int i; double mm; //----- ----- strFileContents=""; Handle=CreateFileW(FileName,(int)0x80000000,3,0,3,0,0); //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ if(Handle==-1) { Comment(""); return; } LogFileSize=GetFileSize(Handle,0); //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ if(LogFileSize<=0) { return; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ if((LogFileSize-148)/60==BytesToRead) { return; } SetFilePointer(Handle,148,movehigh,0); BytesToRead=(LogFileSize-148)/60; ArrayResize(data,BytesToRead,0); nNumberOfBytesToRead=60; ArrayResize(buffer,60,0); for(i=0; i=0; i--) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ { int status=OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderMagicNumber()!=magic) continue; if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { op++; break; } } } return(op); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int CheckSellOrders(int magic) { int op=0; for(int i=OrdersTotal()-1; i>=0; i--) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ { int status=OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderMagicNumber()!=magic) continue; if(OrderSymbol()==Symbol()) { if(OrderType()==OP_SELL) { op++; break; } } } return(op); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int CheckTotalBuyOrders(int magic) { int op=0; for(int i=OrdersTotal()-1; i>=0; i--) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ { int status=OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderMagicNumber()!=magic) continue; if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { op++; } } } return(op); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int CheckTotalSellOrders(int magic) { int op=0; for(int i=OrdersTotal()-1; i>=0; i--) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ { int status=OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderMagicNumber()!=magic) continue; if(OrderSymbol()==Symbol()) { if(OrderType()==OP_SELL) { op++; } } } return(op); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int CheckMarketSellOrders() { int op=0; for(int i=OrdersTotal()-1; i>=0; i--) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ { int status=OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderMagicNumber()!=MagicNo) continue; if(OrderSymbol()==Symbol()) { if(OrderType()==OP_SELL) { op++; } } } return(op); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int CheckMarketBuyOrders() { int op=0; for(int i=OrdersTotal()-1; i>=0; i--) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ { int status=OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderMagicNumber()!=MagicNo) continue; if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { op++; } } } return(op); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool MainOrders(int a_cmd_0,double price_24,double price_TP,double price_SL) { color color_8=Black; int bClosed; int nAttemptsLeft=Retries; int cmd=0; if(a_cmd_0 ==OP_BUY||a_cmd_0 ==OP_BUYSTOP) cmd=0; if(a_cmd_0 ==OP_SELL||a_cmd_0 ==OP_SELLSTOP) cmd=1; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ if(a_cmd_0==OP_BUYLIMIT || a_cmd_0==OP_BUY) { color_8=Blue; } else { //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ if(a_cmd_0==OP_SELLLIMIT || a_cmd_0==OP_SELL) { color_8=Red; } } double lots_32=NormalizeDouble(LotSize,fnGetLotDigit()); if(lots_32==0.0) return(false); double gd_532 = MarketInfo(Symbol(), MODE_MAXLOT); double gd_540 = MarketInfo(Symbol(), MODE_MINLOT); if(lots_32 > gd_532) lots_32 = gd_532; if(lots_32 < gd_540) lots_32 = gd_540; bClosed=false; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ while((bClosed==false) && (nAttemptsLeft>=0)) { nAttemptsLeft--; RefreshRates(); if(!ecnBroker) bClosed=OrderSend(Symbol(),a_cmd_0,lots_32,price_24,Slippage,price_SL,price_TP,Ordercomment,MagicNo,0,color_8); else bClosed=OrderSend(Symbol(),a_cmd_0,lots_32,price_24,Slippage,0,0,Ordercomment,MagicNo,0,color_8); if(bClosed<=0) { int nErrResult=GetLastError(); if(a_cmd_0==0) { Print("FX EA Open New Buy FAILED : Error "+IntegerToString(nErrResult)+" ["+ErrorDescription(nErrResult)+".]"); Print(IntegerToString(a_cmd_0)+" "+DoubleToString(lots_32,2)+" "+DoubleToString(price_24,Digits)); } else { if(a_cmd_0==1) { Print("FX EA Open New Sell FAILED : Error "+IntegerToString(nErrResult)+" ["+ErrorDescription(nErrResult)+".]"); Print(IntegerToString(a_cmd_0)+" "+DoubleToString(lots_32,2)+" "+DoubleToString(price_24,Digits)); } } if(nErrResult == ERR_TRADE_CONTEXT_BUSY || nErrResult == ERR_NO_CONNECTION) { Sleep(50); continue; } } ticket=bClosed; bClosed=true; } return(true); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CloseBuy() { bool clo; while(CheckMarketBuyOrders()>0) { for(int i=OrdersTotal()-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNo) if(OrderType()==OP_BUY) clo=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,clrAqua); } } } //+------------------------------------------------------------------+ void CloseSell() { bool clo; while(CheckMarketSellOrders()>0) { for(int i=OrdersTotal()-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNo) if(OrderType()==OP_SELL) clo=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,clrAqua); } } } //+------------------------------------------------------------------+ double GetLots() { double lot; double minlot=MarketInfo(Symbol(),MODE_MINLOT); double maxlot=MarketInfo(Symbol(),MODE_MAXLOT); if(risk!=0) { lot=NormalizeDouble(AccountBalance()*risk/100/10000,2); if(lotmaxlot) lot=maxlot; } else lot=LotSize; return(lot); } //+------------------------------------------------------------------+ int signal(int mode) { int res=0; double var1 = 0; double var2 = 0; double var3 = 0; double var4 = 0; double var5 = 0; double var6 = 0; if(Close[2]>Open[2] && Close[1]>Open[1] && Low[2]Close[2] && Open[1]>Close[1] && High[2]>High[1]) { if(mode==2) { var5 = High[2]; var6 = High[1]; if(Open[0]>var6 -(var5-var6)) { var2=Low[0]; } if(Open[2]>Open[1]) { var5 = Open[2]; var6 = Open[1]; } else { var5 = 0.0; var6 = 0.0; } if(Open[0]>var6 -(var5-var6)) { var4=Low[0]; } } else { if(mode==0) { if(Open[2]>Open[1]) { var5 = Open[2]; var6 = Open[1]; } else { var5 = 0.0; var6 = 0.0; } } else { var5 = High[2]; var6 = High[1]; } if(Open[0]>var6 -(var5-var6)) { var4=Low[0]; } } } if((var1>0.0 || var3>0.0)) { res=+1; } else { if((var2>0.0 || var4>0.0)) { res=-1; } } return res; } //+------------------------------------------------------------------+ string CandleStick_Analyzer() { RefreshRates(); string CandleStick, Comment1="",Comment2="",Comment3="",Comment4="",Comment5="",Comment6="",Comment7="",Comment8="",Comment9=""; if(BullishEngulfingExists()) Comment1 =" Bullish Engulfing "; if(BullishHaramiExists()) Comment2 =" Bullish Harami "; if(LongUpCandleExists()) Comment3 =" Bullish LongUp "; if(DojiAtBottomExists()) Comment4 =" MorningStar Doji "; if(DojiAtTopExists()) Comment5 =" EveningStar Doji "; if(BearishHaramiExists()) Comment6 =" Bearish Harami "; if(BearishEngulfingExists()) Comment7 =" Bearish Engulfing "; if(LongDownCandleExists()) Comment8 =" Bearish LongDown "; /*if(SpinningTopExists()) Comment9 =" Spinning Top ";*/ CandleStick =Comment1+Comment2+Comment3+Comment4+Comment5+Comment6+Comment7+Comment8+Comment9; return (CandleStick); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool BullishEngulfingExists() { if(Open[1] <= Close[2] && Close[1] >= Open[2] && Open[2] - Close[2] >= 10*Point && Close[1] - Open[1] >= 10*Point) return (true); return (false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool BullishHaramiExists() { if(Close[2] < Open[2] && Open[1] < Close[1] && Open[2] - Close[2] > iATR(NULL, 0, 14, 2) && Open[2] - Close[2] > 4*(Close[1] - Open[1])) return (true); return (false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool DojiAtBottomExists() { if(Open[3] - Close[3] >= 8*Point && MathAbs(Close[2] - Open[2]) <= 1*Point && Close[1] - Open[1] >= 8*Point) return (true); return (false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool DojiAtTopExists() { if(Close[3] - Open[3] >= 8*Point && MathAbs(Close[2] - Open[2]) <= 1*Point && Open[1] - Close[1] >= 8*Point) return (true); return (false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool BearishHaramiExists() { if(Close[2] > Close[1] && Open[2] < Open[1] && Close[2] > Open[2] && Open[1] > Close[1] && Close[2] - Open[2] > iATR(NULL, 0, 14, 2) && Close[2] - Open[2] > 4*(Open[1] - Close[1])) return (true); return (false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool LongUpCandleExists() { if(Open[2] < Close[2] && High[2] - Low[2] >= 40*Point && High[2] - Low[2] > 2.5*iATR(NULL, 0, 14, 2) && Close[1] < Open[1] && Open[1] - Close[1] > 10*Point) return (true); return (false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool LongDownCandleExists() { if(Open[1] > Close[1] && High[1] -Low[1] >= 40*Point && High[1] - Low[1] > 2.5*iATR(NULL, 0, 14, 1)) return (true); return (false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool BearishEngulfingExists() { if(Open[1] >= Close[2] && Close[1] <= Open[2] && Open[2] -Close[2] >= 10*Point && Close[1]- Open[1] >= 10*Point) return (true); return (false); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ /*bool SpinningTopExists() { HideTestIndicators(true); if(High[1] - Low[1] > 1.5*iATR(NULL, 0, 14, 1)) Print("ST Condition 1 Met"); if(MathAbs(Open[1] - Close[1])*5 < High[1] - Low[1]) Print("ST Condition 2 Met"); if(High[1] - Low[1] > 1.5*iATR(NULL, 0, 14, 1) && (High[1] - Low[1] > 30*Point) && MathAbs(Open[1] - Close[1])*5 < High[1]- Low[1]) return (true); HideTestIndicators(false); return (false); }*/ //+------------------------------------------------------------------+ void MakeLine(double price) { string name="Equator"; if(price>iOpen(Symbol(),PERIOD_M5,0)) Comment("BUY = "+DoubleToStr(price,Digits)); if(price= 0 && Seconds() < 10) li_0 = 255; if (Seconds() >= 10 && Seconds() < 20) li_0 = 15631086; if (Seconds() >= 20 && Seconds() < 30) li_0 = 42495; if (Seconds() >= 30 && Seconds() < 40) li_0 = 16711680; if (Seconds() >= 40 && Seconds() < 50) li_0 = 65535; if (Seconds() >= 50 && Seconds() <= 59) li_0 = 16776960; string ls_8 = "--------------------------------------------------------------------------------"; LABEL("L01", "Arial", 9,110,13,C'226,103,211',0,ls_8); LABEL("L02", "Public Sans", 12,120,23,C'226,103,211',0,"Prometheus"); LABEL("L03", "Public Sans", 10,120,48,C'226,103,211',0,"SYNK Trading"); LABEL("L04", "Arial", 9,110,60,C'226,103,211', 0, ls_8); LABEL("L09", "Arial", 8,120,80,C'226,103,211', 0,"Total Lots"); //LABEL("L10", "Arial", 7,120,95,White, 0,"Total Lots - Sell"); //---------------------------------------------------------------------------------------------------- LABEL("L12", "Arial", 8,120,110,C'226,103,211', 0,"Open Orders"); //LABEL("L13", "Arial", 7,120,125,White, 0,"Orders Open-Sell"); LABEL("L14", "Arial", 9,110,140,C'226,103,211', 0, ls_8); LABEL("L15", "Arial", 8,120,155,C'226,103,211',0,"Time Candle"); LABEL("L16", "Arial", 9,110,205,C'226,103,211', 0, ls_8); LABEL("L17", "Arial", 8,120,170,C'226,103,211',0,"Balance"); LABEL("L18", "Arial", 8,120,185,C'226,103,211',0,"Equity"); LABEL("L19", "Arial", 9,110,280,C'226,103,211', 0, ls_8); LABEL("L20", "Arial", 8,120,220,C'226,103,211',0,"Profit / Loss :"); //-------------------------------------------------------------------------- LABEL("L33", "Arial", 8,220,80,C'226,103,211',0,": " + DoubleToStr((lotsbuy + lotssell), 2) ); //LABEL("L34", "Arial", 7,220,95,White,0,": " + DoubleToStr(lotssell, 2) ); LABEL("L38", "Arial", 8,220,110,C'226,103,211',0,": " + DoubleToStr((Buy + Sell), 0) ); //LABEL("L39", "Arial", 7,220,125,White,0,": " + DoubleToStr(Sell, 0) ); LABEL("L40", "Arial", 8,220,155,C'226,103,211',0,": " + _m+DoubleToStr(m,0)+":"+_s+DoubleToStr(s,0) ); LABEL("L41", "Arial", 8,220,170,C'226,103,211',0,": " + DoubleToStr(AccountBalance(), 2) ); LABEL("L42", "Arial", 8,220,185,C'226,103,211',0,": " + DoubleToStr(AccountEquity(), 2) ); LABEL("L21", "Arial", 12,120,240,C'226,103,211',0,""+ DoubleToStr(AccountEquity() - AccountBalance(), 2)); } void LABEL(string a_name_0, string a_fontname_8, int a_fontsize_16, int a_x_20, int a_y_24, color a_color_28, int a_corner_32, string a_text_36) { if (ObjectFind(a_name_0) < 0) ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0); ObjectSetText(a_name_0, a_text_36, a_fontsize_16, a_fontname_8, a_color_28); ObjectSet(a_name_0, OBJPROP_CORNER, a_corner_32); ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_20); ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_24); } //+------------------------------------------------------------------+ //| OnChart event handler | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { if(ObjectGetInteger(0,"CLOSE ALL1",OBJPROP_STATE)!=0) { ObjectSetInteger(0,"CLOSE ALL1",OBJPROP_STATE,0); PlaySound("alert2.wav"); int total = OrdersTotal(); for (int cnt = total-1 ; cnt >=0 ; cnt--) { bool MOT=false; MOT=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) { switch(OrderType()) { case OP_BUY : { if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),10,Violet)) return; }break; case OP_SELL : { if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),10,Violet)) return; }break; } if(OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLLIMIT) if(!OrderDelete(OrderTicket())) { Print("Error deleting " + IntegerToString(OrderType()) + " order : ",GetLastError()); return ; } } } return ; } // FUNGSI CLOSE ALL if (ObjectGetInteger(0, "CLOSE ALL", OBJPROP_STATE) != 0) { ObjectSetInteger(0, "CLOSE ALL", OBJPROP_STATE, 0); for (int li_0 = OrdersTotal() - 1; li_0 >= 0; li_0--) { // bool ClsAll=false; ClsAll=OrderSelect(li_0, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol()) { if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) // bool ClsAll2=false; ClsAll2=OrderClose(OrderTicket(), OrderLots(), Bid, MagicNo); if (OrderType() == OP_SELL) // bool ClsAll3=false; ClsAll3=OrderClose(OrderTicket(), OrderLots(), Ask, MagicNo); } Sleep(1000); } } } }