Scripts: Drag and Drop Move StopLoss

 

Drag and Drop Move StopLoss:

Set StopLoss by just dragging and dropping script on the desired price level.

Author: Chioma Obunadike

 
Automated-Trading:

Drag and Drop Move StopLoss:

Author: Chioma Obunadike

does it work for multiple positions running on same pair?

If No, can you make it happen?

 
Ugochukwu Nwoko #:

does it work for multiple positions running on same pair?

If No, can you make it happen?

I think it does. Ha ha ha. Never tired but sure I can make it happen :)
 
Ugochukwu Nwoko #:does it work for multiple positions running on same pair? If No, can you make it happen?

Before asking, why not experiment with it and find out?

That is what "demo" accounts are for — to experimente and to learn by "doing"!

 
This script has a bug and this bug is quite annoying and inconvenient. As follows: - I opened a buy order for BTCUSD and a buy order for ETHUSD at the same time. - Then, I dropped this script on the ETHUSD chart to set a stop loss, and it immediately set the stop loss for both the ETHUSD buy order and the BTCUSD buy order at the same value. This error also exists in the script: Move TakeProfit.mq5 at this link: https://www.mql5.com/en/code/46313. When I dropped this script on the BTCUSD chart to set takeprofit, it immediately set takeprofit for both the BTCUSD buy order and the ETHUSD buy order at the same value. Can you fix this error in both scripts: Move StopLoss.mq5 and Move TakeProfit.mq5? ​
 

Fixed to only do current chart, and do SL and TP, and only of open orders


//+------------------------------------------------------------------+
//|                                                Move StopLoss.mq5 |
//|                                  Copyright 2023,Obunadike Chioma |
//|                                           https://t.me/devbidden |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023,Obunadike Chioma"
#property link      "https://t.me/devbidden"
#property version   "1.00"
#include  <Trade/Trade.mqh>
CTrade trade;
CPositionInfo  m_position;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   double Price = ChartPriceOnDropped();
   if(Price > 0)
      for(int i = PositionsTotal() - 1; i >= 0; i--) // loop all Open Positions
         if(m_position.SelectByIndex(i))  // select a position
           {   
              if(m_position.Symbol()==ChartSymbol())
              {
               if(Price<SymbolInfoDouble(Symbol(),SYMBOL_BID)&&m_position.PositionType()==POSITION_TYPE_BUY)trade.PositionModify(m_position.Ticket(),Price,m_position.TakeProfit());
               if(Price>SymbolInfoDouble(Symbol(),SYMBOL_ASK)&&m_position.PositionType()==POSITION_TYPE_SELL)trade.PositionModify(m_position.Ticket(),Price,m_position.TakeProfit());
               
               if(Price>SymbolInfoDouble(Symbol(),SYMBOL_BID)&&m_position.PositionType()==POSITION_TYPE_BUY)trade.PositionModify(m_position.Ticket(),m_position.StopLoss(),Price);
               if(Price<SymbolInfoDouble(Symbol(),SYMBOL_ASK)&&m_position.PositionType()==POSITION_TYPE_SELL)trade.PositionModify(m_position.Ticket(),m_position.StopLoss(),Price);
               
              }
              
           }
}
//+------------------------------------------------------------------+
  
 
Ryan Ross #:

Fixed to only do current chart, and do SL and TP, and only of open orders


Yh. That should work. Thanks 
 
Working great. It moves ALL Open Position SL. Do you have script that effect open position PLUS pending orders?