#property copyright"Copyright 2019, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"//---- показывать входные параметры#property script_show_inputs//---#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
CTrade m_trade; // trading object
CSymbolInfo m_symbol; // symbol info object//+------------------------------------------------------------------+//| Enum Stop or Limit |//+------------------------------------------------------------------+enum ENUM_STOP_OR_LIMIT
{
stop=0, // Buy stop and Sell stop
limit=1// Buy limit and Sell limit
};
//--- input parametersinputushort InpUpGap = 15; // Gap for pending orders UP from the current price (in points)inputushort InpUpStep = 30; // Step between orders UP (in points)inputushort InpDownGap = 15; // Gap for pending orders DOWN from the current price (in points)inputushort InpDownStep = 30; // Step between orders DOWN (in points)input ENUM_STOP_OR_LIMIT InpPending = stop; // Type of pending ordersinputuchar InpUpQuantity = 1; // UP quantity ordersinputuchar InpDownQuantity = 1; // DOWN quantity ordersinputdouble InpLots = 0.01; // Lotsinputushort InpStopLoss = 50; // Stop Loss (in points)inputushort InpTakeProfit = 50; // Take Profit (in points)//---ulong m_slippage=30; // slippagedouble ExtUpGap=0.0;
double ExtUpStep=0.0;
double ExtDownGap=0.0;
double ExtDownStep=0.0;
double ExtStopLoss=0.0;
double ExtTakeProfit=0.0;
//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+voidOnStart()
{
//---if(InpLots<=0.0)
{
Print("The \"Lots\" can't be smaller or equal to zero");
return;
}
//---if(!m_symbol.Name(Symbol())) // sets symbol namereturn;
if(!RefreshRates())
return;
string err_text="";
if(!CheckVolumeValue(InpLots,err_text))
{
Print(err_text);
return;
}
//---if(IsFillingTypeAllowed(SYMBOL_FILLING_FOK))
m_trade.SetTypeFilling(ORDER_FILLING_FOK);
elseif(IsFillingTypeAllowed(SYMBOL_FILLING_IOC))
m_trade.SetTypeFilling(ORDER_FILLING_IOC);
else
m_trade.SetTypeFilling(ORDER_FILLING_RETURN);
//---
m_trade.SetDeviationInPoints(m_slippage);
m_trade.SetAsyncMode(true);
//---
ExtUpGap = m_symbol.Point() * InpUpGap;
ExtUpStep = m_symbol.Point() * InpUpStep;
ExtDownGap = m_symbol.Point() * InpDownGap;
ExtDownStep = m_symbol.Point() * InpDownStep;
ExtStopLoss = m_symbol.Point() * InpStopLoss;
ExtTakeProfit = m_symbol.Point() * InpTakeProfit;
//--- start workdouble start_price_ask=m_symbol.Ask()-ExtUpGap;
double start_price_bid=m_symbol.Bid()+ExtDownGap;
//--- set pending ordersfor(int i=0; i<InpUpQuantity; i++)
{
double price_ask = start_price_ask+i*ExtUpStep;
double price_bid = start_price_bid+i*ExtUpStep;
if(InpPending==stop)
{
double sl = (ExtStopLoss==0.0) ? 0.0 : price_ask - ExtStopLoss;
double tp = (ExtTakeProfit==0.0) ? 0.0 : price_ask + ExtTakeProfit;
m_trade.BuyStop(InpLots,m_symbol.NormalizePrice(price_ask),m_symbol.Name(),
m_symbol.NormalizePrice(sl),
m_symbol.NormalizePrice(tp));
}
else
{
double sl = (ExtStopLoss==0.0) ? 0.0 : price_bid + ExtStopLoss;
double tp = (ExtTakeProfit==0.0) ? 0.0 : price_bid - ExtTakeProfit;
m_trade.SellLimit(InpLots,m_symbol.NormalizePrice(price_bid),m_symbol.Name(),
m_symbol.NormalizePrice(sl),
m_symbol.NormalizePrice(tp));
}
}
for(int i=0; i<InpDownQuantity; i++)
{
double price_ask = start_price_ask-i*ExtDownStep;
double price_bid = start_price_bid-i*ExtDownStep;
if(InpPending==limit)
{
double sl = (ExtStopLoss==0.0) ? 0.0 : price_ask - ExtStopLoss;
double tp = (ExtTakeProfit==0.0) ? 0.0 : price_ask + ExtTakeProfit;
m_trade.BuyLimit(m_symbol.LotsMin(),m_symbol.NormalizePrice(price_ask),m_symbol.Name(),
m_symbol.NormalizePrice(sl),
m_symbol.NormalizePrice(tp));
}
else
{
double sl = (ExtStopLoss==0.0) ? 0.0 : price_bid + ExtStopLoss;
double tp = (ExtTakeProfit==0.0) ? 0.0 : price_bid - ExtTakeProfit;
m_trade.SellStop(m_symbol.LotsMin(),m_symbol.NormalizePrice(price_bid),m_symbol.Name(),
m_symbol.NormalizePrice(sl),
m_symbol.NormalizePrice(tp));
}
}
}
The script is supposed to set either pending limit orders at a certain distance from ask and bid, or stop orders. The limitpending orders are set without problems but the stop ones are not. Please do not know why the Sell Stop and Buy Stop pending orders are not set.
first you have to find all the texts and use this function to calculate from it?
I don't know this thoroughly, as I'm learning mql4 language recently myself. You can find everything in the help. Do you need the whole text from the object or a chunk?
Yevhenii Levchenko: I don't know this thoroughly, as I'm a recent mql4 language learner myself. You can find everything in the help. Do you need the whole text from the object or a piece of it?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Good day everyone!
Here is part of the script code for Metatrader5:
The script is supposed to set either pending limit orders at a certain distance from ask and bid, or stop orders. The limitpending orders are set without problems but the stop ones are not. Please do not know why the Sell Stop and Buy Stop pending orders are not set.
Yours sincerely, Vladimir.
Hi guys. Made writing a lot next to an open order. Can you tell me how to take the last text and this list?
first you have to find all the texts and use this function to calculate from it?
first you have to find all the texts and use this function to calculate from it?
I don't know this thoroughly, as I'm a recent mql4 language learner myself. You can find everything in the help. Do you need the whole text from the object or a piece of it?
I need what was written last time
Hi guys. Made writing a lot next to an open order. Can you tell me how to take the last text and this list?
From which list?
And please use the styler in the editor (Ctrl+<):
What should be taken from where?
From which list?
And please use the styler in the editor (Ctrl+<):
Where do I get it from?
This function writes a number on each order or more precisely lot*100.
We now need an inverse function which shows what was the last number