So I created my EA, and Now No compile Errors exist anymore, but the Problem is, it doesnt Take any trades..
Let me summarize the Logic fast
So, there is a Candle Time variable.
The High and Low of the Candle will be used as Zone and then we wait for a Candle breakout, with the specified min. ATR Settings and SMA Settings.
And Entry on Close, so the Candle needs to Close above/under the Zone for a Buy/sell and it's Rest of Body or Wick should Touch the Zone. (I will send some Pictures to clarify the logic)
Also spreads Settings, is to make TP smaller and SL wider, so you dont get Wicked Out/dont reach your tp..
And thats how SL works:
If it's a buy, SL will be the Low of that Candle that we used in the Settings (Here 10:00)
And If it's a sell, it will be the high of that candle
ofcourse because of spreads Settings, it will get wider (Here 2 Pips)
And Im also Not Understanding how to Programm the Max Orders code
//Define parametersinputstring candleTime = "10:00";
Input int maxOrders = 1;
inputint tpPips = 200;
inputint magicNumber = 282518;
inputdouble lots = 0.01;
inputint atrPeriod = 14;
inputdouble minAtrLevel = 1.00;
inputint smaPeriod = 200;
inputint bePoints = 100;
inputint trailStartPoints = 110;
inputint trailStepPoints = 50;
inputint trailStopPoints = 300;
inputint spreadPips = 2;
// Global variablesdouble zoneHigh, zoneLow;
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
// Add any initialization code herereturn(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
// Check if it's the specified candle timeif (TimeHour(TimeCurrent()) == StringToInteger(StringSubstr(candleTime, 0, 2)) &&
TimeMinute(TimeCurrent()) == StringToInteger(StringSubstr(candleTime, 3, 2)))
{
zoneHigh = High[1];
zoneLow = Low[1];
// Check if the ATR level meets the criteriadouble atrValue = iATR(_Symbol, 0, atrPeriod);
if (atrValue >= minAtrLevel * Point)
{
// Check for buy conditionif (Close[1] > zoneHigh && Close[1] > iMA(_Symbol, 0, smaPeriod, 0, MODE_SMA, PRICE_CLOSE, 0))
{
// Buy logicdouble entryPriceBuy = Ask;
double slPriceBuy = zoneLow - spreadPips * Point;
double tpPriceBuy = entryPriceBuy + tpPips * Point - spreadPips * Point;
ModifyOrder(entryPriceBuy, slPriceBuy, tpPriceBuy);
}
// Check for sell conditionelseif (Close[1] < zoneLow && Close[1] < iMA(_Symbol, 0, smaPeriod, 0, MODE_SMA, PRICE_CLOSE, 0))
{
// Sell logicdouble entryPriceSell = Bid;
double slPriceSell = zoneHigh + spreadPips * Point;
double tpPriceSell = entryPriceSell - tpPips * Point + spreadPips * Point;
ModifyOrder(entryPriceSell, slPriceSell, tpPriceSell);
}
}
}
}
// Function to modify ordervoid ModifyOrder(double entryPrice, double slPrice, double tpPrice)
{
// Apply spread adjustment
slPrice += spreadPips * Point;
tpPrice -= spreadPips * Point;
int ticket = OrderSend(_Symbol, OP_BUY, lots, entryPrice, 3, slPrice, tpPrice, "Buy Order", magicNumber, 0, Blue);
// Check if the order is opened successfullyif (ticket > 0)
{
Print("Order opened successfully. Ticket: ", ticket);
}
else
{
Print("Error opening order. Error code: ", GetLastError());
}
}
//+------------------------------------------------------------------+
I tried to ask chatgpt But litterally gave me the Code lightly updated with many comments..
Didnt Help me, thats why I want to ask you Guys, so you hopefully can Help me fixing it.
// Define parametersinputstring candleTime = "10:00";
inputint tpPips = 200;
inputint magicNumber = 282518;
inputdouble lots = 0.01;
inputint atrPeriod = 14;
inputdouble minAtrLevel = 1.00;
inputint smaPeriod = 200;
inputint bePoints = 100;
inputint trailStartPoints = 110;
inputint trailStepPoints = 50;
inputint trailStopPoints = 300;
inputint spreadPips = 2;
// Global variablesdouble zoneHigh, zoneLow;
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
// Add any initialization code herereturn(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
// Check if it's the specified candle timeif (TimeHour(TimeCurrent()) == StringToInteger(StringSubstr(candleTime, 0, 2)) &&
TimeMinute(TimeCurrent()) == StringToInteger(StringSubstr(candleTime, 3, 2)))
{
zoneHigh = High[1];
zoneLow = Low[1];
// Check if the ATR level meets the criteriadouble atrValue = iATR(_Symbol, 0, atrPeriod);
if (atrValue >= minAtrLevel * Point)
{
// Check for buy conditionif (Close[1] > zoneHigh && Close[1] > iMA(_Symbol, 0, smaPeriod, 0, MODE_SMA, PRICE_CLOSE, 0))
{
// Buy logicdouble entryPriceBuy = Ask;
double slPriceBuy = zoneLow - spreadPips * Point;
double tpPriceBuy = entryPriceBuy + tpPips * Point - spreadPips * Point;
ModifyOrder(entryPriceBuy, slPriceBuy, tpPriceBuy);
}
// Check for sell conditionelseif (Close[1] < zoneLow && Close[1] < iMA(_Symbol, 0, smaPeriod, 0, MODE_SMA, PRICE_CLOSE, 0))
{
// Sell logicdouble entryPriceSell = Bid;
double slPriceSell = zoneHigh + spreadPips * Point;
double tpPriceSell = entryPriceSell - tpPips * Point + spreadPips * Point;
ModifyOrder(entryPriceSell, slPriceSell, tpPriceSell);
}
}
}
}
// Function to modify ordervoid ModifyOrder(double entryPrice, double slPrice, double tpPrice)
{
// Apply spread adjustment
slPrice += spreadPips * Point;
tpPrice -= spreadPips * Point;
int ticket = OrderSend(_Symbol, OP_BUY, lots, entryPrice, 3, slPrice, tpPrice, "Buy Order", magicNumber, 0, Blue);
// Check if the order is opened successfullyif (ticket > 0)
{
Print("Order opened successfully. Ticket: ", ticket);
}
else
{
Print("Error opening order. Error code: ", GetLastError());
}
}
//+------------------------------------------------------------------+
And Im also Not Understanding how to Programm the Max Orders code