Regarding:
//| Trade algorithms for brokers who offer nonzero spread and | //| and stops setting after opening a position!
in your code where you setup the request to modify a Buy . . .
bool BuyPositionModify . . . //---- initializing structure of the MqlTradeRequest to open BUY position request.type = ORDER_TYPE_BUY; request.price = Ask; request.action = TRADE_ACTION_SLTP; request.symbol = symbol; //---- Determine distance to Stop Loss (in price chart units) if(StopLoss) { if(!StopCorrect(symbol,StopLoss))return(false); double dStopLoss=StopLoss*point; request.sl=NormalizeDouble(request.price-dStopLoss,digit); if(request.sl<PositionGetDouble(POSITION_SL)) request.sl=PositionGetDouble(POSITION_SL); } else request.sl=PositionGetDouble(POSITION_SL); //---- Determine distance to Take Profit (in price chart units) if(Takeprofit) { if(!StopCorrect(symbol,Takeprofit))return(false); double dTakeprofit=Takeprofit*point; request.tp=NormalizeDouble(request.price+dTakeprofit,digit); if(request.tp<PositionGetDouble(POSITION_TP)) request.tp=PositionGetDouble(POSITION_TP); } else request.tp=PositionGetDouble(POSITION_TP);
you set the type, price, action, symbol, sl and tp. The documentation states that only the action, symbol, tp and sl are required, why do you also setup type and price ? have you found that the documentation is incorrect ?
Hello, I tried to stop the multiple entries but it failed I think its because of the recount command, any assistant on that please.
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
TradeAlgorithms:
Author: Nikolay Kositsin