Hi my code Is not actioning any trades please help me Identify the error #150463
Replies: 3 comments
-
|
Thanks for posting in the GitHub Community, @JasonBoshoff! We're happy you're here. You are more likely to get a useful response if you are posting your question in the applicable category, the Discussions category is solely related to conversations around the GitHub product Discussions. This question should be in the Programming Help category. I've gone ahead and moved it for you. Good luck! |
Beta Was this translation helpful? Give feedback.
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
//+------------------------------------------------------------------+
//| Advanced Gold Day Trading Bot v3.0 |
//| Combines Multiple Indicators with Dynamic Risk Management |
//+------------------------------------------------------------------+
#property strict
#property copyright "Advanced Gold Trading Bot"
#property version "3.0"
#include <Trade\Trade.mqh>
CTrade trade;
// Inputs for trading configuration
input double RiskPercentage = 1.0; // Risk per trade as a percentage of account equity
input int ATRPeriod = 14; // ATR period for dynamic stop-loss
input int RSIPeriod = 14; // RSI period
input int OverboughtLevel = 70; // RSI overbought level
input int OversoldLevel = 30; // RSI oversold level
input int FastMAPeriod = 9; // Fast moving average period
input int SlowMAPeriod = 21; // Slow moving average period
input int BollingerPeriod = 20; // Bollinger Bands period
input double BollingerDeviation = 2.0; // Bollinger Bands deviation
input string SymbolName = "XAUUSD"; // Trading symbol
input ENUM_TIMEFRAMES Timeframe = PERIOD_M15; // Trading timeframe
// Internal variables
double atrValue;
double accountEquity;
// Calculate position size based on risk percentage and ATR
double CalculateLotSize(double stopLossDistance)
{
accountEquity = AccountInfoDouble(ACCOUNT_EQUITY);
double riskAmount = accountEquity * (RiskPercentage / 100.0);
double tickValue = SymbolInfoDouble(SymbolName, SYMBOL_TRADE_TICK_VALUE);
return NormalizeDouble(riskAmount / (stopLossDistance * tickValue), 2);
}
// Calculate dynamic Stop Loss and Take Profit based on ATR
void CalculateTradeLevels(double price, bool isBuy, double &stopLoss, double &takeProfit)
{
double atrPoints = atrValue * _Point;
if (isBuy)
{
stopLoss = NormalizeDouble(price - 1.5 * atrPoints, _Digits);
takeProfit = NormalizeDouble(price + 2 * atrPoints, _Digits);
}
else
{
stopLoss = NormalizeDouble(price + 1.5 * atrPoints, _Digits);
takeProfit = NormalizeDouble(price - 2 * atrPoints, _Digits);
}
}
// Function to place a buy or sell order
bool PlaceOrder(ENUM_ORDER_TYPE orderType)
{
double price = (orderType == ORDER_TYPE_BUY) ? SymbolInfoDouble(SymbolName, SYMBOL_ASK) : SymbolInfoDouble(SymbolName, SYMBOL_BID);
double stopLoss, takeProfit;
}
// Expert initialization function
int OnInit()
{
if (!SymbolSelect(SymbolName, true))
{
Print("Symbol not found: ", SymbolName);
return INIT_FAILED;
}
}
// Expert deinitialization function
void OnDeinit(const int reason)
{
Print("EA deinitialized.");
}
// Expert tick function
void OnTick()
{
double fastMA = iMA(SymbolName, Timeframe, FastMAPeriod, 0, MODE_SMA, PRICE_CLOSE);
double slowMA = iMA(SymbolName, Timeframe, SlowMAPeriod, 0, MODE_SMA, PRICE_CLOSE);
double rsiValue = iRSI(SymbolName, Timeframe, RSIPeriod, PRICE_CLOSE);
atrValue = iATR(SymbolName, Timeframe, ATRPeriod);
}
Beta Was this translation helpful? Give feedback.
All reactions