When compiling this code i get an error in line 96 (the last line of code) saying that "lotSize" is not declared. I dont understand as i have declared this variable just above. Also, i get no error message in the similar code i use above to enter long positions.. Can someone see what im doing wrong?
- How do I define a variable as the moving average OF another indicator?
- Nested if statements
- What is wrong in the for loop declaration ?
-
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.
Great, thanks for the inputs. Problem Solved;)
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.

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