Discussion of article "How to Create Your Own Trailing Stop" - page 6

 
None of the posted codes doesn't open trades, giving errors 2021.02.08 23:43:23.200 my_first_ea_sartrailing (ES,M1) Alert: Request to set Buy order failed - error code:4756 At the same time the request for prices seems to be actual 2021.02.08 23:43:23.200 my_first_ea_sartrailing (ES,M1) Alert: action= 1price= 3900.88sl= 3900.58tp= 3901.88volume= 0.1magic= 12345type= 0type_filling= 0deviation= 1000


 
Thanks, great article very detailed.
 

Look like this is a dead discussion but I will put my comments in.


There are a couple of errors found during compiling that need to be resolved.

In the ZeroMemory request on line 116  the compiler says

         'ZeroMemory' - unexpected toke, probably type is mission?

         'mrequest' - declaration without type

This looks like the mrequest was not properly declared with a type......Not sure how to fix this.


Also,


       return value of "OrderSend" should be checked.   on line215 and 262


This looks like it might be returning a value it should not.


Any help in fixing these two issues would be most appreciated.

Chris

 

Really want to understand what is written in the comments ?

class CTrailingStop{

protected:
string m_symbol; // symbology
ENUM_TIMEFRAMES m_timeframe; // timeframe
bool m_eachtick; // work on each tick
bool m_indicator; // show the indicator on the graph
bool m_button; // show on/off button
int m_button_x; // button's koridinate x
int m_button_y; // button's y coordinate
colour m_bgcolor; // button colour
colour m_txtcolor; // button caption colour
int m_shift; // bool m_shift; // bool shifting
bool m_onoff; // switch on/off
int m_handle; // indicator's chíldel
datetime m_lasttime; // time of the last execution of the trailing stop
MqlTradeRequest m_request; // the structure of the trade request
MqlTradeResult m_result; // structure of the result of a trade request
int m_digits; // number of digits after the decimal point of the price
double m_point; // point value
string m_objname; // button name
string m_typename; // name of the type of trail stop
string m_caption; // button caption
 
Very rewarding read, thanks!
 
Hi folks, I changed OrderSend for the Trade object, much easier. Also the event is executed every second, there is no need for such a fast frequency. I changed it to every 60 seconds and it improves drastically the performance.
 
Rustam Ayupov #:

Really want to understand what the comments say ?

protected:
string m_symbol;             // symbol
ENUM_TIMEFRAMES m_timeframe; // timeframe
bool m_eachtick;             // run on every tick
bool m_indicator;            // show the indicator on the chart
bool m_button;               // show on/off button
int m_button_x;              // button's x-coordinate
int m_button_y;              // the coordinate of the button
color m_bgcolor;             // button colour
color m_txtcolor;            // button caption colour
int m_shift;                 // bar offset
bool m_onoff;                // on/off
int m_handle;                // indicator handle
datetime m_lasttime;         // time of the last trailing stop execution
MqlTradeRequest m_request;   // trade request structure
MqlTradeResult m_result;     // structure of the trade request result
int m_digits;                // the number of decimal places of the price
double m_point;              // item value
string m_objname;            // button name
string m_typename;           // trailing stop type name
string m_caption;            // button inscription

Regards, Vladimir.