Pada dasar nya script ini di gunakan untuk yang paham dengan Supply and Demand … Asisten ini cocok untuk anda yang suka bermain di area Ranging Supply and Demand …
kali ni saya coba untuk buat script asistent untuk MT5 ato meta trader 5
![]()
berikut script untuk mt5 rbr-dbd v1
//+——————————————————————+
//| Advanced_Fibo_Panel.mq5 |
//| |
//+——————————————————————+
#property copyright “Hak Cipta Dilindungi”
#property link “”
#property version “5.00”#include <Trade\Trade.mqh>
#include <Controls\Button.mqh>
#include <Controls\Edit.mqh>
#include <Controls\Label.mqh>
#include <Controls\Panel.mqh>CTrade trade;
//— Input Parameter Dasar
input ulong InpMagicNum = 987654;
string FiboName = “EA_Fibo_Object”;//— Variabel Global GUI
CPanel panelBg;
CButton btnFixedLot, btnRiskPct, btnBuyLimit, btnSellLimit;
CButton btnCloseAll, btnDeleteAllPO, btnDeleteBuyPO, btnDeleteSellPO;
CEdit inputLot, inputLayers, inputMultiplier;//— Status Mode
bool isRiskMode = false;
double riskPercentage = 1.0;//+——————————————————————+
//| Expert initialization function |
//+——————————————————————+
int OnInit()
{
trade.SetExpertMagicNumber(InpMagicNum);
ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, true);CreateGUI();
CreateFiboObject();
EventSetTimer(1);ChartRedraw();
return(INIT_SUCCEEDED);
}//+——————————————————————+
//| Expert deinitialization function |
//+——————————————————————+
void OnDeinit(const int reason)
{
EventKillTimer();
ObjectDelete(0, FiboName);
panelBg.Destroy();
btnFixedLot.Destroy(); btnRiskPct.Destroy();
btnBuyLimit.Destroy(); btnSellLimit.Destroy();
inputLot.Destroy(); inputLayers.Destroy(); inputMultiplier.Destroy();
btnCloseAll.Destroy(); btnDeleteAllPO.Destroy();
btnDeleteBuyPO.Destroy(); btnDeleteSellPO.Destroy();
}//+——————————————————————+
//| Expert timer function |
//+——————————————————————+
void OnTimer()
{
UpdateCounters();
}
//+——————————————————————+
//| Fungsi Membuat Tampilan GUI Panel (Lebar & Font Diperbesar) |
//+——————————————————————+
void CreateGUI()
{
int offsetX = 20;
int offsetY = 60;
int pWidth = 375; // Ukuran lebar panel dasar dari Anda// Membuat Background Panel Utama (Tinggi disesuaikan pas ke offsetY + 380)
panelBg.Create(0, “Panel_Bg”, 0, offsetX, offsetY, offsetX + pWidth, offsetY + 380);
panelBg.ColorBackground(C’45,45,45′);
panelBg.ColorBorder(clrGray);// — BARIS 1: Tombol FIXED LOT & RISK % —
// Lebar masing-masing tombol: 165 piksel. Jarak tengah: 15 piksel. Jarak tepi: 15 piksel.
btnFixedLot.Create(0, “Btn_FixedLot”, 0, offsetX + 15, offsetY + 15, offsetX + 180, offsetY + 50);
btnFixedLot.Text(“FIXED LOT”); btnFixedLot.ColorBackground(C’0,100,0′); btnFixedLot.Color(clrWhite); btnFixedLot.FontSize(12);btnRiskPct.Create(0, “Btn_RiskPct”, 0, offsetX + 195, offsetY + 15, offsetX + 360, offsetY + 50);
btnRiskPct.Text(“% RISK”); btnRiskPct.ColorBackground(clrDarkGray); btnRiskPct.Color(clrWhite); btnRiskPct.FontSize(12);// — BARIS 2: Kolom Input Lot Dasar & Jumlah Layers —
inputLot.Create(0, “Inp_Lot”, 0, offsetX + 15, offsetY + 65, offsetX + 180, offsetY + 100);
inputLot.Text(“0.1”); inputLot.FontSize(12);inputLayers.Create(0, “Inp_Layers”, 0, offsetX + 195, offsetY + 65, offsetX + 360, offsetY + 100);
inputLayers.Text(“4”); inputLayers.FontSize(12);// — BARIS 3: Kolom Input Multiplier (Melebar Penuh) —
// Bentangan horizontal penuh dari sisi kiri (15) ke sisi kanan (360) agar simetris
inputMultiplier.Create(0, “Inp_Multi”, 0, offsetX + 15, offsetY + 115, offsetX + 360, offsetY + 150);
inputMultiplier.Text(“1,1,1,2”); inputMultiplier.FontSize(12);// — BARIS 4: Tombol Utama BUY LIMIT & SELL LIMIT —
btnBuyLimit.Create(0, “Btn_BuyLimit”, 0, offsetX + 15, offsetY + 165, offsetX + 180, offsetY + 205);
btnBuyLimit.Text(“▲ BUY LIMIT”); btnBuyLimit.ColorBackground(C’0,128,64′); btnBuyLimit.Color(clrWhite); btnBuyLimit.FontSize(12);btnSellLimit.Create(0, “Btn_SellLimit”, 0, offsetX + 195, offsetY + 165, offsetX + 360, offsetY + 205);
btnSellLimit.Text(“▼ SELL LIMIT”); btnSellLimit.ColorBackground(C’128,0,0′); btnSellLimit.Color(clrWhite); btnSellLimit.FontSize(12);// — BARIS 5: Tombol Melebar Penuh – Close All —
btnCloseAll.Create(0, “Btn_CloseAll”, 0, offsetX + 15, offsetY + 220, offsetX + 360, offsetY + 255);
btnCloseAll.Text(“CLOSE ALL POSITIONS”); btnCloseAll.ColorBackground(C’45,25,25′); btnCloseAll.Color(clrDarkGray); btnCloseAll.FontSize(12);// — BARIS 6: Tombol Melebar Penuh – Delete All Pending Orders —
btnDeleteAllPO.Create(0, “Btn_DeleteAllPO”, 0, offsetX + 15, offsetY + 270, offsetX + 360, offsetY + 305);
btnDeleteAllPO.Text(“DELETE PENDING ORDERS”); btnDeleteAllPO.ColorBackground(C’15,35,85′); btnDeleteAllPO.Color(clrWhite); btnDeleteAllPO.FontSize(12);// — BARIS 7: Tombol Pembersih Berjejer Samping – Delete Buy vs Sell —
// Koordinat akhir diseret penuh ke 180 (kiri) dan 360 (kanan) agar membagi ruang panel dengan sempurna
btnDeleteBuyPO.Create(0, “Btn_DeleteBuyPO”, 0, offsetX + 15, offsetY + 320, offsetX + 180, offsetY + 355);
btnDeleteBuyPO.Text(“DELETE PO BUY”); btnDeleteBuyPO.ColorBackground(C’20,85,45′); btnDeleteBuyPO.Color(clrWhite); btnDeleteBuyPO.FontSize(11);btnDeleteSellPO.Create(0, “Btn_DeleteSellPO”, 0, offsetX + 195, offsetY + 320, offsetX + 360, offsetY + 355);
btnDeleteSellPO.Text(“DELETE PO SELL”); btnDeleteSellPO.ColorBackground(C’128,45,35′); btnDeleteSellPO.Color(clrWhite); btnDeleteSellPO.FontSize(11);UpdateCounters();
}//+——————————————————————+
//| Fungsi Membuat Objek Fibonacci Retracement Asli |
//+——————————————————————+
void CreateFiboObject()
{
if(ObjectFind(0, FiboName) >= 0) return;
double price = SymbolInfoDouble(_Symbol, SYMBOL_BID); double spacing = 2000 * _Point;
datetime time1 = TimeCurrent() – 14400; datetime time2 = TimeCurrent();ObjectCreate(0, FiboName, OBJ_FIBO, 0, time1, price – spacing, time2, price + spacing);
ObjectSetInteger(0, FiboName, OBJPROP_LEVELS, 5);double p_levels[] = { 0.0, 0.25, 0.50, 0.75, 1.00 };
string p_texts[] = { “0.0 (%$)”, “25.0 (%$)”, “50.0 (%$)”, “75.0 (%$)”, “100.0 (%$)” };for(int i=0; i<5; i++) {
ObjectSetDouble(0, FiboName, OBJPROP_LEVELVALUE, i, p_levels[i]);
ObjectSetString(0, FiboName, OBJPROP_LEVELTEXT, i, p_texts[i]);
}
ObjectSetInteger(0, FiboName, OBJPROP_LEVELCOLOR, clrYellow);
ObjectSetInteger(0, FiboName, OBJPROP_COLOR, clrRed);
ObjectSetInteger(0, FiboName, OBJPROP_SELECTABLE, true); ObjectSetInteger(0, FiboName, OBJPROP_SELECTED, true);
}
//+——————————————————————+
//| Logika Pendeteksi Klik Tombol (OnChartEvent) |
//+——————————————————————+
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
{
if(id == CHARTEVENT_OBJECT_CLICK)
{
if(sparam == “Btn_FixedLot”) { isRiskMode = false; btnFixedLot.ColorBackground(C’0,128,64′); btnRiskPct.ColorBackground(clrDarkGray); }
if(sparam == “Btn_RiskPct”) { isRiskMode = true; btnRiskPct.ColorBackground(C’0,128,64′); btnFixedLot.ColorBackground(clrDarkGray); }
if(sparam == “Btn_BuyLimit”) { EksekusiOrder(ORDER_TYPE_BUY_LIMIT); UpdateCounters(); }
if(sparam == “Btn_SellLimit”) { EksekusiOrder(ORDER_TYPE_SELL_LIMIT); UpdateCounters(); }
if(sparam == “Btn_CloseAll”) { ActionCloseAllPositions(); UpdateCounters(); }
if(sparam == “Btn_DeleteAllPO”) { ActionDeletePendingOrders(0); UpdateCounters(); }
if(sparam == “Btn_DeleteBuyPO”) { ActionDeletePendingOrders(ORDER_TYPE_BUY_LIMIT); UpdateCounters(); }
if(sparam == “Btn_DeleteSellPO”) { ActionDeletePendingOrders(ORDER_TYPE_SELL_LIMIT); UpdateCounters(); }
}
}//+——————————————————————+
//| Fungsi Penghitung Angka Indikator Tombol (Counter) |
//+——————————————————————+
void UpdateCounters()
{
int openPos = 0; int totalPO = 0; int buyPO = 0; int sellPO = 0;
for(int i=PositionsTotal()-1; i>=0; i–) {
if(PositionGetSymbol(i) == _Symbol && PositionGetInteger(POSITION_MAGIC) == InpMagicNum) openPos++;
}
for(int i=OrdersTotal()-1; i>=0; i–) {
ulong ticket = OrderGetTicket(i);
if(ticket > 0 && OrderGetString(ORDER_SYMBOL) == _Symbol && OrderGetInteger(ORDER_MAGIC) == InpMagicNum) {
long type = OrderGetInteger(ORDER_TYPE); totalPO++;
if(type == ORDER_TYPE_BUY_LIMIT) buyPO++; if(type == ORDER_TYPE_SELL_LIMIT) sellPO++;
}
}
btnCloseAll.Text(“CLOSE ALL POSITIONS [” + (string)openPos + “]”);
btnDeleteAllPO.Text(“DELETE PENDING ORDERS [” + (string)totalPO + “]”);
btnDeleteBuyPO.Text(“DELETE PO BUY [” + (string)buyPO + “]”);
btnDeleteSellPO.Text(“DELETE PO SELL [” + (string)sellPO + “]”);
if(openPos > 0) { btnCloseAll.Color(clrWhite); btnCloseAll.ColorBackground(C’140,25,25′); }
else { btnCloseAll.Color(clrDarkGray); btnCloseAll.ColorBackground(C’45,25,25′); }
ChartRedraw();
}void ActionCloseAllPositions() {
for(int i=PositionsTotal()-1; i>=0; i–) {
if(PositionGetSymbol(i) == _Symbol && PositionGetInteger(POSITION_MAGIC) == InpMagicNum) trade.PositionClose(PositionGetInteger(POSITION_TICKET));
}
}void ActionDeletePendingOrders(long filterType) {
for(int i=OrdersTotal()-1; i>=0; i–) {
ulong ticket = OrderGetTicket(i);
if(ticket > 0 && OrderGetString(ORDER_SYMBOL) == _Symbol && OrderGetInteger(ORDER_MAGIC) == InpMagicNum) {
if(filterType == 0 || OrderGetInteger(ORDER_TYPE) == filterType) trade.OrderDelete(ticket);
}
}
}void EksekusiOrder(ENUM_ORDER_TYPE type)
{
int digits = (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS);
double p0 = ObjectGetDouble(0, FiboName, OBJPROP_PRICE, 0); double p100 = ObjectGetDouble(0, FiboName, OBJPROP_PRICE, 1);
double diff = p100 – p0;
double f0 = NormalizeDouble(p0, digits); double f25 = NormalizeDouble(p0 + (diff * 0.25), digits);
double f50 = NormalizeDouble(p0 + (diff * 0.50), digits); double f75 = NormalizeDouble(p0 + (diff * 0.75), digits);
double f100 = NormalizeDouble(p100, digits);int totalLayers = (int)StringToInteger(inputLayers.Text()); double baseLot = StringToDouble(inputLot.Text());
string arrayMulti[]; StringSplit(inputMultiplier.Text(), ‘,’, arrayMulti);if(type == ORDER_TYPE_BUY_LIMIT) {
double lowBound = MathMin(f0, f25); double highBound = MathMax(f0, f25);
double step = (highBound – lowBound) / MathMax(1, totalLayers – 1);
for(int i=0; i<totalLayers; i++) {
double targetPrice = NormalizeDouble(lowBound + (i * step), digits);
int multiIdx = (totalLayers – 1) – i;
double multiplier = (multiIdx >= 0 && multiIdx < ArraySize(arrayMulti)) ? StringToDouble(arrayMulti[multiIdx]) : 1.0;
trade.BuyLimit(NormalizeDouble(baseLot * multiplier, 2), targetPrice, _Symbol, 0, f50, ORDER_TIME_GTC, 0, “”);
}
}
else if(type == ORDER_TYPE_SELL_LIMIT) {
double lowBound = MathMin(f75, f100); double highBound = MathMax(f75, f100);
double step = (highBound – lowBound) / MathMax(1, totalLayers – 1);
for(int i=0; i<totalLayers; i++) {
double targetPrice = NormalizeDouble(lowBound + (i * step), digits);
double multiplier = (i < ArraySize(arrayMulti)) ? StringToDouble(arrayMulti[i]) : 1.0;
trade.SellLimit(NormalizeDouble(baseLot * multiplier, 2), targetPrice, _Symbol, 0, f50, ORDER_TIME_GTC, 0, “”);
}
}
}
untuk yang versi 2 next … kalo ada yang minat … wkwkwk untuk v1 pending order akan mengikutin garis fibo yang ada … dan versi 2 ada garis horizontal merah dan hijau serta tp warna biru …
soo … selamat mencoba ….
beerikut tampilan screen shoot dari meta trader mt5 untuk v1