What is (in your understanding) a "transaction"? It:
- deal ENTER THE MARKET
- deal EXIT THE MARKET
What is (in your understanding) a "transaction"? It:
- deal ENTER THE MARKET
- deal EXIT THE MARKET
yes.
What "yes"? Give an exact answer - there are TWO options in my question.
i am referring a position.
Example:
ATTENTION: Stop Loss and Take Profit prices are NOT NORMALIZED!!!
//+------------------------------------------------------------------+ //| Reverse the last position.mq5 | //| Copyright © 2021, Vladimir Karputov | //+------------------------------------------------------------------+ #property copyright "Copyright © 2021, Vladimir Karputov" #property version "1.000" //--- #include <Trade\PositionInfo.mqh> #include <Trade\Trade.mqh> //--- CPositionInfo m_position; // object of CPositionInfo class CTrade m_trade; // object of CTrade class //--- ENUM_POSITION_TYPE m_last_positions = WRONG_VALUE; // last position type //--- input parameters input int Input1=9; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- forced initialization of variables m_last_positions = WRONG_VALUE; // last position type //--- initialize the generator of random numbers MathSrand(GetTickCount()); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- MqlTick tick; if(!SymbolInfoTick(Symbol(),tick)) return; //--- check if a position is present and display the time of its changing if(!PositionSelect(Symbol())) { if(m_last_positions==WRONG_VALUE) { int math_rand=MathRand(); if(math_rand<32767/2) { Comment("Start BUY ..."); m_trade.Buy(1,Symbol(),tick.ask,tick.ask-1.0,tick.ask+1.0, ""); } else { Comment("Start SELL ..."); m_trade.Sell(1,Symbol(),tick.bid,tick.bid+1.0,tick.bid-1.0, ""); } } else { if(m_last_positions==POSITION_TYPE_BUY) { } else { } } } else { //--- receive position type m_last_positions=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE); } } //+------------------------------------------------------------------+
thank you sir, is exactly what i was looking for.
Good afternoon, what happened to my account <...> with an initial investment of <...>?
Because it is indicated as "NOT VALID" until 1.6.2021 it was visible!
You can answer me on my email <...> as not knowing English I can use an online translator from Google.
I am worried and do not understand what happened to the sums paid.
I look forward to your verification and a reply email.
I speak only Italian....
Thank you. <...>
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I need help in this code below, I want this expert advisor to sell if the last trade was of buy and buy if the last trade was of sale.