Konstantin Bystrov: Hi all. who can write an indicator in mt4, so that the active trading sessions (can be set from 10-18) were displayed in the form of Japanese candles
Are there any craftsmen here who could write an EA based on an informational indicator of currency strength. The algorithm is as follows. We are waiting for the strong and weak currency to appear. In the example on the screenshot, it is EUR and USD. If the difference is significant (to be set in the EA parameters), then we open a position. In the example on the screenshot, you need to enter into a sell, which I will do on Monday. In the EA, we have to set the timeframe parameter, from which the EA should take the signal (difference in strength of different currencies). The currency strength difference is the signal. Stop Loss is not needed. Take Profit is needed. If the price goes against us, let's average. In your Expert Advisor, prescribe the averaging step, the number of orders, magic number, initial lot size, and lot increment factor. I have been trading using this method recently; I am very satisfied. For my perception it is a grail.
Konstantin Bystrov: Hi all. can you write an indicator in mt4, to display active trading sessions (you can set the time from 10-18) in the form of Japanese candles
//+------------------------------------------------------------------+//+------------------------------------------------------------------+#property copyright""#property link""#property indicator_chart_windowexternint NumberOfDays = 50;
externstring AsiaBegin = "10:00";
externstring AsiaEnd = "18:00";
externcolor AsiaColor = Goldenrod;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+void init()
{
DeleteObjects();
for(int i=0; i<NumberOfDays; i++)
CreateObjects("AS"+i, AsiaColor);
Comment("");
}
//+------------------------------------------------------------------+//| Custor indicator deinitialization function |//+------------------------------------------------------------------+void deinit()
{
DeleteObjects();
Comment("");
}
//+------------------------------------------------------------------+bool CreateObjects(
conststring name="Rectangle", // имя прямоугольникаconstcolor clr=clrRed, // цвет прямоугольникаconstlong chart_ID=0, // ID графикаconstint sub_window=0, // номер подокнаdatetime time1=0, // время первой точкиdouble price1=0, // цена первой точкиdatetime time2=0, // время второй точкиdouble price2=0, // цена второй точкиconstENUM_LINE_STYLE style=STYLE_SOLID, // стиль линий прямоугольникаconstint width=2, // толщина линий прямоугольникаconstbool fill=false, // заливка прямоугольника цветомconstbool back=false, // на заднем планеconstbool selection=false, // выделить для перемещенийconstbool hidden=true, // скрыт в списке объектовconstlong z_order=0) // приоритет на нажатие мышью
{
//--- сбросим значение ошибкиResetLastError();
//--- создадим прямоугольник по заданным координатамif(!ObjectCreate(chart_ID,name,OBJ_RECTANGLE,sub_window,time1,price1,time2,price2))
{
Print(__FUNCTION__,
": не удалось создать прямоугольник! Код ошибки = ",GetLastError());
return(false);
}
//--- установим цвет прямоугольникаObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- установим стиль линий прямоугольникаObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- установим толщину линий прямоугольникаObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- включим (true) или отключим (false) режим заливки прямоугольникаObjectSetInteger(chart_ID,name,OBJPROP_FILL,fill);
//--- отобразим на переднем (false) или заднем (true) планеObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- включим (true) или отключим (false) режим выделения прямоугольника для перемещений//--- при создании графического объекта функцией ObjectCreate, по умолчанию объект//--- нельзя выделить и перемещать. Внутри же этого метода параметр selection//--- по умолчанию равен true, что позволяет выделять и перемещать этот объектObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- скроем (true) или отобразим (false) имя графического объекта в списке объектовObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- установим приоритет на получение события нажатия мыши на графикеObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- успешное выполнениеreturn(true);
}
//+------------------------------------------------------------------+void DeleteObjects()
{
for(int i=0; i<NumberOfDays; i++)
ObjectDelete("AS"+i);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+void start()
{
datetime dt=CurTime();
for(int i=0; i<NumberOfDays; i++)
{
DrawObjects(dt, "AS"+i, AsiaBegin, AsiaEnd);
dt=decDateTradeDay(dt);
while(TimeDayOfWeek(dt)>5)
dt=decDateTradeDay(dt);
}
}
//+------------------------------------------------------------------+void DrawObjects(datetime dt, string no, string tb, string te)
{
datetime t1, t2;
double p1, p2;
int b1, b2;
t1=StrToTime(TimeToStr(dt, TIME_DATE)+" "+tb);
t2=StrToTime(TimeToStr(dt, TIME_DATE)+" "+te);
if(!TimeDayOfWeek(t1))
return;
b1=iBarShift(NULL, 0, t1);
b2=iBarShift(NULL, 0, t2);
p1=High[Highest(NULL, 0, MODE_HIGH, b1-b2, b2)];
p2=Low [Lowest(NULL, 0, MODE_LOW, b1-b2, b2)];
ObjectSet(no, OBJPROP_TIME1, t1);
ObjectSet(no, OBJPROP_PRICE1, p1);
ObjectSet(no, OBJPROP_TIME2, t2);
ObjectSet(no, OBJPROP_PRICE2, p2);
}
//+------------------------------------------------------------------+datetime decDateTradeDay(datetime dt)
{
int ty=TimeYear(dt);
int tm=TimeMonth(dt);
int td=TimeDay(dt);
int th=TimeHour(dt);
int ti=TimeMinute(dt);
td--;
if(td==0)
{
tm--;
if(tm==0)
{
ty--;
tm=12;
}
if(tm==1 || tm==3 || tm==5 || tm==7 || tm==8 || tm==10 || tm==12)
td=31;
if(tm==2)
if(MathMod(ty, 4)==0)
td=29;
else
td=28;
if(tm==4 || tm==6 || tm==9 || tm==11)
td=30;
}
return(StrToTime(ty+"."+tm+"."+td+" "+th+":"+ti));
}
//+------------------------------------------------------------------+
Hello Dear programming gurus, I'm asking for your help in finishing this robot.
I'm not a programmer myself, this robot is assembled by myself from various parts found on the Internet, but I can not attach the remaining two functions that I would like to see. Please help me. I think that for you it will not be as difficult as me. If you would like to help, please make a function which closes pending order after one of two pending orders has triggered. And the second function should automatically increase a lot of the order ("say" for every $50 of balance 0.01 lot, when you reach $100 the robot will automatically increase a lot by 0.02). Thanks in advance for your help.
externint TakeProfit = 100.0;
externbool AllPositions = True; // Управлять всеми позициямиexternbool ProfitTrailing = True; // Тралить только профитexternint TrailingStop = 50; // Фиксированный размер тралаexternint TrailingStep = 0; // Шаг тралаexternbool UseSound = False; // Использовать звуковой сигналexternstring NameFileSound = "expert.wav"; // Наименование звукового файлаvoid start()
{
double TakeProfitLevelB;
double TakeProfitLevelS;
double BuyStart = Ask + 400*_Point;
double SellStart = Bid - 400*_Point;
TakeProfitLevelB = BuyStart + TakeProfit*Point;
TakeProfitLevelS = SellStart - TakeProfit*Point;
if (Open[1]==Close[1]&& OrdersTotal()==0)
{
int BuyTicket = OrderSend(Symbol(),OP_BUYSTOP,0.10,BuyStart,3,0,TakeProfitLevelB,NULL,0,0,Green);
int SellTicket = OrderSend(Symbol(),OP_SELLSTOP,0.10,SellStart,3,0,TakeProfitLevelS,NULL,0,0,Blue);
}
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (AllPositions || OrderSymbol()==Symbol()) {
TrailingPositions();
}
}
}
}
void TrailingPositions()
{
double pBid, pAsk, pp;
pp = MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType()==OP_BUY) {
pBid = MarketInfo(OrderSymbol(), MODE_BID);
if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp) {
if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp) {
ModifyStopLoss(pBid-TrailingStop*pp);
return;
}
}
}
if (OrderType()==OP_SELL) {
pAsk = MarketInfo(OrderSymbol(), MODE_ASK);
if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp) {
if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0) {
ModifyStopLoss(pAsk+TrailingStop*pp);
return;
}
}
}
}
void ModifyStopLoss(double ldStopLoss)
{
bool fm;
fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
if (fm && UseSound) PlaySound(NameFileSound);
}
Thank you dear gss for your interest in my request. This is the reason why I decided to address the MQL4 guru. The code I have posted works. I have collected it from various Expert Advisors, or rather one of them, I took only Trailing Stop function. The rest I have made up myself (concerning pending orders). I would like to ask you and other gurus to take a look at my code and add two more functions to this robot, if you would not mind.
1) To delete a pending order when one of them triggers.
2) Automatic lot increase (for each 50$ 0.01 i.e. for 100$ it will be 0.02)
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.
Hi all. who can write an indicator in mt4, so that the active trading sessions (can be set from 10-18) were displayed in the form of Japanese candles
ok
Good afternoon!
Are there any craftsmen here who could write an EA based on an informational indicator of currency strength. The algorithm is as follows. We are waiting for the strong and weak currency to appear. In the example on the screenshot, it is EUR and USD. If the difference is significant (to be set in the EA parameters), then we open a position. In the example on the screenshot, you need to enter into a sell, which I will do on Monday. In the EA, we have to set the timeframe parameter, from which the EA should take the signal (difference in strength of different currencies). The currency strength difference is the signal. Stop Loss is not needed. Take Profit is needed. If the price goes against us, let's average. In your Expert Advisor, prescribe the averaging step, the number of orders, magic number, initial lot size, and lot increment factor. I have been trading using this method recently; I am very satisfied. For my perception it is a grail.
Hi all. can you write an indicator in mt4, to display active trading sessions (you can set the time from 10-18) in the form of Japanese candles
Hello Dear programming gurus, I'm asking for your help in finishing this robot.
I'm not a programmer myself, this robot is assembled by myself from various parts found on the Internet, but I can not attach the remaining two functions that I would like to see. Please help me. I think that for you it will not be as difficult as me. If you would like to help, please make a function which closes pending order after one of two pending orders has triggered. And the second function should automatically increase a lot of the order ("say" for every $50 of balance 0.01 lot, when you reach $100 the robot will automatically increase a lot by 0.02). Thanks in advance for your help.
Look at e-News-Lucky$.mq4.
Look at Fixed-Proportional Position Size Selection Method (R. Jones) - MQL4 and MetaTrader 4 - MQL4 Algo-Traders Forum - Page 3 (mql5.com)
Look at e-News-Lucky$.mq4.
Look at the Fixed-Proportional Position Size Selection Method (R. Jones) - MQL4 and MetaTrader 4 - MQL4 Algo-Trader Forum - Page 3 (mql5.com)
Hi all, check out my idea for an indicator, so as not to spam all posts, here is the link
https://www.mql5.com/ru/forum/35071/page144#comment_22289427
i. e.if the deal is in profit i.e. the order advances --- i.e. in case of reverse movement the lock will be positive.
2.In the case of opening any part of the lock, an order for the difference should be placed.
seems to be all. Once again --- the Expert Advisor should not close by itselfwithout any additional buttons on the chart.