my if condition in Mql4 is never established

my if condition in Mql4 is never established

Manage alerts

Loading saved threads...

Alex · External communityPost link
External question — Stack Overflow Stack Exchange Author: Alex Original post: https://stackoverflow.com/questions/66143994 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. in the below code if(sma5_after > sma18_after) never is true while this condition is repeated many times in the chart I use Mql4 in meta trader4 void OnTick() { if(iVolume(_Symbol,_Period,0)<=1) { sma5_befor = iMA(_Symbol,_Period,5,0,MODE_SMA,PRICE_CLOSE,2); sma5_after = iMA(_Symbol,_Period,5,0,MODE_SMA,PRICE_CLOSE,0); ... sma18_befor = iMA(_Symbol,_Period,18,0,MODE_SMA,PRICE_CLOSE,2); sma18_after = iMA(_Symbol,_Period,5,0,MODE_SMA,PRICE_CLOSE,0); ... sma5_slop = (sma5_after - sma5_befor) / Point; ... if(sma5_after > sma18_after){ // this condition never is true in meta trader4 tester!! WHY? Print("OK"); } } } Please Help Me thank you
Quote
Report
Enivid · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Enivid Original post: https://stackoverflow.com/a/66315735 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. You have a typo in sma18_after assignment. This line: sma18_after = iMA(_Symbol,_Period,5,0,MODE_SMA,PRICE_CLOSE,0); should be this: sma18_after = iMA(_Symbol,_Period,18,0,MODE_SMA,PRICE_CLOSE,0);
Quote
Report

Post Reply

Checking account access…