#include <Trade\Trade.mqh>
double lowerBound , upperBound;
bool IsPriceInZone(double openPrice,int zoneWidth)
{
// Calculate the lower and upper bounds of the zone
lowerBound = openPrice - zoneWidth;
upperBound = openPrice + zoneWidth;
double CurrentPrice = SymbolInfoDouble(_Symbol,SYMBOL_BID);
// Check if the current price is in the zone
if (CurrentPrice >= lowerBound || CurrentPrice <= upperBound) {
return true;
} else {
return false;
}
}
void OnTick(){
// Check if the current price is in a zone of points around the open price of the candle
double OpenPrice =iOpen(_Symbol,PERIOD_CURRENT,0);
bool isInZone = IsPriceInZone(OpenPrice, 10);
// Print a message if the current price is in the zone
if (isInZone) {
Print("The current price is in the zone");
} else {
Print("The current price is not in the zone");
}
}
- Help me fix this code pls
- Trailing price bot
- EA error
kekeli doe:
#include <Trade\Trade.mqh>
double lowerBound , upperBound;
bool IsPriceInZone(double openPrice,int zoneWidth)
{
// Calculate the lower and upper bounds of the zone
lowerBound = openPrice - zoneWidth;
upperBound = openPrice + zoneWidth;
double CurrentPrice = SymbolInfoDouble(_Symbol,SYMBOL_BID);
// Check if the current price is in the zone
if (CurrentPrice >= lowerBound || CurrentPrice <= upperBound) {
return true;
} else {
return false;
}
}
void OnTick(){
// Check if the current price is in a zone of points around the open price of the candle
double OpenPrice =iOpen(_Symbol,PERIOD_CURRENT,0);
bool isInZone = IsPriceInZone(OpenPrice, 10);
// Print a message if the current price is in the zone
if (isInZone) {
Print("The current price is in the zone");
} else {
Print("The current price is not in the zone");
}
}
this must be an and
if (CurrentPrice >= lowerBound && CurrentPrice <= upperBound) {
-
Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
Forum rules and recommendations - General - MQL5 programming forum (2023)
Messages Editor Your code if (CurrentPrice >= lowerBound && CurrentPrice <= upperBound) { return true; } else { return false; }
Simplified. return CurrentPrice >= lowerBound && CurrentPrice <= upperBound;

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register