python:Change open position Stop Loss and Take Profit by python code

 



I tried to change stop loss of open position with one of the above two methods. In both print(results) show that it has changed, but nothing has happened in my account. Can anyone help?

 
Majid Palar:



I tried to change stop loss of open position with one of the above two methods. In both print(results) show that it has changed, but nothing has happened in my account. Can anyone help?

I was able to solve the problem. Here's the answer. Maybe someone else has the same problem

 
Hello fellows am tempted to ask if Python that executes at run time is really a good idea for Forex automations?
 
Malcolm Okechukwu:
Hello fellows am tempted to ask if Python that executes at run time is really a good idea for Forex automations?

Yes. The runtime execution time is irrelevant compared to the latency of a "retail" platform.


If you need true HFT then you need to use specialized hardware that is colocated with the liquidity provider's servers. Your stack would be something like specialized linux kernel -> highly optimized C algo -> FIX/Currenex. You'd also have a massive bankroll and be considered a commercial trader. 

 
Majid Palar:

I was able to solve the problem. Here's the answer. Maybe someone else has the same problem

Trade order to modify the StopLoss and/or TakeProfit price levels. It requires to specify the following 4 fields:

  • action
  • symbol
  • sl
  • tp
  • position
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Interaction between the client terminal and a trade server for executing the order placing operation is performed by using trade requests. The trade request is represented by the special predefined structure of MqlTradeRequest type, which contain all the fields necessary to perform trade deals. The request processing result is represented by...
 
Malcolm Okechukwu:
Hello fellows am tempted to ask if Python that executes at run time is really a good idea for Forex automations?
I couldn't communicate well with mql but Python? It's wonderful. It works well. The hardware system must be good. It would be great if you could use the deep learning system
 
nicholi shen:

Trade order to modify the StopLoss and/or TakeProfit price levels. It requires to specify the following 4 fields:

  • action
  • symbol
  • sl
  • tp
  • position
Thank you very much for your guidance
 
Majid Palar:

I was able to solve the problem. Here's the answer. Maybe someone else has the same problem

Hey Majid, I still can't use this approach.

Do someone have another example using it please??


Thanks

 
Pedro Lealdino Filho #:

Hey Majid, I still can't use this approach.

Do someone have another example using it please??


Thanks

Hi, my name is Sydney Nhamo, i found out why we were facing this problem.

When you execute a trade for the first time note that STOP_LOSS is always equal to for example 500 points difference from price but now you want to modify a stop loss.

So 500 points +/- current_price = e.g. 138.500 == OUR STOP_LOSS

The hack here is that you put price for a STOP_LOSS, NOT POINTS.

So the new request will be:

request = { 'action': mt5.TRADE_ACTION_SLTP, 'position': position.ticket, 'sl': 139.000, } Now you will be finally on to something