Forum

call SymbolInfoTick every time?

Hi guys, just a quick question: do I really have to call SymbolInfoTick every time before I use last_tick in the code to get updated quotes? Or is it sufficient to call it only once in the code and then just use last_tick without calling it again? Do I have to call SymbolInfoTick again in every

ObjectGetDouble Check return value

Hi everyone, how can I properly check if the following code returns correct price value ObjectGetDouble ( ChartID (), "Line" , OBJPROP_PRICE , 0 ); other than checking if it is bigger 0? Thanks

Normalize Price?

Hey guys, can someone explain me the idea behind this code? double NormalizePrice( double p) { double ts= SymbolInfoDouble ( _Symbol , SYMBOL_TRADE_TICK_SIZE ); return ( MathRound (p/ts)*ts); } Can it not be simply replaced with this? NormalizeDouble (value, Digits ()) Help very much

4202 error

Why do I get 4202 error from this code? (in strategy tester it works fine!) double trendline( int i) { double trendline= ObjectGetValueByTime ( ChartID (), "Trendline" , iTime ( NULL , PERIOD_D1 , i), 0 ); if( GetLastError ()> 0 ) { Print( "Error :" , GetLastError ()); } return trendline; }

Copyrates price gaps

Can anyone share some kind of code that deals with gaps when copying rates? Thanks

ATR wrong value why?

So I have an MT5 VPS running and an expert placed on the chart. I use trailing stop (price + ATR) and I get ATR value with this code: double ATR() { double myPriceArray[]; int AverageTrueRangeDefinition= iATR ( _Symbol , PERIOD_D1 , 10 ); ArraySetAsSeries (myPriceArray, true ); CopyBuffer

Problem with ObjectGetValueByTime asap help needed

So I use this function to get the value of a trendline for a specific bar: double trendline( int i) { double trendline= ObjectGetValueByTime ( 0 , "Trendline" , iTime ( NULL , PERIOD_D1 , i),0); return trendline; } then I compare it with bar close using: if (barclose( 1 )>trendline( 1 ) &&

Trendline Breakout Automated Entry

Hi everyone, I am wondering if there is a possibility to code an entry condition where the price is > or < a trendline drawn on the chart. Is there any possibility to get the value of a trendline in mql5? Is it possible to compare the price with the value of the trendline on the same date? Thanks a

Trailing stop function

Hello everyone, so I have a trailing stop function which works but once it changes my SL it keeps doing it again and again So this is the function void TrailingStop() { //Last bar close price MqlRates PriceInformation[]; ArraySetAsSeries (PriceInformation, true ); int Data= CopyRates (

loop through open positions and get max profit

Hi everyone, I want to loop through all open positions for one symbol and get the position with max. profit. This is my code: int Positionsforthissymbol= 0 ; for ( int i= PositionsTotal ()- 1 ; i>= 0 ; i--) { string symbol= PositionGetSymbol (i); if ( Symbol ()==symbol)