View Full Version : Mql4 Coding Help
Csarlenne
01-29-2009, 09:09 AM
Hello Men
I've a problem with a code.
I would love to understand how to perform a routine whenever a candle transcend a MM, only 1 time, and the order can not be repeated until next crossing.
Code example:
Inserted Code int limit=1; dual MMA; for (int change =1; shiftlt;=limitation; change ) MMA=iMA(NULL,timeFrame,FastEMA,0,MODE_EMA,PRICE_CL OSE,change ); //-- sell states if (MMAgt;Ask 0.0010) SellValue=1; split; //-- buy conditions if (MMAlt;Ask - 0.0010) BuyValue=1; break;
The code above repeat the order for several times after make profit and before the next line cross.
I need the orders it can open not surpass 1 order per cross. Or a limitation variable (N orders).
So, If someone could assist, I would be grateful.
Thanks Beforehand.
Csarlenne
11-17-2021, 08:46 PM
Milhouse, thanks!
I made the changes but still repeating orders each new candle before the following cross.
Another sugestion?
Cheers.
eRRe88
11-17-2021, 10:07 PM
Inserted Code int limit=1; dual MMA, MMA1; for (int shift=1; shiftlt;=limitation; shift ) MMA=iMA(NULL,timeFrame,FastEMA,0,MODE_EMA,PRICE_CL OSE,shift); MMA1=iMA(NULL,timeFrame,FastEMA,0,MODE_EMA,PRICE_C LOSE,shift 1); //-- market conditions if (MMAgt;Ask 0.0010 MMA1lt;Close#91;shift 1#93;-RRB- SellValue=1; split; //-- buy conditions if (MMAlt;Ask - 0.0010 MMA1gt;Close#91;shift 1#93;-RRB- BuyValue# 1; break;
Try this signal. You need to check whether MMA of preceding candle has been lower or higher compared to price. When it's just like current candle, then no cross happened on current candle.
Csarlenne
11-17-2021, 11:28 PM
Quaestus, thanks.
The code worked nicely. Actually the orders are repeated, but just when the trend is on the ideal side, even prior to the next intersection. Not well understood the logic, however I'll do more tests later and article here.
Grateful for your small help!
eRRe88
11-18-2021, 12:49 AM
There are few possible reasons why multiple orders are placed. Are orders only repeated on the exact same candle? Or can your EA also buy and sell on candles after the cross?
Csarlenne
11-18-2021, 02:10 AM
Hello quaestus,
I did a few backtests, but unfortunately the saying did not do the job right. I tried several alternatives.
The EA relies on this 's generic EA Ma crossover:
https://www.forexsoutheast.asia/crypto-trading/538-idea-programmer.html
Within This post has a better excuse:
https://www.forexsoutheast.asia/crypto-trading/376-set-2-ea-pair.html
eRRe88
11-18-2021, 03:30 AM
Upload the EA file with the changes that you've done and I will take a look at it https://www.forexsoutheast.asia/attachments/1527469837.png
Lauracivilctt
11-18-2021, 04:51 AM
Can someone Allow Me to know how to do the next,
I want to retrieve the value of a 40sma on the near of the 4-00am (UK time) candle and also the same value at the close of the 6-15am candle
can anyone provide the code to Get This Particular
thank you
MinaCivarius
11-18-2021, 06:12 AM
Can someone let me know how to Perform the following,
I want to retrieve the value of a 40sma on the near of the 4-00am (UK time) candle and also the same value at the End of the 6-15am candle
can anyone provide the code to Get This Particular
thank you you Can Attempt this
Inserted Code if (Hour() = 4 Minute() = Stage ()) Dual maval1 = iMA(... parameters...,1) if (Hour() = 6 Minute() = 15 Stage ()) Dual maval2 = iMA(... parameters...,1) the use of period() depends upon the timeframe you're using, the above case is to Get timeframes below h1
sepkxnari
11-18-2021, 07:33 AM
Though the above code may function it's a bit of a kludge.
Try using the iHour and iMinute and define PERIOD_M1 at the time framework. Read about them in the help file.
Regards
Lux
seda90
11-18-2021, 08:53 AM
Just use ibarshift...
cokalcosol93
11-18-2021, 10:14 AM
Sir
anybody help me the way to write a code for weekly and monthly available. In advance thanks.
jttepri
11-18-2021, 11:35 AM
The easies would be to have a boolean, although there are better ways for this.
On Your init() you want TradeOK=True;
Then, as Soon as You make a trade you want to use TradeOK=false;
Eventually, You Have to alter the If statement to if((MMAgt;Ask 0.0010) (TradeOK=True))
Powered by forexsoutheast.asia® Version 4.2.5 Copyright © 2023 forexsoutheast.asia Solutions, Inc. All rights reserved.