Having trouble making the EA perform an OrderSend() after checking multiple. However the commented out section of my sell position works to makes orders of the sell. I believe the largest part of my problem is in the MACD retracement requirement. I have not seen any other example that checks a few parameters, waits on an action to happen, then checks more parameters before making an order. Assistance would be appreciated.
Side note, I understand that I am use many, if not excessive, parenthesis. I use another program editor just to make sure those all line up.
Maybe one of these is not true, Print(), Comment() or Alert() them and find out . . .
if ((macdValues == true) && (adxValue2 == true) && (adxSpread2 == true))
By the way, Buy at Ask, Sell at Bid
- Add print statement before and inside your IFs so you find out why.
- Check your return values for FAILURE to find out why. What are Function return values ? How do I use them ? - MQL4 forum
RaptorUK and WHRoeder, thank you for your help. The Print() command has helped me figure out where most of my code was giving me trouble. I have opening and closing of positions.
However I still have trouble making the MACD retracement become true. I have commented out (whatever it is called when I add the // to the code to essentially blank it out) everything except the ADX before the MACD retracement and after the MACD to ensure no other code would be in the way. Here is my current attempt at the retracement. If this should be another thread inform me and it will be done. Assumed I could continue on the same thread since this is still the same EA.
So far I have gotten results as far as the Print() of "MACD went negative, wait for positive." And the timeNow, timeWait, timeFinish variables have already been declared in the same area of my code as the bools of adxValue1, adxSpread1, etc.
if( (iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0) > 0) && (adxValue1==true) && (adxSpread1==true)) {macdValue=true; Print("MACD retracement watch beginning."); timeNow = TimeCurrent(); timeWait = timeNow + 3600; //1hr I believe if(iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0) <= 0) { wentNeg=true; Print("MACD went negaitve, wait for positive."); } } //hang up at this point in the MACD retracement while(wentNeg==true) {if(iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0) >=0) { backPos = true; Print("MACD went back to positive."); timeFinish = TimeCurrent(); wentNeg=false; } } if((backPos==true) && (timeFinish<timeWait)) {macdRetraced=true; Print("MACD retracement watch is FINISHED."); }
while(MACDgoNEG == true) //from here watch the MACD go from negaitve back to positive { if (iMACD(NULL,PERIOD_M1,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0) > 0 )//went back to positive {macdRetraced = true;} else {macdRetraced = false;} }//whileThis is an infinite loop, nothing is changing. Return from start and wait for the next tick.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Having trouble making the EA perform an OrderSend() after checking multiple. However the commented out section of my sell position works to makes orders of the sell. I believe the largest part of my problem is in the MACD retracement requirement. I have not seen any other example that checks a few parameters, waits on an action to happen, then checks more parameters before making an order. Assistance would be appreciated.
Side note, I understand that I am use many, if not excessive, parenthesis. I use another program editor just to make sure those all line up.