I have a JS code like this
function Entry(){
var Trigger = setInterval(function () {
var ent = EntryZone(); //EntryZone is a function which returns a value that change in every second
if (Value <= ent) { // Value is a variable
clearInterval(Trigger);
var TakeEntry = setInterval(function () {
var chkPer = Percentage(); //Percentage() is a function which returns a value that change in every second
if (Value >= chkPer) { //Here I am comparing Value with chkPer
var interval = setInterval(function(){
if (Value >= chkPer){ //Here I want to compare Vlaue again with chkPer after 10 seconds. If it has still the same or grater value then proceeding further.
BuyNow();
clearInterval(TakeEntry);
}
clearInterval(interval);
},10000);
}
}, 500);
}
}, 500);
}
Ok, so that is what I am trying to do. But as I run the script its messing up. The Middle part where I want to check the value again after 10 seconds is executing multiple time. I just want to execute it once. And if the value is not same after 10 seconds then clear the "interval" interval and go back and continue "TakeEntry" interval. Please guide me what is wrong with the code. Thank you!