Some general recommendations as far as your coding style, which may help you find issues a little easier if they pop up. Learn to use indenting, and format your code a little better for others to read. Also, it is a good habit to get into to put all of your comments of what a specific line does either just before the line, or on the same line after the code, not a mix of before the code in some places and after it in others. Also, meaningful names are helpful, it is good to see you are making use of them, for the most part.
if(Buy_opened) { Alert("We already have a Buy Position!!!"); return; } ZeroMemory(mrequest); mrequest.action = TRADE_ACTION_DEAL; // mrequest.price = NormalizeDouble(latest_price.ask, _Digits); // latest ask price mrequest.sl = NormalizeDouble(latest_price.ask - STP* _Point,_Digits); // Stop Loss mrequest.tp = NormalizeDouble(latest_price.ask + TKP* _Point,_Digits); // Take Profit // you can code like this below // currency pair mrequest.symbol = _Symbol; // number of lots to trade mrequest.volume = Lot; // Order Magic Number mrequest.magic = EA_Magic; // Buy Order mrequest.type = ORDER_TYPE_BUY; // Order execution type mrequest.type_filling = ORDER_FILLING_FOK; // Deviation from current price mrequest.deviation=100; //or like the following example mrequest.symbol = _Symbol; // currency pair mrequest.volume = Lot; // number of lots to trade mrequest.magic = EA_Magic; // Order Magic Number mrequest.type = ORDER_TYPE_BUY; // Buy Order mrequest.type_filling = ORDER_FILLING_FOK; // Order execution type mrequest.deviation = 100; // Deviation from current price //--- send order OrderSend(mrequest,mresult); // get the result code if(mresult.retcode==10009 || mresult.retcode==10008) //Request is completed or order placed { Alert( "A Buy order has been successfully placed with Ticket#:", mresult.order,"!!"); } else { Alert( "The Buy order request could not be completed -error:", GetLastError()); ResetLastError(); return; }
Bluebee:
Do you get an error ? What is in the log ?
Hi can anyone tell me why my stochastic code wont open any trades and how I can fix it :-/ many thanks
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
Hi can anyone tell me why my stochastic code wont open any trades and how I can fix it :-/ many thanks