Why am I getting a mass of errors in my nested || statement?

Why am I getting a mass of errors in my nested || statement?

Manage alerts

Loading saved threads...

user15861095 · External communityPost link
External question — Stack Overflow Stack Exchange Author: user15861095 Original post: https://stackoverflow.com/questions/68098810 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Right, why am I getting a mass of errors in my nested || operator when there is no reason behind this? Below is the code and the screenshot. Thank you. Error Log Screenshot if(BarTime != Time[0]) { if(hammerHeadClose < hammerHeadOpen){ if (bearHammerHead >= Transform(candleBodyLength,2)) if (bearHammerHandle!=0 && (bearHammerHead / bearHammerHandle) <= hammerHandlePct) if (bullRetracementCandle!=0 && (bearHammerHead / bullRetracementCandle) <= hammerHeadPct) } else if (hammerHeadClose > hammerHeadOpen){ if (bearHammerHead >= Transform(candleBodyLength,2)) if (bearHammerHandle!=0 && (bearHammerHead / bearHammerHandle) <= hammerHandlePct) if (bullRetracementCandle!=0 && (bearHammerHead / bullRetracementCandle) <= hammerHeadPct) } if (bearHammerHead >= Transform(candleBodyLength,2)) if (bearHammerHandle!=0 && (bearHammerHead / bearHammerHandle) <= hammerHandlePct) if (bullRetracementCandle!=0 && (bearHammerHead / bullRetracementCandle) <= hammerHeadPct) if (bullRetracementCandle!=0 && (initialTrendBearCandle / bullRetracementCandle) <= retracePercentage) if (bullRetracementCandle >= Transform(candleBodyLength,2)) if (iMA(NULL,0,Period_TrendFast,0, AM_TrendFast,PRICE_CLOSE,1) < iMA(NULL,0,Period_TrendSlow,0,AM_TrendSlow,PRICE_CLOSE,1)) if (iMA(NULL,0,Period_MomentumFast,0,AM_MomentumFast,PRICE_CLOSE,1) < iMA(NULL,0,Period_MomentumSlow,0,AM_MomentumSlow,PRICE_CLOSE,1)) if (NewBar) if (spread <= MaxSpread) if (hourOfDay >= startingHour && hourOfDay < endingHour) if (OrdersTotal()== 0) { OrderSend(....); } }
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange Author: PaulB Original post: https://stackoverflow.com/a/68118828 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. It is difficult to know what you are trying to achieve with the code posted. Generally, if statements use the following rules: if(Condition) // Header of the operator and condition { Block 1 of operators // If the condition is true, then.. composing body 1 //..the operators composing body 1 are executed } Your code has lots of conditions without anything to execute. For example: if(hammerHeadClose < hammerHeadOpen) { if(bearHammerHead >= Transform(candleBodyLength,2)) if(bearHammerHandle!=0 && (bearHammerHead / bearHammerHandle) <= hammerHandlePct) if(bullRetracementCandle!=0 && (bearHammerHead / bullRetracementCandle) <= hammerHeadPct) } This code does not actually do anything. You have nested if statements, but your final if statement needs to execute something, like so: if(hammerHeadClose < hammerHeadOpen) { if(bearHammerHead >= Transform(candleBodyLength,2)) if(bearHammerHandle!=0 && (bearHammerHead / bearHammerHandle) <= hammerHandlePct) if(bullRetracementCandle!=0 && (bearHammerHead / bullRetracementCandle) <= hammerHeadPct) { /* Code to execute if previous 3 if statements conditions are met */ } } Your final block of 11 nested if statement would result in OrderSend() if all conditions were true, it is your first set of if-else which do not make sense. Hopefully this explanation will help.
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: PaulB Source score (net votes, not local likes): 1 Original post: https://stackoverflow.com/a/68118828 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. It is difficult to know what you are trying to achieve with the code posted. Generally, if statements use the following rules: if(Condition) // Header of the operator and condition { Block 1 of operators // If the condition is true, then.. composing body 1 //..the operators composing body 1 are executed } Your code has lots of conditions without anything to execute. For example: if(hammerHeadClose < hammerHeadOpen) { if(bearHammerHead >= Transform(candleBodyLength,2)) if(bearHammerHandle!=0 && (bearHammerHead / bearHammerHandle) <= hammerHandlePct) if(bullRetracementCandle!=0 && (bearHammerHead / bullRetracementCandle) <= hammerHeadPct) } This code does not actually do anything. You have nested if statements, but your final if statement needs to execute something, like so: if(hammerHeadClose < hammerHeadOpen) { if(bearHammerHead >= Transform(candleBodyLength,2)) if(bearHammerHandle!=0 && (bearHammerHead / bearHammerHandle) <= hammerHandlePct) if(bullRetracementCandle!=0 && (bearHammerHead / bullRetracementCandle) <= hammerHeadPct) { /* Code to execute if previous 3 if statements conditions are met */ } } Your final block of 11 nested if statement would result in OrderSend() if all conditions were true, it is your first set of if-else which do not make sense. Hopefully this explanation will help.

Cancel quote

Checking account access…