• Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)

Looping Code High & Low Mql4

rickyandreas290292

New Member
Credits
0
void OnTick() {
// Looping high prices
// Loop from 1 to 6
for (int i = 1; i <= 6; i++) {
double highestPrice = High;

// Loop to find the highest price for the current range
for (int j = i - 1; j >= 0; j--) {
if (High[j] > highestPrice) {
highestPrice = High[j];
}
}

// Print the highest price for the current range
Print("Highest price for Range 1-6, Bar ", i, ": ", highestPrice);
}

// Loop from 6 to 34
for (int i = 6; i <= 34; i++) {
double highestPrice = High;

// Loop to find the highest price for the current range
for (int j = i - 1; j >= i - 5; j--) {
if (High[j] > highestPrice) {
highestPrice = High[j];
}
}

// Print the highest price for the current range
Print("Highest price for Range 6-34, Bar ", i, ": ", highestPrice);
}

// Looping low prices
// Loop from 1 to 6
for (int i = 1; i <= 6; i++) {
double lowestPrice = Low;

// Loop to find the lowest price for the current range
for (int j = i - 1; j >= 0; j--) {
if (Low[j] < lowestPrice) {
lowestPrice = Low[j];
}
}

// Print the lowest price for the current range
Print("Lowest price for Range 1-6, Bar ", i, ": ", lowestPrice);
}

// Loop from 6 to 34
for (int i = 6; i <= 34; i++) {
double lowestPrice = Low;

// Loop to find the lowest price for the current range
for (int j = i - 1; j >= i - 5; j--) {
if (Low[j] < lowestPrice) {
lowestPrice = Low[j];
}
}

// Print the lowest price for the current range
Print("Lowest price for Range 6-34, Bar ", i, ": ", lowestPrice);
}
}
 
Back
Top