repahel
New Coder
//+------------------------------------------------------------------+
//| short_martingale.mq5 |
//| Copyright 2022, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
#include <customfunctions.mqh>
#include <Trade/Trade.mqh>
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
CTrade trade;
int lot_amount = 0.01;
int tp = 0.0013;
int sl = 0.01;
void OnTick()
{
//---
double ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits);
double bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits);
if (PositionsTotal() == 0)
{
sl = ask + ask*sl;
tp = ask + ask*tp;
MqlRates price_info[];
ArraySetAsSeries(price_info, true);
int price_data = CopyRates(_Symbol, _Period, 0, 3, price_info);
trade.Buy(lot_amount, NULL, ask, sl, tp, NULL);
}
}
//+------------------------------------------------------------------+
//| short_martingale.mq5 |
//| Copyright 2022, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
#include <customfunctions.mqh>
#include <Trade/Trade.mqh>
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
CTrade trade;
int lot_amount = 0.01;
int tp = 0.0013;
int sl = 0.01;
void OnTick()
{
//---
double ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits);
double bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits);
if (PositionsTotal() == 0)
{
sl = ask + ask*sl;
tp = ask + ask*tp;
MqlRates price_info[];
ArraySetAsSeries(price_info, true);
int price_data = CopyRates(_Symbol, _Period, 0, 3, price_info);
trade.Buy(lot_amount, NULL, ask, sl, tp, NULL);
}
}
//+------------------------------------------------------------------+