How to add close_above_open for a buy indicator in MQL4?
How to add close_above_open for a buy indicator in MQL4?
Loading saved threads...
Krishna · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Krishna
Original post: https://stackoverflow.com/questions/70580526
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Is that possible to add a
close_above_open
condition too in the pattern of
iHigh() && iClose() && iLow()
?
I.e. I would like to add the
close_above_open
in the below code. Can you help me to know the method?
const int timePeriodD1=PERIOD_D1;
if(iHigh(symbol,timePeriodD1,1)>iHigh(symbol,timePeriodD1,2) && iClose(symbol,timePeriodD1,1) >iClose(symbol,timePeriodD1,2) &&
iLow(symbol,timePeriodD1,1)>iLow(symbol,timePeriodD1,2)){
//ObjectSetText(d1label,"UP",11, "Verdana", Aqua);
d1result="UP";
}else if(iHigh(symbol,timePeriodD1,1)<iHigh(symbol,timePeriodD1,2) && iClose(symbol,timePeriodD1,1) < iClose(symbol,timePeriodD1,2) &&
iLow(symbol,timePeriodD1,1)< iLow(symbol,timePeriodD1,2)){
//ObjectSetText(d1label,"DOWN",11, "Verdana", Yellow);
d1result="DOWN";
}else{
//ObjectSetText(d1label,"MIXED",11, "Verdana", White);
d1result="MIXED";
}
Simply asking is there any way to write as below:
if(iHigh(symbol,timePeriodD1,1)>iHigh(symbol,timePeriodD1,2) && iClose(symbol,timePeriodD1,1) >iClose(symbol,timePeriodD1,2) &&
iLow(symbol,timePeriodD1,1)>iLow(symbol,timePeriodD1,2) &&
CloseAboveOpen(symbol,timePeriodD1,1)>CloseAboveOpen(symbol,timePeriodD1,2)
Quote
Report
user3666197 · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: user3666197
Original post: https://stackoverflow.com/a/70602000
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Q1
:
Is that possible to add a close_above_open condition too in the pattern of iHigh() && iClose() && iLow()?
Yes, it is:
...
if ( iHigh( symbol, timePeriodD1, 1 ) > iHigh( symbol, timePeriodD1, 2 )
&& iClose( symbol, timePeriodD1, 1 ) > iClose( symbol, timePeriodD1, 2 )
&& iLow( symbol, timePeriodD1, 1 ) > iLow( symbol, timePeriodD1, 2 )
&& CloseAboveOpen( symbol, timePeriodD1, 1 ) > CloseAboveOpen( symbol, timePeriodD1, 2 )
){ ... }
...
Q2
:
Simply asking is there any way to write it as below...?
Yes, there is.
May try to customize this template to match your further needs:
int CloseAboveOpen( string aSymbolNAME, /// [DOC-me] Ret-s {+|-}n-pts above Open
int aTimeFRAME,
int nOffsetBARs ) {
return( (int)( ( iClose( aSymbolNAME, aTimeFRAME, nOffsetBARs )
- iOpen( aSymbolNAME, aTimeFRAME, nOffsetBARs )
)
* MathPow( 10, (int)MarketInfo( aSymbolNAME, MODE_DIGITS ) )
)
);
}
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: user3666197 Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/a/70602000 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Q1 : Is that possible to add a close_above_open condition too in the pattern of iHigh() && iClose() && iLow()? Yes, it is: ... if ( iHigh( symbol, timePeriodD1, 1 ) > iHigh( symbol, timePeriodD1, 2 ) && iClose( symbol, timePeriodD1, 1 ) > iClose( symbol, timePeriodD1, 2 ) && iLow( symbol, timePeriodD1, 1 ) > iLow( symbol, timePeriodD1, 2 ) && CloseAboveOpen( symbol, timePeriodD1, 1 ) > CloseAboveOpen( symbol, timePeriodD1, 2 ) ){ ... } ... Q2 : Simply asking is there any way to write it as below...? Yes, there is. May try to customize this template to match your further needs: int CloseAboveOpen( string aSymbolNAME, /// [DOC-me] Ret-s {+|-}n-pts above Open int aTimeFRAME, int nOffsetBARs ) { return( (int)( ( iClose( aSymbolNAME, aTimeFRAME, nOffsetBARs ) - iOpen( aSymbolNAME, aTimeFRAME, nOffsetBARs ) ) * MathPow( 10, (int)MarketInfo( aSymbolNAME, MODE_DIGITS ) ) ) ); }
Checking account access…