CashMachine_5min

Author: Puncher Poland� 2008: bemowo@tlen.pl

CashMachine_5min Trading Strategy Description

The CashMachine_5min.mq4 script is designed for use with MetaTrader platforms, which are popular tools for trading financial markets like Forex. This strategy uses technical indicators to make buy or sell decisions based on certain conditions. Below is an explanation of the logic and components in non-technical terms:

Overview

The script aims to automate trade execution by opening buy or sell orders when specific market conditions are met, using two key technical indicators: DeMarker and Stochastic Oscillator.

Key Components

  1. Take Profit and Stop Loss:

    • These settings determine the target profit level and the maximum acceptable loss for a trade.
    • Take Profit: The script will close an order if the price reaches this level, ensuring profits are locked in.
    • Stop Loss: If the market moves against the position to this level, the order is closed to prevent further losses.
  2. Target Profits:

    • There are three target profit levels set within the strategy. Each serves as a checkpoint for securing partial profits before reaching the full take-profit target.
  3. Technical Indicators:

    • The strategy uses two indicators to make trading decisions: DeMarker and Stochastic Oscillator.

    DeMarker Indicator

    • This indicator helps identify overbought or oversold market conditions.
    • When the value is below a certain threshold, it suggests an oversold condition, which might be a good opportunity to buy.

    Stochastic Oscillator

    • This momentum indicator compares a particular closing price of an asset to its price range over a specific period.
    • A low value indicates an oversold condition, suggesting potential for buying, while a high value signals overbought conditions, indicating selling opportunities.

Trading Logic

Buying Conditions

  • The script looks for the following conditions to open a buy order:
    • DeMarker is below a certain level (indicating an oversold market).
    • Stochastic Oscillator is also low, reinforcing the signal of a potential upward trend.

Selling Conditions

  • Conversely, for opening a sell order, the script checks if:
    • DeMarker is above a certain threshold (indicating an overbought market).
    • Stochastic Oscillator is high, suggesting a potential downward movement.

Order Management

Once a trade is executed based on these conditions:

  • The strategy monitors ongoing trades to manage profits and losses.

For Buy Orders:

  • If the price reaches the take-profit level or falls to the stop-loss threshold, the position is closed.
  • As the price hits intermediate target levels (three predefined profit checkpoints), the script modifies the order to secure part of the gains.

For Sell Orders:

  • Similarly, for sell orders, if the price touches the take-profit or stop-loss limits, it closes the trade.
  • Intermediate targets are used to adjust the sell orders and lock in partial profits as the market moves favorably.

Conclusion

The CashMachine_5min.mq4 strategy uses a systematic approach based on technical indicators to automate trading decisions. By setting predefined profit and loss levels, it aims to manage risk while capturing potential gains from favorable market movements.

Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
Indicators Used
DeMarker indicatorStochastic oscillator
0 Views
0 Downloads
0 Favorites

Profitability Reports

GBP/USD Oct 2024 - Jan 2025
40.00 %
Total Trades 225
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -2.65
Gross Profit 403.60
Gross Loss -1000.80
Total Net Profit -597.20
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 1419
Won Trades 0
Lost trades 1419
Win Rate 0.00 %
Expected payoff -7.03
Gross Profit 0.00
Gross Loss -9972.00
Total Net Profit -9972.00
-100%
-50%
0%
50%
100%
CashMachine_5min
//+------------------------------------------------------------------+
//|                                             CashMachine_5min.mq4 |
//|                                             Puncher Poland© 2008 |
//|                                        http://www.terazpolska.pl |
//+------------------------------------------------------------------+
#property copyright "Puncher Poland© 2008: bemowo@tlen.pl"
#property link      "http://www.terazpolska.pl"

//---- Tu zakladasz zysk maks. i maks. strate
extern double hidden_TakeProfit = 60;
extern double hidden_StopLoss = 30;

extern double Lots = 0.2; // tu definiujesz wilekosc transakcji w lotach
extern double target_tp1 = 20; // tu definiujesz minimalny zakladny pierwszy próg zysku
extern double target_tp2 = 35; // drugi próg zysku
extern double target_tp3 = 50; // trzeci próg zysku

// wskaŸnik DeMarker
extern int pidem=0; //Indicator period
extern int pidemu=14; //Period of averaging for indicator calculation

// wskaŸnik Stochastic Oscillator
extern int pisto=0; //Indicator period
extern int pistok=5; //Period(amount of bars) for the calculation of %K line
extern int pistod=3; //Averaging period for the calculation of %D line
extern int istslow=3; //Value of slowdown

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
    int cnt, ticket, total;
//----
    if(Bars < 100)
      {
        Print("bars less than 100");
        return(0);  
      }
//----
    if(hidden_TakeProfit < 10)
      {
        Print("TakeProfit less than 10");
        return(0);  // check TakeProfit
      }
//----
    total  = OrdersTotal(); 
    if(total < 1) 
      {
        
            if(iDeMarker(NULL,pidem,pidemu,1)<0.30&&iDeMarker(NULL,pidem,pidemu,0)>=0.30)
            {
          
                  if(iStochastic(NULL,pisto,pistok,pistod,istslow,MODE_EMA,0,MODE_MAIN,1)<20&&iStochastic(NULL,pisto,pistok,pistod,istslow,MODE_EMA,0,MODE_MAIN,0)>=20)
                  {
                     
                     ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, 0, 0, "Cash machine buy", 12345, 0, Green);
                     
                     if(ticket > 0)
                     {
                     if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES)) 
                     Print("BUY order opened : ",OrderOpenPrice());
                     }
                     else 
                     Print("Error opening BUY order : ", GetLastError()); 
                     return(0);
                     
                    
                 }
         
          
        }
       
            if(iDeMarker(NULL,pidem,pidemu,1)>0.70&&iDeMarker(NULL,pidem,pidemu,0)<=0.70)
            {
               if(iStochastic(NULL,pisto,pistok,pistod,istslow,MODE_EMA,0,MODE_MAIN,1)>80&&iStochastic(NULL,pisto,pistok,pistod,istslow,MODE_EMA,0,MODE_MAIN,0)<=80)
               {
                  
                  ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, 0, 0, "Cash machine sell", 12345, 0, Red);
                  
                  if(ticket > 0)
                  {
                  if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES)) 
                  Print("SELL order opened : ", OrderOpenPrice());
                  }
                  else 
                  Print("Error opening SELL order : ",GetLastError()); 
                  return(0);
                  
                 
               }
         
        }
        return(0);
} 
//----
    for(cnt = 0; cnt < total; cnt++)
      {
        OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
        if(OrderType() <= OP_SELL && OrderSymbol() == Symbol())
          {
            if(OrderType() == OP_BUY)   // jesli pozycja dluga jest otwarta to
              {
                     //zabezpieczamy osiagniety zysk lub akceptujemy maksymalna strate ktora dopuszczamy w hidden_StopLoss
                if(Bid <= (OrderOpenPrice()-(hidden_StopLoss*Point)) || Bid >= (OrderOpenPrice()+(hidden_TakeProfit*Point)) )
                      {
                        OrderClose(OrderTicket(),Lots,Bid,3,Green);
                        return(0);
                      }
                     //zabezpieczamy min. osiagniety zysk progu trzeciego
                if(Bid >= OrderOpenPrice()+(target_tp3*Point))
                     {
                        OrderModify(OrderTicket(), OrderOpenPrice(), Bid - (Point * (target_tp3-13)), Ask + (Point * hidden_TakeProfit), 0, Green);
                        return(0); 
                     }
                     //zabezpieczamy min. osiagniety zysk progu drugiego
                if(Bid >= OrderOpenPrice()+(target_tp2*Point) && Bid < OrderOpenPrice()+(target_tp3*Point))
                     {
                        OrderModify(OrderTicket(), OrderOpenPrice(), Bid - (Point * (target_tp2-13)), Ask + (Point * hidden_TakeProfit), 0, Green);
                        return(0); 
                     }
                     //zabezpieczamy min. osiagniety zysk progu pierwszego
                if(Bid >= OrderOpenPrice()+(target_tp1*Point) && Bid < OrderOpenPrice()+(target_tp3*Point) && Bid < OrderOpenPrice()+(target_tp2*Point))
                     {
                        OrderModify(OrderTicket(), OrderOpenPrice(), Bid - (Point * (target_tp1-13)), Ask + (Point * hidden_TakeProfit), 0, Green);
                        return(0); 
                     }
              }
            else // jesli pozycja krotka jest otwarta to
              {
              //zabezpieczamy osiagniety zysk lub akceptujemy maksymalna strate ktora dopuszczamy w hidden_StopLoss
                if(Ask >= (OrderOpenPrice()+ (hidden_StopLoss * Point)) || Ask <= (OrderOpenPrice()-(hidden_TakeProfit*Point)) )
                      {
                        OrderClose(OrderTicket(),Lots,Ask,3,Red);
                        return(0);
                      }
               //zabezpieczamy min. osiagniety zysk progu trzeciego       
                if(Ask <= OrderOpenPrice()-(target_tp3*Point))
                     {
                       OrderModify(OrderTicket(), OrderOpenPrice(), Ask + (Point * (target_tp3+13)), Bid - (Point * hidden_TakeProfit), Red);
                       return(0);                        
                     }
                 //zabezpieczamy min. osiagniety zysk progu drugiego
                if(Ask <= OrderOpenPrice()-(target_tp2*Point) && Ask > OrderOpenPrice()-(target_tp3*Point) )
                     {
                       OrderModify(OrderTicket(), OrderOpenPrice(), Ask + (Point * (target_tp2+13)), Bid - (Point * hidden_TakeProfit), Red);
                       return(0);                        
                     }
                  //zabezpieczamy min. osiagniety zysk progu pierwszego
                if(Ask <= OrderOpenPrice()-(target_tp1*Point) && Ask > OrderOpenPrice()-(target_tp2*Point) && Ask > OrderOpenPrice()-(target_tp3*Point) )
                     {
                       OrderModify(OrderTicket(), OrderOpenPrice(), Ask + (Point * (target_tp1+13)), Bid - (Point * hidden_TakeProfit), Red);
                       return(0);                        
                     }                
                 return(0);
              }
          }
      }
//----
    return(0);
  }
//+------------------------------------------------------------------+ 

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---