Command to await signal

 

I have the command to check for the desired signal. Problem is, it will trade off the last signal as soon as the EA starts. I want it to wait for the next signal to open positions. Any ideas what to code and where to place it? Any helpers please?


<SNIP>

 
Please edit your post
patrick007:

I have the command to check for the desired signal. Problem is, it will trade off the last signal as soon as the EA starts. I want it to wait for the next signal to open positions. Any ideas what to code and where to place it? Any helpers please?


<SNIP>

Please edit your post . . .


Please use this to post code . . . it makes it easier to read.

 
Add a bool as a latch, set it on the first signal then check it on the next signal . .
 

  1. For large amounts of code, attach it
    Yours
    if (countOfFastEMATrades() < maxTrades && lastTrade != Time[0]) {
        double ema10 = iMA(Symbol(), 0, 10, 0, MODE_EMA, PRICE_CLOSE, 1);
        double ema25 = iMA(Symbol(), 0, 25, 0, MODE_EMA, PRICE_CLOSE, 1);
        double ema50 = iMA(Symbol(), 0, 50, 0, MODE_EMA, PRICE_CLOSE, 1);
        if (ema10 < ema25 && ema25 < ema50) {
            OrderSend(Symbol(), OP_SELL, lotSize, Bid,3,0,0,"Forex 01 Fast EMA Sell");
            lastTrade = Time[0];
            return;
        } else if (ema10 > ema25 && ema25 > ema50) {
            OrderSend(Symbol(), OP_BUY, lotSize, Ask,3,0,0,"Forex 01 Fast EMA Buy");
            lastTrade = Time[0];
            return;
    }
    Try
    bool canTrade = countOfFastEMATrades() < maxTrades && lastTrade != Time[0])
    double ema10 = iMA(Symbol(), 0, 10, 0, MODE_EMA, PRICE_CLOSE, 1);
    double ema25 = iMA(Symbol(), 0, 25, 0, MODE_EMA, PRICE_CLOSE, 1);
    double ema50 = iMA(Symbol(), 0, 50, 0, MODE_EMA, PRICE_CLOSE, 1);
    bool buyTrade = ema10 < ema25 && ema25 < ema50;
    bool sellTrade = ema10 > ema25 && ema25 > ema50
    
    static bool  buySigCurr = true,     bool  buySigPrev = buySigCurr;  
    static bool sellSigCurr = true;     bool sellSigPrev = sellSigPrev; 
     buySigCurr = canTrade && buyTrade;
    sellSigCurr = canTrade && sellTrade;
    if (buySigCurr && !buySigPrev){
        OrderSend(Symbol(), OP_SELL, lotSize, Bid,3,0,0,"Forex 01 Fast EMA Sell");
        lastTrade = Time[0];
        return;
    } else if (sellSigCurr && !sellSigPrev) {
        OrderSend(Symbol(), OP_BUY, lotSize, Ask,3,0,0,"Forex 01 Fast EMA Buy");
        lastTrade = Time[0];
        return;
    }
    

  2. What are Function return values ? How do I use them ? - MQL4 forum
  3. Not adjusting for 4/5 digit brokers (slippage)
 
WHRoeder:

  1. For large amounts of code, attach it
    Yours
    Try

  2. What are Function return values ? How do I use them ? - MQL4 forum
  3. Not adjusting for 4/5 digit brokers (slippage)

Thanks for reply. When compiling lots of errors.
 
RaptorUK:
Please edit your postPlease edit your post . . .


Please use this to post code . . . it makes it easier to read.


RaptorUK:
Please edit your postPlease edit your post . . .


Please use this to post code . . . it makes it easier to read.


Is this any easier?
Files:
edit.mq4  1 kb
 
patrick007:


Is this any easier?
No, please edit your first post above.
 
RaptorUK:
No, please edit your first post above.


Thanks. Not sure what you are implying. Instead of copying and pasting, I have attached it as you specified on the second reply.
 
patrick007:

Thanks. Not sure what you are implying. Instead of copying and pasting, I have attached it as you specified on the second reply.
Perhaps you are referring to WHRoeder's post ?
 
RaptorUK:
Perhaps you are referring to WHRoeder's post ?


I think we are talking in riddles here! Anyhow, the code WHRoeder sent has 18 errors. Are you able to offer any help? Even if it has 17 errors it would be a step forward!
 

Hi patrick007,

How's sponge bob 008 ?

Since you using different period, checking crossing will cost much work to do.

Whether its first attached or not and no opened position, then you have to scan back at least one bar to see if trade condition is true, if its true and trading condition for current bar is also true then don't open position. If trade condition for last bar is false and true for current bar then open position.

Reason: