Experts: Return Strategy

 

Return Strategy:

Working with pending Buy Limit and Sell Limit orders. Grid of pending orders.

Return Strategy

Author: Vladimir Karputov

 
Alexander Kamyshanov:
Hi, how to make instead of pending order lifetime its constant movement behind the price by a certain number of pips from the price once in minutes?

First: you need to run the text of the question at least through Word - this action will correct the text and add punctuation marks in the right places ...

 

Version 1.001 - fixed LotsOrRisk function

You can download from Return Strategy :

 

Hi Vladimir,
Thanks for the correction.

Can we say that the total profit function (in points) does not have the same functionality as the target profit or minimum profit?

 
Edviao:

Hi Vladimir,
Thanks for the correction.

Can we say that the total profit function (in points) does not have the same functionality as the target profit or minimum profit?

The question is not clear: there is no'target profit' and'minimum profit' in the EA.


How to look for answers: take the input parameter 'Total profit (in pips)' - see which variable is responsible for it:

input ushort   InpTotalProfit    = 100;      // Total profit (in pips)


... look for the first occurrence of 'InpTotalProfit'.

   ExtTotalProfit    = InpTotalProfit  * m_adjusted_point;


... now look for the first occurrence of'ExtTotalProfit' ...

//---
   if(CalculateTotalProfit()>=ExtTotalProfit)
     {
      bln_close_all=true;
      return;
     }


... it remains to study the 'CalculateTotalProfit()' function ...

 
Thanks for the homework, which I'll be working on this weekend, Vladimir!
 

Good afternoon!

What can be the reason for the message in the log during testing? The settings of the Expert Advisor are taken by default.

2021.10.30 10:20:44.968 2021.01.11 10:57:26   Code of request result: 10022
2021.10.30 10:20:44.968 2021.01.11 10:57:26   code of request result as a string: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Deal ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Order ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Volume of deal or order: 0.00
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Price, confirmed by broker: 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current bid price: 1.21783 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current ask price: 1.21795 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Broker comment: 
2021.10.30 10:20:44.968 2021.01.11 10:57:26   CTrade::OrderOpen: Invalid expiration type
2021.10.30 10:20:44.968 2021.01.11 10:57:26   #3  Buy Limit (0) -> false. Result Retcode: 10022, description of result: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Code of request result: 10022
2021.10.30 10:20:44.968 2021.01.11 10:57:26   code of request result as a string: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Deal ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Order ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Volume of deal or order: 0.00
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Price, confirmed by broker: 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current bid price: 1.21782 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current ask price: 1.21794 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Broker comment: 
2021.10.30 10:20:44.968 2021.01.11 10:57:26   CTrade::OrderOpen: Invalid expiration type
2021.10.30 10:20:44.968 2021.01.11 10:57:26   #3  Buy Limit (1) -> false. Result Retcode: 10022, description of result: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Code of request result: 10022
2021.10.30 10:20:44.968 2021.01.11 10:57:26   code of request result as a string: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Deal ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Order ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Volume of deal or order: 0.00
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Price, confirmed by broker: 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current bid price: 1.21782 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current ask price: 1.21794 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Broker comment: 
2021.10.30 10:20:44.968 2021.01.11 10:57:26   CTrade::OrderOpen: Invalid expiration type
2021.10.30 10:20:44.968 2021.01.11 10:57:26   #3  Buy Limit (2) -> false. Result Retcode: 10022, description of result: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Code of request result: 10022
2021.10.30 10:20:44.968 2021.01.11 10:57:26   code of request result as a string: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Deal ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Order ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Volume of deal or order: 0.00
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Price, confirmed by broker: 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current bid price: 1.21782 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current ask price: 1.21794 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Broker comment: 
2021.10.30 10:20:44.968 2021.01.11 10:57:26   CTrade::OrderOpen: Invalid expiration type
2021.10.30 10:20:44.968 2021.01.11 10:57:26   #3  Buy Limit (3) -> false. Result Retcode: 10022, description of result: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Code of request result: 10022
2021.10.30 10:20:44.968 2021.01.11 10:57:26   code of request result as a string: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Deal ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Order ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Volume of deal or order: 0.00
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Price, confirmed by broker: 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current bid price: 1.21782 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current ask price: 1.21794 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Broker comment: 
2021.10.30 10:20:44.968 2021.01.11 10:57:26   CTrade::OrderOpen: Invalid expiration type
2021.10.30 10:20:44.968 2021.01.11 10:57:26   #3  Sell Limit (0) -> false. Result Retcode: 10022, description of result: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Code of request result: 10022
2021.10.30 10:20:44.968 2021.01.11 10:57:26   code of request result as a string: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Deal ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Order ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Volume of deal or order: 0.00
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Price, confirmed by broker: 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current bid price: 1.21782 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Current ask price: 1.21794 (the requote): 0.00000
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Broker comment: 
2021.10.30 10:20:44.968 2021.01.11 10:57:26   CTrade::OrderOpen: Invalid expiration type
2021.10.30 10:20:44.968 2021.01.11 10:57:26   #3  Sell Limit (1) -> false. Result Retcode: 10022, description of result: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Code of request result: 10022
2021.10.30 10:20:44.968 2021.01.11 10:57:26   code of request result as a string: invalid expiration
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Deal ticket: 0
2021.10.30 10:20:44.968 2021.01.11 10:57:26   Order ticket: 0
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Volume of deal or order: 0.00
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Price, confirmed by broker: 0.00000
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Current bid price: 1.21782 (the requote): 0.00000
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Current ask price: 1.21794 (the requote): 0.00000
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Broker comment: 
2021.10.30 10:20:44.969 2021.01.11 10:57:26   CTrade::OrderOpen: Invalid expiration type
2021.10.30 10:20:44.969 2021.01.11 10:57:26   #3  Sell Limit (2) -> false. Result Retcode: 10022, description of result: invalid expiration
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Code of request result: 10022
2021.10.30 10:20:44.969 2021.01.11 10:57:26   code of request result as a string: invalid expiration
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Deal ticket: 0
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Order ticket: 0
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Volume of deal or order: 0.00
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Price, confirmed by broker: 0.00000
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Current bid price: 1.21782 (the requote): 0.00000
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Current ask price: 1.21794 (the requote): 0.00000
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Broker comment: 
2021.10.30 10:20:44.969 2021.01.11 10:57:26   CTrade::OrderOpen: Invalid expiration type
2021.10.30 10:20:44.969 2021.01.11 10:57:26   #3  Sell Limit (3) -> false. Result Retcode: 10022, description of result: invalid expiration
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Code of request result: 10022
2021.10.30 10:20:44.969 2021.01.11 10:57:26   code of request result as a string: invalid expiration
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Deal ticket: 0
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Order ticket: 0
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Volume of deal or order: 0.00
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Price, confirmed by broker: 0.00000
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Current bid price: 1.21782 (the requote): 0.00000
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Current ask price: 1.21794 (the requote): 0.00000
2021.10.30 10:20:44.969 2021.01.11 10:57:26   Broker comment: 

Regards, Vladimir.

 
Indicates that'ORDER_TIME_SPECIFIED' is not supported.
 
Vladimir Karputov 'ORDER_TIME_SPECIFIED' is not supported.

I am embarrassed to ask - not supported by whom or by what?

Regards, Vladimir.

 
MrBrooklin #:

I'm embarrassed to ask - not supported by whom or what?

With respect, Vladimir.

The trading server. Are you probably not testing on Forex?

 
Vladimir Karputov #:

A trading server. Are you probably not testing on forex?

I'm testing in the terminal of my forex-dealer. I will try to update the build.

Regards, Vladimir.