Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Coin Flip - MetaTrader 5 Expert | Martin EA Download - MT4/MT5 Resources

author EAcpu | 3 reads | 0 comments |

Coin Flip - expert for MetaTrader 5

Coin Flip - expert for MetaTrader 5

Idea from : Vladimir Gribachev .

MQL5 code by : Vladimir Karputov .

An EA that does not use any custom indicators; positions are opened pseudo-randomly. The EA can display current statistics in two languages:

Coin Flip - expert for MetaTrader 5

Trailing modification of stop loss for open positions. If a loss occurs, use Martingale to increase the lot size. How to monitor losses: For online trading , we capture the transaction DEAL_REASON_SL - the signal that triggers the stop loss:

//+------------------------------------------------------------------+
//| TradeTransaction function |
//+------------------------------------------------------------------+
Blank OnlineTrade ( const MqlTrade transaction & trans,
Constant Mql Transaction Requests & Requirements,
Constant Mql Transaction Result &Result)
  { //--- Get the transaction type as enumeration value ENUM_TRADE_TRANSACTION_TYPE type = trans.type; //--- If the transaction is the result of adding a historical transaction if (type == TRADE_TRANSACTION_DEAL_ADD )
    {
long deal_ticket = 0 ;
long deal_order = 0 ;
long deal_time = 0 ;
long deal_time_msc = 0 ;
long deal_type =- 1 ;
long deal_entry =- 1 ;
long deal_magic = 0 ;
long deal_reason =- 1 ;
long deal_position_id = 0 ;
Double volume = 0.0 ;
Double transaction price = 0.0 ;
Double trading commission = 0.0 ;
double deal_swap = 0.0 ;
Double deal_profit = 0.0 ;
string deal_symbol = ”” ;
string deal_comment = ”” ;
string deal_external_id = ”” ;
if ( Historical Transaction Select (Transaction))
        {
        deal_ticket = historical transaction acquisition integer (cross-transaction, DEAL_TICKET );
        deal_order = historical transaction acquisition integer (cross-transaction, transaction order );
        deal_time = historical transaction acquisition integer (cross-transaction, DEAL_TIME );
        deal_time_msc = historical transaction acquisition integer (cross-transaction, DEAL_TIME_MSC );
        deal_type = historical transaction acquisition integer (cross-transaction, transaction type );
        deal_entry = historical transaction acquisition integer (cross-transaction, DEAL_ENTRY );
        deal_magic = historical transaction acquisition integer (cross-transaction, DEAL_MAGIC );
        Transaction reason = historical transaction get integer (cross-transaction, DEAL_REASON );
        deal_position_id = Historical transaction acquisition integer (cross-transaction, DEAL_POSITION_ID );

        Transaction volume = historical transactions get double (cross transaction, transaction volume );
        Transaction Price = Historical Transaction Get Double (Cross Transaction, DEAL_PRICE );
        Transaction commission = double historical transactions (cross-transaction, DEAL_COMMISSION );
        deal_swap = historical transactions get double (cross-transaction, transaction-swap );
        deal_profit = get double the historical transaction (cross transaction, transaction profit );

        deal_symbol = historical transaction acquisition string (cross-transaction, DEAL_SYMBOL );
        deal_comment = historical transaction acquisition string (cross-transaction, DEAL_COMMENT );
        deal_external_id = Historical transaction acquisition string (cross-transaction, transaction external ID );
        }
Othersan> return ; if (deal_symbol==m_symbol.Name() && deal_magic==m_magic) if (transaction entry == DEAL_ENTRY_OUT ) { previous item = 0 ; if ( transaction reason == DEAL_REASON_SL && trading commission + trading swap + trading profit < 0.0 ) last_lots_sl = trading volume; other last lot size sl = 0.0 ; } } }


Then the test was interrupted (the EA was forcibly unloaded from the chart) because the reference lot exceeded the maximum lot size range:

Coin Flip - expert for MetaTrader 5


Attachment download

📎 coin_flip.mq5 (67.45 KB)

Source: MQL5 #20836

Verification code Refresh