I would like to draw a simple line 10 points above from my entry. But this line needs to start 2 candles ago and end 2 candles in front of my entry candle.
Is this possible? Can someone post a sample code?
Thanks!
Show your idea in a picture. Explain what is " my entry"?
-
Of course, it's possible. Find the index of your entry bar. Get the time of two bars before. Get the time of two bar after. Draw your TLine. What's the problem?
-
You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
No free help 2017.04.21Or pay someone. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum 2018.05.12We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
No free help 2017.04.21
I would like to draw a simple line 10 points above from my entry. But this line needs to start 2 candles ago and end 2 candles in front of my entry candle.
Is this possible? Can someone post a sample code?
Thanks!
It is only an example
//+------------------------------------------------------------------+ //| Ejemplo.mq5 | //+------------------------------------------------------------------+ #include <Trade\PositionInfo.mqh> #include <Trade\Trade.mqh> CPositionInfo Posicion; CTrade Trade; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { ejemplo(); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void ejemplo() { if(PositionsTotal() == 0) { Trade.Buy(0.01, NULL, 0, 0, 0, NULL); Posicion.Select(Symbol()); double PriceLine = Posicion.PriceOpen() + 10 * Point(); datetime TimeStart = iTime(Symbol(), PERIOD_CURRENT, 2); datetime TimeEnd = Posicion.Time() + 2 * PeriodSeconds(PERIOD_CURRENT); string name = "myLine"; ObjectCreate(0, name, OBJ_TREND, 0, TimeStart, PriceLine, TimeEnd, PriceLine); ObjectSetInteger(0, name, OBJPROP_RAY, false); ObjectSetInteger(0, name, OBJPROP_COLOR, clrAqua); } } //+------------------------------------------------------------------+
That is because you did not implement the example properly. Show your code so we can point out your error!
That is because you did not implement the example properly. Show your code so we can point out your error!
Posicion.Select(Symbol()); double PriceLine = Posicion.PriceOpen() + 10 * Point(); datetime TimeStart = iTime(Symbol(), PERIOD_CURRENT, 2); datetime TimeEnd = Posicion.Time() + 2 * PeriodSeconds(PERIOD_CURRENT); string name = "myLine"; ObjectCreate(0, name, OBJ_TREND, 0, TimeStart, PriceLine, TimeEnd, PriceLine); ObjectSetInteger(0, name, OBJPROP_RAY, false); ObjectSetInteger(0, name, OBJPROP_COLOR, clrAqua);
It is only an example
Ok I got it working but When I implement it on the On-tick function it slows down the chart. Anyone know how to fix this?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I would like to draw a simple line 10 points above from my entry. But this line needs to start 2 candles ago and end 2 candles in front of my entry candle.
Is this possible? Can someone post a sample code?
Thanks!