Please use this to post code . . . it makes it easier to read.
Please use this to post code . . . it makes it easier to read.
No problem
No problem
Are your Brokers the same ? I suspect not, are they both ECN Brokers ? what about the spread ? do they have similar spreads for the pairs you are both testing on ? or are you testing on different pairs ?
Our brokers are the same. When we attach it to the same pairs. It works perfectly on my end, and it gives bogus orders on his end.
for instance.
buy stop 110.974 sl 110.474 tp 111.974
GJ
sell stop 1.648 sl 2.148 tp 0.648
the sell stop orders are bogus. but on my laptop everything is fine. how is this possible?
Perhaps it's an issue with the EA parameters ?
Have you tried exporting your settings (you can do it from the EA Properties) and sending them to your friend to be imported ?
Perhaps it's an issue with the EA parameters ?
Have you tried exporting your settings (you can do it from the EA Properties) and sending them to your friend to be imported ?
There are only two parameters. start is a variable integer input which is the time of the server that coincides with the london open. Both enter 10 since we use fxPro and there server is GMT+2.
the other parameter is an integer for the percentage of risk. so I would enter 15 if I want to risk 15%
I am collecting a high and low for a previous period and I want to place an OCO using the high as the pending "buy" price and the low as the pending "sell" price. This works perfectly fine on my laptop
using it on 5 different instruments. It works perfectly and executes as planned in the strategy tester. I send it to my friend, and it places correct buy stop orders but the sell stop orders are bogus when he attaches the EA to several different charts in a live demo account. Can someone give me a clue how can one code work perfectly on my end but screw up half the orders on his end and place half the orders correctly.
- The Mql4 model does not support OCO. You're going to have to loop and count open orders and then delete the pending.
- EA's must adjust for 4/5 digit brokers, TP, SL, AND slippage
//++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double 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
- On ECN brokers you must open first and THEN set stops.
- The Mql4 model does not support OCO. You're going to have to loop and count open orders and then delete the pending.
- EA's must adjust for 4/5 digit brokers, TP, SL, AND slippage
- On ECN brokers you must open first and THEN set stops.
I used this code to calculate the percentage I want to risk
RiskAmount = AccountEquity()*(EquityPercent / 100); TickValue = MarketInfo(Symbol(),MODE_TICKVALUE); if(Point == 0.001 || Point == 0.00001)TickValue *= 10; CalcLots = (RiskAmount/StopLoss) / TickValue; LotSize = CalcLots;
My straddle code is
if(ordersetGU == false) { PendingPriceGU = highGU; SLGU = highGU - (StopLoss*PipPoint(Symbol())); TPGU = highGU + (TakeProfit*PipPoint(Symbol())); TicketGU = OpenBuyStopOrder(Symbol(), LotSize, PendingPriceGU, SLGU, TPGU, Slippage, MagicNumber,0, "Buy Stop Order"); PendingPriceGUs = lowGU; SLGUs = lowGU + (StopLoss*PipPoint(Symbol())); TPGUs = lowGU - (TakeProfit*PipPoint(Symbol())); TicketGUs = OpenSellStopOrder(Symbol(), LotSize, PendingPriceGUs, SLGUs, TPGUs, Slippage, MagicNumber,0, "Sell Stop Order"); ordersetGU = true; OCOsetGU = true; } if(OrderSelect(TicketGU,SELECT_BY_TICKET)&&(OP_BUY == OrderType() )&&(OCOsetGU == true) )//delete order for OCO of GBPUSD { OrderDelete(TicketGUs,Red); } else if(OrderSelect(TicketGUs,SELECT_BY_TICKET)&&(OP_SELL == OrderType() )&&(OCOsetGU == true) ) { OrderDelete(TicketGU,Green); }
I used these functions for the code
int GetSlippage(string Currency, int SlippagePips) { int CalcDigits = MarketInfo(Currency,MODE_DIGITS); if(CalcDigits == 2 || CalcDigits == 4) double CalcSlippage = SlippagePips; else if(CalcDigits == 3 || CalcDigits == 5) CalcSlippage = SlippagePips * 10; return(CalcSlippage); } //******************************PIP point FUNC****************************************** double PipPoint(string Currency) { int CalcDigits = MarketInfo(Currency,MODE_DIGITS); if(CalcDigits == 2 || CalcDigits == 3) double CalcPoint = 0.01; else if(CalcDigits == 4 || CalcDigits == 5) CalcPoint = 0.0001; return(CalcPoint); } //**************************************************************BUY sTop Order******************************************************* int OpenBuyStopOrder(string argSymbol, double argLotSize, double argPendingPrice, double argStopLoss, double argTakeProfit, double argSlippage, double argMagicNumber, datetime argExpiration = 0, string argComment = "Buy Stop Order") { while(IsTradeContextBusy()) Sleep(10); // Place Buy Stop Order int Ticket = OrderSend(argSymbol,OP_BUYSTOP,argLotSize,argPendingPrice,argSlippage,argStopLoss,argTakeProfit,argComment,argMagicNumber,argExpiration,Green); // Error Handling if(Ticket == -1) { int ErrorCode = GetLastError(); string ErrDesc = ErrorDescription(ErrorCode); string ErrAlert = StringConcatenate("Open Buy Stop Order - Error ",ErrorCode,": ",ErrDesc); Alert(ErrAlert); string ErrLog = StringConcatenate("Ask: ",MarketInfo(argSymbol,MODE_ASK)," Lots: ",argLotSize, " Price: ",argPendingPrice," Stop: ",argStopLoss," Profit: ",argTakeProfit," Expiration: ",TimeToStr(argExpiration)); Print(ErrLog); } return(Ticket); } //**********************************************************Sell Stop Order*************************************************** int OpenSellStopOrder(string argSymbol, double argLotSize, double argPendingPrice, double argStopLoss, double argTakeProfit, double argSlippage, double argMagicNumber, datetime argExpiration = 0, string argComment = "Sell Stop Order") { while(IsTradeContextBusy()) Sleep(10); // Place Sell Stop Order int Ticket = OrderSend(argSymbol,OP_SELLSTOP,argLotSize,argPendingPrice,argSlippage,argStopLoss,argTakeProfit,argComment,argMagicNumber,argExpiration,Red); // Error Handling if(Ticket == -1) { int ErrorCode = GetLastError(); string ErrDesc = ErrorDescription(ErrorCode); string ErrAlert = StringConcatenate("Open Sell Stop Order - Error ",ErrorCode,": ",ErrDesc); Alert(ErrAlert); string ErrLog = StringConcatenate("Bid: ",MarketInfo(argSymbol,MODE_BID)," Lots: ",argLotSize, " Price: ",argPendingPrice," Stop: ",argStopLoss," Profit: ",argTakeProfit," Expiration: ",TimeToStr(argExpiration)); Print(ErrLog); } return(Ticket); } AM i MISSING ANYTHING IMPORTANT TO PLACE THE ORDERS?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am collecting a high and low for a previous period and I want to place an OCO using the high as the pending "buy" price and the low as the pending "sell" price. This works perfectly fine on my laptop
using it on 5 different instruments. It works perfectly and executes as planned in the strategy tester. I send it to my friend, and it places correct buy stop orders but the sell stop orders are bogus when he attaches the EA to several different charts in a live demo account. Can someone give me a clue how can one code work perfectly on my end but screw up half the orders on his end and place half the orders correctly.
I use these functions for the orders