Don't use 'OnChartEvent' - do your checks in OnTick.
I put it at OnTick()
voidOnTick()
{
HandleRect();
CalculateOrders();
//--- we work only at the time of the birth of new barstaticdatetime PrevBars=0;
datetime time_0=iTime(m_symbol.Name(), Period(), 0);
if(time_0==PrevBars)
return;
PrevBars=time_0;
//---
ManageTrades();
/*
if(ObjectFind(0, sUpRectangle)!=-1) {
Comment ("Rectangle Low : ", DoubleToString(UpperRectLow, _Digits), "\n",
"Rectangle High : ", DoubleToString(UpperRectHigh, _Digits), "\n",
"SellLimit Price : ", DoubleToString(ObjectGetDouble(0, sUpRectLabelPrice, OBJPROP_PRICE, 0), _Digits), "\n",
"SellLimit SL : ", DoubleToString(ObjectGetDouble(0, sUpRectLabelSL, OBJPROP_PRICE, 0), _Digits)
);
}
else if(ObjectFind(0, sDnRectangle)!=-1) {
Comment ("Rectangle High : ", DoubleToString(LowerRectHigh, _Digits), "\n",
"Rectangle Low : ", DoubleToString(LowerRectLow, _Digits), "\n",
"BuyLimit Price : ", DoubleToString(ObjectGetDouble(0, sDnRectLabelPrice, OBJPROP_PRICE, 0), _Digits), "\n",
"BuyLimit SL : ", DoubleToString(ObjectGetDouble(0, sDnRectLabelSL, OBJPROP_PRICE, 0), _Digits)
);
}
*///---
}
It creates rectangle at OnInit.. I add price label & trendline on that rectangle just for visualisation. Values from rectangle that uses for level price & SL for limit orders
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.
What principle do you use to place a pending order? Which bar do you check?
on rectangle values. SellLimit from Upper Rectangle & BuyLimit from Lower Rectangle values
Forum on trading, automated trading systems and testing trading strategies
How to start with MQL5
Vladimir Karputov, 2021.12.27 18:41
*** Which bar do you check?
Don't use 'OnChartEvent' - do your checks in OnTick.
I put it at OnTick()
It creates rectangle at OnInit.. I add price label & trendline on that rectangle just for visualisation. Values from rectangle that uses for level price & SL for limit ordersI put it at OnTick()
I'll take a look at it tomorrow. It's very late today - it's time to sleep :)
I'll take a look at it tomorrow. It's very late today - it's time to sleep :)
Okay sir, thank you
It's fine when using indicators value, thanks to you for open this thread i learned a lot...
Okay sir, thank you
It's fine when using indicators value, thanks to you for open this thread i learned a lot...
I launched it and immediately saw that the stop loss for 'Buy Limit' was set somewhere in the wrong place:
I launched it and immediately saw that the stop loss for 'Buy Limit' was set somewhere in the wrong place:
My mistake
but modify orders still don't work..
those rectangle will be dragged manually (near last SnD) & limit order has to be modified accordingly
I saw that OnChartEvent very responsive to detect values of rectangle changes. Whenever i dragged that rectangle, their values change realtimeMy mistake
but modify orders still don't work..
those rectangle will be dragged manually (near last SnD) & limit order has to be modified accordingly
I saw that OnChartEvent very responsive to detect values of rectangle changes. Whenever i dragged that rectangle, their values change realtimeBroken call logic
and the logic inside the function 'ModifyPending':
Broken call logic
and the logic inside the function 'ModifyPending':
Okay, i'll check it
I found it, very stupid mistake i made. I didn't see it before. Thank you very much Sir
Okay, i'll check it
I found it, very stupid mistake i made. I didn't see it before. Thank you very much Sir
Dear Vladimir,
I put modify pending code at OnChartEvent...
They're very responsive.