help troubleshoot
- How do I define a variable as the moving average OF another indicator?
- What is wrong in the for loop declaration ?
- Questions from a "dummy"
-
else if(slowEMA > fastEMA && Bid < slowEMA && Open[1] > fastEMA ) double lotSize = OptimalLotSize(riskPerTrade,Bid,SLsell);
What do you think that one line does? Compare that to your buy code.
-
openOrderID = OrderSend(NULL,OP_BUYLIMIT,lotSize,Ask,10,SLbuy,TPbuy,NULL,magicNB);
Don't use NULL.- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not. OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
-
openOrderID = OrderSend(NULL,OP_BUYLIMIT,lotSize,Ask,10,SLbuy,TPbuy,NULL,magicNB); ⋮ openOrderID = OrderSend(NULL,OP_SELLLIMIT,lotSize,Bid,10,SLsell,TPsell,NULL,magicNB);
You can't move stops (or pending prices) closer to the market than the minimum: MODE_STOPLEVEL * _Point or SymbolInfoInteger(SYMBOL_TRADE_STOPS_LEVEL).
Requirements and Limitations in Making Trades - Appendixes - MQL4 TutorialOn some ECN type brokers the value might be zero (broker doesn't know.) Use a minimum of two (2) PIPs.
Don't do that. Someone searching might find this thread and still be clueless. What solved what?
How To Ask Questions The Smart Way. 2004
When You Ask.
Follow up with a brief note on the solution.