Hi, what do you want to do after detected profit or loss position? send emai? save info to file, journal? for what do you need this info. Regards Greg
Greg Pawlak:
Hi, what do you want to do after detected profit or loss position? send emai? save info to file, journal? for what do you need this info. Regards Greg
Hi, what do you want to do after detected profit or loss position? send emai? save info to file, journal? for what do you need this info. Regards Greg
My immediate goal is only to detect profit or loss position.
Hi, your statement show you profit and loss position. Regards Greg
@Greg Pawlak
Could you explain how exactly to do ?
Thanks
DeltaElectronics:
@Greg Pawlak
Could you explain how exactly to do ?
Thanks
double pprofit = PositionGetDouble(POSITION_PROFIT);
here are some other examples of information you can get about a position:
#define xPOSITION_COMMENT (PositionGetString(POSITION_COMMENT)) #define xPOSITION_SYMBOL (PositionGetString(POSITION_SYMBOL)) #define xPOSITION_EXTERNAL_ID (PositionGetString(POSITION_EXTERNAL_ID)) #define xPOSITION_TYPE (PositionGetInteger(POSITION_TYPE)) #define xPOSITION_MAGIC (PositionGetInteger(POSITION_MAGIC)) #define xPOSITION_OPENTIME (PositionGetInteger(POSITION_TIME)) #define xPOSITION_TICKET (PositionGetInteger(POSITION_TICKET)) #define xPOSITION_IDENTIFIER (PositionGetInteger(POSITION_IDENTIFIER)) #define xPOSITION_PRICE_OPEN (PositionGetDouble(POSITION_PRICE_OPEN)) #define xPOSITION_PRICE_CURRENT (PositionGetDouble(POSITION_PRICE_CURRENT)) #define xPOSITION_PROFIT (PositionGetDouble(POSITION_PROFIT)) #define xPOSITION_PROFIT_LIQUID (PositionGetDouble(POSITION_PROFIT)+PositionGetDouble(POSITION_SWAP)) #define xPOSITION_SL (PositionGetDouble(POSITION_SL)) #define xPOSITION_TP (PositionGetDouble(POSITION_TP)) #define xPOSITION_SWAP (PositionGetDouble(POSITION_SWAP)) #define xPOSITION_VOLUME (PositionGetDouble(POSITION_VOLUME)) #define xPOSITION_ELAPSEDTIME (TimeCurrent()-PositionGetInteger(POSITION_TIME)) #define xPOSITION_TYPE_STRING ((PositionGetInteger(POSITION_TYPE)) ? "Sell" : "Buy ") #define xPOSITION_TICKVALUE (SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE)) #define xPOSITION_SPREAD (SymbolInfoInteger(_Symbol,SYMBOL_SPREAD)) #define xMARKET_PIPVALUE (SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE))
First select any position with:
PositionGetTicket(i);
Then you have access to every info about it using my definitions above.
// --- if (xPOSITION_TYPE == POSITION_TYPE_SELL) { ProftInPoints = (int)NormalizeDouble( xPOSITION_PRICE_OPEN/_Point - xPOSITION_PRICE_CURRENT/_Point ,0); } else if (xPOSITION_TYPE == POSITION_TYPE_BUY) { ProftInPoints = (int)NormalizeDouble( xPOSITION_PRICE_CURRENT/_Point - xPOSITION_PRICE_OPEN/_Point ,0); } double profit_money = xPOSITION_PROFIT; double profit_points = ProftInPoints; double position_lots = xPOSITION_VOLUME; // etc.. etc etc..

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello to everybody,
My goal is to write an EA which react in a particular way once I close a specified deal; i.e. suppose I have just closed a specified deal by the following code
where the index 'i' refers to the selected openend position
Then I want in my OnTradeTransaction(const MqlTradeTransaction& trans, const MqlTradeRequest& request, const MqlTradeResult& result) detect the deal just closed in order, for example, to detect the gain or the loss.
Advanced thank to everybody will help me.