extern int Delta = 30; extern int SL = 20; extern int TP = 40; double LHFU, LLFD; // LastHighFractalUp, LastLowFractalDown double SS_OpnPrx, BS_OpnPrx; int JT_SL, // Jumlah Trades Sell Limit JT_BL, // Jumlah Trades Buy Limit JT_SS, // Jumlah Trades Sell Stop JT_BS, // Jumlah Trades Buy Stop JT_OS, // Jumlah Trades Open Sell JT_OB; // Jumlah Trades Open Buy int start() { ChkAllTrd(); if (JT_OS<=0 && JT_OB<=0) // tdk ada open posisi { FindLastFractal(); if (LHFU>0) // ada fractal up { if (JT_BS>0) HapusBuyStop(); Print ("LHFU...: "+LHFU); Print ("SS Open: "+ChkOrderOpnPrx("SS")); if (ChkOrderOpnPrx("SS")>0 && ChkOrderOpnPrx("SS")!=LHFU-(Delta*Point)) HapusSellStop(); if (JT_SS<=0) { SS_OpnPrx = LHFU-(Delta*Point); OrderSend(Symbol(),OP_SELLSTOP,1,SS_OpnPrx,0,SS_OpnPrx+(SL*Point),SS_OpnPrx-(TP*Point),"Sell",0,0,Red); } } if (LLFD>0) // ada fractal dn { if (JT_SS>0) HapusSellStop(); Print ("LLFD...: "+LLFD); Print ("BS Open: "+ChkOrderOpnPrx("BS")); if (ChkOrderOpnPrx("BS")>0 && ChkOrderOpnPrx("BS")!=LLFD+(Delta*Point)) HapusBuyStop(); if (JT_BS<=0) { BS_OpnPrx = LLFD+(Delta*Point); OrderSend(Symbol(),OP_BUYSTOP,1,BS_OpnPrx,0,BS_OpnPrx-(SL*Point),BS_OpnPrx+(TP*Point),"Buy",0,0,Blue); } } } return(0); } void FindLastFractal() { double val1; double val2; int i; i = Bars; LHFU = 0; LLFD = 0; while(i>=0) { val1 = iFractals(NULL, 0, MODE_UPPER,i); if (val1 > 0) LHFU = High[i]; val2 = iFractals(NULL, 0, MODE_LOWER,i); if (val2 > 0) LLFD = Low[i]; if (LHFU>0 || LLFD>0) break; else i--; } } void ChkAllTrd() { int ecnt, total; JT_SL=0; JT_BL=0; JT_SS=0; JT_BS=0; JT_OS=0; JT_OB=0; total=OrdersTotal(); for (ecnt=0;ecnt