Libraries: TradeAlgorithms

 

TradeAlgorithms:

Trade functions library designed for use in the code of scripts and Expert Advisors depending on a broker

Author: Nikolay Kositsin

 

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 ?

 

i've tried to put trailing stop using WPR or Parabolic, unfortunately still failed

would you mind to give an example how to put the trailing stops for frasmav2

thanks a lot 

 
Hello,  I tried to stop the multiple entries but it failed I think its because of the recount command,  any assistant on that please.
Reason: