0% found this document useful (0 votes)
9 views2 pages

AyuRobot 30-Position Trading Strategy

Uploaded by

atasischoloo
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

AyuRobot 30-Position Trading Strategy

Uploaded by

atasischoloo
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//+------------------------------------------------------------------+

//| AyuRobot_TickTrader_30Limit.mq5 |
//| Maks 30 entry, refill otomatis jika ada yg closed |
//| TP=$0.3, SL=$0.1, Lot=0.1 |
//+------------------------------------------------------------------+
#property strict
#include <Trade/[Link]>

CTrade trade;

input double LotSize = 0.1;


input int MaxPositions = 30;
input ENUM_TIMEFRAMES TimeFrame = PERIOD_M1;

//-------------------------------------------------------------
// Convert target money ? price distance
//-------------------------------------------------------------
double MoneyToPrice(double money, bool isBuy)
{
double price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);

for(int i = 1; i < 5000000; i++)


{
double newPrice = isBuy ? price + i * point : price - i * point;

double profit;
if(!OrderCalcProfit(isBuy ? ORDER_TYPE_BUY : ORDER_TYPE_SELL,
_Symbol, LotSize, price, newPrice, profit))
return 0;

if(profit >= money)


return MathAbs(newPrice - price);
}
return 0;
}

//-------------------------------------------------------------
// Hitung total posisi simbol ini
//-------------------------------------------------------------
int CountAllPositions()
{
int count = 0;
for(int i = 0; i < PositionsTotal(); i++)
{
if(PositionGetSymbol(i) == _Symbol)
count++;
}
return count;
}

//-------------------------------------------------------------
// Buat satu entry sesuai arah candle
//-------------------------------------------------------------
void OpenOneTrade(int direction)
{
double slMoney = 0.1;
double tpMoney = 0.3;
if(direction == 1) // BUY
{
double price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double slDist = MoneyToPrice(slMoney, false);
double tpDist = MoneyToPrice(tpMoney, true);

double sl = price - slDist;


double tp = price + tpDist;

[Link](LotSize, _Symbol, 0, sl, tp, "BuyRefill");


}
else if(direction == -1) // SELL
{
double price = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double slDist = MoneyToPrice(slMoney, true);
double tpDist = MoneyToPrice(tpMoney, false);

double sl = price + slDist;


double tp = price - tpDist;

[Link](LotSize, _Symbol, 0, sl, tp, "SellRefill");


}
}

//-------------------------------------------------------------
// MAIN LOGIC – jaga agar selalu ada 30 posisi
//-------------------------------------------------------------
void OnTick()
{
// Tentukan arah candle
double openPrice = iOpen(_Symbol, TimeFrame, 0);
double closePrice = iClose(_Symbol, TimeFrame, 0);

int direction = 0;
if(closePrice > openPrice) direction = 1; // BUY
else if(closePrice < openPrice) direction = -1; // SELL
else return; // Candle doji ? tidak entry

// Hitung total posisi


int currentPos = CountAllPositions();

// Jika kurang dari 30 ? isi kekosongan


if(currentPos < MaxPositions)
{
int need = MaxPositions - currentPos;

for(int i = 0; i < need; i++)


OpenOneTrade(direction);
}
}

You might also like