Dynamically Filled New Postiion Comments

 

Hi,

I'm new to coding EA's and would like to know if its possible to dynamically build a comment on a new position based on input parameters, such as Symbol, TimeFrame, Period etc.. anything I have predefined in input parameters.

 

The purpose so I can quickly identify what conditions were used to create a particular order, when using multiple conditions and EA's. 

CExpertTrade::Buy(double volume,double price,double sl,double tp,const string comment="Symbol, Timeframe, MA_Method, MA_Period etc....")

 Thanks for your help guys.

 
Andrew Hill: I'm new to coding EA's and would like to know if its possible to dynamically build a comment on a new position based on input parameters, such as Symbol, TimeFrame, Period etc.. anything I have predefined in input parameters.

The purpose so I can quickly identify what conditions were used to create a particular order, when using multiple conditions and EA's. 

CExpertTrade::Buy(double volume,double price,double sl,double tp,const string comment="Symbol, Timeframe, MA_Method, MA_Period etc....")

Don't rely on Order Comments as most Brokers will:

  • Limit their size and truncate their contents
  • Some brokers clear them completely
  • Some brokers replace the text partially or completely, especial when hitting a S/L or T/P

So, instead:

  • either keep a "virtual" track of your orders by associating the the ticket to a data structure or class object of the extra data (with optional saving to external file if necessary)
  • or bit-map the Magic number with a Major Part for EA identification and a Minor Part with bit-mapped (or enumerated) variations to identify different cases (my preferred method, because it gets saved to the trading server)
 
Fernando Carreiro:

Don't rely on Order Comments as most Brokers will:

  • Limit their size and truncate their contents
  • Some brokers clear them completely
  • Some brokers replace the text completely, especial when hitting a S/L or T/P

So, instead:

  • either keep a "virtual" track of your orders by associating the the ticket to a data structure or class object of the extra data (with optional saving to external file if necessary).
  • or bit-map the Magic number with a Major Part for EA identification and a Minor Part with bit-mapped variations to identify different cases.

Thanks for Fernando,

 I don't have any problems with initiated orders with my broker (alpari), in most cases my initiated EA order's with my pre-defined comments but I do understand what you mean as on the TP/SL orders are overridden with a price for example of exit. 

Keeping this in mind that I don't really care for the exits or SL/TP but only care for the comments on a new condition buy/sell is there any quick and dirty way to achieve this with dynamically calling the elements I require?

As you can imagine when working during the day I get new orders it would be nice to see on the mobile application what was activated, or is there a better way to achieve this with the use of Emails etc?

 

Thanks! 

 
Andrew Hill: ... but I do understand what you mean as on the TP/SL orders are overridden with a price for example of exit ...

... or is there a better way to achieve this with the use of Emails etc?

Some brokers replace or append to the Comment with either a "[tp]" or "[sl]" to show if the order hit either the TakeProfit or the StopLoss.

Yes, you can send push notifications to the Mobile App with messages of your own design with any info you wish as well as send emails.

 

Yes you can make or OrderSend() function do that:

OrderSend(Symbol(),OP_BUY,lots,Ask,Slippage,0,0,"Buy: "+Symbol()+" @ "+Input Parameter,MagicNumber,0,Blue); .......................for example.

Any string that you want permanently in there would be within " ", the use + to add your own input that would change dynamically.  The + is kind of like a "then add this" when used in this case.

 
Perfect
Christopher Fernandez Ledon:

Yes you can make or OrderSend() function do that:

OrderSend(Symbol(),OP_BUY,lots,Ask,Slippage,0,0,"Buy: "+Symbol()+" @ "+Input Parameter,MagicNumber,0,Blue); .......................for example.

Any string that you want permanently in there would be within " ", the use + to add your own input that would change dynamically.  The + is kind of like a "then add this" when used in this case.

Perfect thankyou! just what I am after, but maybe yes I need to look at Sned Push notifications in the future.

Thanks again!

 
Anytime...glad I could help. 
 
Oh...I forgot...you may have to convert stuff to string...easy enough for you to figure out.  The big thing is, what you want can easily be done.