3 EMA and 2 LWMA
disregard the "&& EMA1 && " in >>>((LWMA1 > LWMA2 && EMA1 && preLWMA1 <= preLWMA2 )> EMA3 . that was a typo while pasting it into forum
prodi:
can any one help with this code im trying to have it enter a trade when the 2 LWMA cross and the #3Ema confirms the trend, but it doesnt enter when the 2 LWMA cross, can someone pin point what i did wroung???
can any one help with this code im trying to have it enter a trade when the 2 LWMA cross and the #3Ema confirms the trend, but it doesnt enter when the 2 LWMA cross, can someone pin point what i did wroung???
for ( i = 0; i < OrdersTotal(); i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() )
Always test return codesfor ( i = 0; i < OrdersTotal(); i++) if( OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() ){
if(OrderComment() == "Order 1") ThereIsOrder1 = true;
Brokers can change comments, partially or completelyif(!ThereIsOrder1 && ThereIsOrder2 && ThereIsOrder3 && ThereIsOrder4)Do you meanif((!ThereIsOrder1) && ThereIsOrder2 && ThereIsOrder3 && ThereIsOrder4) or if(!(ThereIsOrder1 && ThereIsOrder2 && ThereIsOrder3 && ThereIsOrder4))
Don't rely on precedence, don't mix and's, or's and not'sif (NewBar && ((currPos <= 0 && EMA1 > EMA2 && EMA1 > EMA3 && (preEMA1 <= preEMA2 || preEMA1 <= preEMA3) && val > 0 && CheckTime()) || ((LWMA1 > LWMA2 && EMA1 && preLWMA1 <= preLWMA2 )> EMA3 && val > 0 && !ThereIsOrder1 && !ThereIsOrder2 && !ThereIsOrder3 && !ThereIsOrder4)) )
That statement, besides being utterly unreadable, Will NOT COMPILE [(bool && EMA1 && bool) > EMA3] or if it does is gibberish [apples > oranges]
Split into readable peices, print the values so you can find out WHY.
bool EmaIsUp = EMA1 > EMA2 && EMA1 > EMA3, EmaWasPrevNot = preEMA1 <= preEMA2 || preEMA1 <= preEMA3, EmaIsBuy = EmaIsUp && EmaWasPrevNot, LwmaIsUp = LwmaWasNot= if (NewBar && CheckTime() && EmaIsBuy && LwmaIsBuy && val > 0...
can any one help with this code im trying to have it enter a trade when the 2 LWMA cross and the #3Ema confirms the trend, but it doesnt enter when the 2 LWMA cross, can someone pin point what i did wroung???