İş Gereklilikleri
i would like someone to create a bot for me that trades volatility 50 (1s) and volatility 75 index. Setting the required stop losses and take profit, following trends while using the martingale function. i start with 5usd......and please tell me the cost of this bot. this is a bot i tried creating on chatgpt.
//+------------------------------------------------------------------+
//| Expert Advisor using CCI (200), Stochastic (60,1,2), and ATR |
//+------------------------------------------------------------------+
#include <Trade/Trade.mqh>
CTrade trade;
// Indicator Handles
int cciHandle, stochHandle, atrHandle;
// Indicator Buffers
double cciBuffer[];
double kBuffer[];
double atrBuffer[];
// Risk Management Parameters
input double ATRMultiplier = 1.5; // Multiplier for ATR-based SL/TP
input double BreakEven = 10; // Move SL to break-even after this profit (in points)
input double LotSize = 0.007; // User-defined lot size
input double ProfitLock = 20; // Lock in profits after this amount
input double MaxDrawdownPerTrade = 2; // Maximum drawdown per trade in percentage
input double MaxAccountDrawdown = 10; // Maximum account drawdown in percentage
double AdjustedLotSize; // Internal adjustable lot size
//+------------------------------------------------------------------+
//| Function to check and adjust lot size |
//+------------------------------------------------------------------+
void CheckLotSize()
{
double minLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
double stepLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
AdjustedLotSize = LotSize;
if (AdjustedLotSize < minLot)
{
Print("Warning: Lot size too small. Adjusting to minimum allowed: ", minLot);
AdjustedLotSize = minLot;
}
AdjustedLotSize = NormalizeDouble(AdjustedLotSize / stepLot, 0) * stepLot;
}
//+------------------------------------------------------------------+
//| Initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
CheckLotSize();
cciHandle = iCCI(_Symbol, PERIOD_M5, 200, PRICE_TYPICAL);
stochHandle = iStochastic(_Symbol, PERIOD_M5, 60, 1, 2, MODE_SMA, STO_LOWHIGH);
atrHandle = iATR(_Symbol, PERIOD_M5, 14);
return INIT_SUCCEEDED;
}
//+------------------------------------------------------------------+
//| Main trading logic |
//+------------------------------------------------------------------+
void OnTick()
{
if (CopyBuffer(cciHandle, 0, 0, 2, cciBuffer) <= 0) return;
if (CopyBuffer(stochHandle, 0, 0, 2, kBuffer) <= 0) return;
if (CopyBuffer(atrHandle, 0, 0, 1, atrBuffer) <= 0) return;
double cciCurrent = cciBuffer[0];
double cciPrevious = cciBuffer[1];
double stochK = kBuffer[0];
double atrValue = atrBuffer[0] * ATRMultiplier;
double priceAsk = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double priceBid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
Print("CCI Current: ", cciCurrent, " Stochastic K: ", stochK, " ATR: ", atrValue);
// Buy condition: CCI crosses above -100 and Stochastic is below 50
if (cciPrevious < -100 && cciCurrent > -100 && stochK < 50)
{
double sl = priceAsk - atrValue;
double tp = priceAsk + (atrValue * 1.5);
trade.Buy(AdjustedLotSize, _Symbol, priceAsk, sl, tp);
Print("Buy order executed at ", priceAsk);
}
// Sell condition: CCI crosses below 100 and Stochastic is above 50
if (cciPrevious > 100 && cciCurrent < 100 && stochK > 50)
{
double sl = priceBid + atrValue;
double tp = priceBid - (atrValue * 1.5);
trade.Sell(AdjustedLotSize, _Symbol, priceBid, sl, tp);
Print("Sell order executed at ", priceBid);
}
}