What type of "help" are u expecting?
gordon:
What type of "help" are u expecting?
What type of "help" are u expecting?
i wrote a code that if
iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,1)>20)
it should place a sell order,but i discovered that it also places sell orders even when the value of stochastics main indicator on the previous bar is below 20
please what could be wrong?
jmorgan:
[...] please what could be wrong?
Post your code.
[...] please what could be wrong?
iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,1)>20)
means above 20
iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,1)>20)
means the previous bar
double stoch1=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,0); double stocha1=iStochastic(NULL,0,14,3,3,MODE_SMA,0,MODE_MAIN,2); double stoch2=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0); double stocha2=iStochastic(NULL,0,14,3,3,MODE_SMA,0,MODE_SIGNAL,2);
stoch1 always equals stoch2
stocha1 always equals stocha2
if(wert1!=EMPTY_VALUE && wert1>wert2)signal=1; if(wert3!=EMPTY_VALUE && wert3<wert4)signal=2; if(traden==1 && signal==1 && OrderAngaben[2]<=0 && ma1>ma2 && macd1>macd2 && val1>val2 && ((STOCH1>STOCH2 && STOCHA1<=STOCHA2 && Close[0]<High[1]) || (STOCH1<=STOCH2 && stoch1>stoch2 && High[0]>=High[1])) && Low[0]>Low[1] && Open[1]<Close[1] && STOCH1<80)
I suggest you simplify and self document your logic, so you can understand what you wrote. If it doesn't make sense when you write it out, your logic is wrong.
bool buying = (wert1!=EMPTY_VALUE && wert1>wert2), openOrders = OrderAngaben[2] > 0, maRising = ma1 > ma2, macdRising = macd1 > macd2, stochCross = (STOCH1>STOCH2 && STOCHA1<=STOCHA2), higherHigh = High[0] >= High[1], higherLow = Low[0] > Low[1], upCandle = Close[1] >= Open[1]; if(traden==1 && buying && (!openOrders) && maRising && macdRising && val1>val2 && (stochCross || (STOCH1<=STOCH2 && stoch1>stoch2 && higherHigh)) && higherLow && upCandle
- Your time begin/end could be simple
int DOW = TimeDayOfWeek(now), /* https://www.mql5.com/en/forum/127483 // reports DayOfWeek() always returns 5 in the tester. No refresh?*/ DayMask = 1 << DOW; // #define DAYS_MAX 0x3F // 1<<6-1=63. (S-F) //extern int Days.Mask = 55; // Not Wed if (Days.Mask & DayMask == 0){ EA.status="Day="+DOW; return(0); } //extern double TradeHr.UTC.Start = 7.3; // London-1 //extern double TradeHr.UTC.End = 12.9; // NY open int secStart = 3600*TradeHr.UTC.Start, secEnd = 3600*TradeHr.UTC.End, hrBeg = (now-secStart+86400)%86400, hrEnd = (now-secEnd +86400)%86400; if (hrBeg > hrEnd){ EA.status="HR"+DoubleToStr(hrBeg/3600.-24,2); return(0); }
if(Digits==2)geteiltdurch=100.0; if(Digits==3)geteiltdurch=100.0; if(Digits==4)geteiltdurch=10000.0; if(Digits==5)geteiltdurch=10000.0;
EA's should adjust TP, SL, and slippage for 5 digit brokers://++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
for(int i=0; i <= OrdersTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) { if(OrderMagicNumber()==Magicnumber) {
OrderSelect(OrdersTotal()... is wrong. 0 .. OrdersTotal()-1. And remember if there are EAs on other pairs, you must always count down when modifying.
for(int i=OrdersTotal()-1 ; i >= 0; i--) if ( OrderSelect(i,SELECT_BY_POS) && OrderMagicNumber()==Magicnumber){
WHRoeder:
thanks a lot for the suggestions, i'm very grateful.
stoch1 always equals stoch2
stocha1 always equals stocha2
-
I suggest you simplify and self document your logic, so you can understand what you wrote. If it doesn't make sense when you write it out, your logic is wrong.
- Your time begin/end could be simple
-
EA's should adjust TP, SL, and slippage for 5 digit brokers:
-
OrderSelect(OrdersTotal()... is wrong. 0 .. OrdersTotal()-1. And remember if there are EAs on other pairs, you must always count down when modifying.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register