SCT_Martingale

Author: Copyright 2020, Mario Gharib. mario.gharib@hotmail.com
Orders Execution
It automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites
SCT_Martingale
//+------------------------------------------------------------------+
//|                                                   Martingale.mq5 |
//|                                    Copyright 2020, Mario Gharib. |
//|                                         mario.gharib@hotmail.com |
//+------------------------------------------------------------------+
//|IMPORTANT INFORMATION YOU NEED TO KNOW                            |
//+------------------------------------------------------------------+
//|Please note that investing involves risks. Any decision to invest |
//|in either the real estate or stock markets is a personal decision |
//|that should be made after thorough research, including an         |
//|assessment of your personal risk tolerance and your personal      |
//|financial condition and goals. Results are based on market        |
//|conditions and on each individual and the action they take and the|
//|time and effort they put in.                                      |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, Mario Gharib. mario.gharib@hotmail.com"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property script_show_inputs
#property strict

input int iNbStopOrders=5; // Number of limit orders (Buy limit Or Sell limit)
input double dEntryPrice;  // The initial entry price
input double dStopLoss;   // The initial stop loss
input double dTakeProfit;   // The initial Take profit
input double dLotSize=0.01;   // The position size of each trade.

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   string sSymbol = Symbol();
   
   if (dEntryPrice>SymbolInfoDouble(sSymbol,SYMBOL_ASK)) {
      double dGrid1=dStopLoss-dEntryPrice;
      for (int i=1 ; i<=iNbStopOrders ; i++)
         bool selllimit = OrderSend(Symbol(),OP_SELLLIMIT,dLotSize,dEntryPrice-(i-1)*dGrid1,5,dStopLoss,dTakeProfit,NULL);         
   }
   else {
      double dGrid=dEntryPrice-dStopLoss;
      for (int j=1 ; j<=iNbStopOrders ; j++)
         bool buylimit = OrderSend(Symbol(),OP_BUYLIMIT,dLotSize,dEntryPrice+(j-1)*dGrid,5,dStopLoss,dTakeProfit,NULL);
   }
}

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 ---