Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1297

 

Good afternoon, can you tell me if the swap is calculated in money or in points? How do I get the swap value in points?

PositionGetDouble(POSITION_SWAP) ???
 

Hello, can you help me? Question. I am trending by the angle in my EA. When a new bar comes, it sees one, butignores the secondanchor point.

#include <ChartObjects\ChartObjectsLines.mqh>   // Класс ChartObjectsLines   
CChartObjectTrendByAngle myline1;   // Объект класса ChartObjectsLines
// координаты опорных точек трендовых
   datetime time1=iTime(_Symbol,_Period,1);
   datetime time2=iTime(_Symbol,_Period,Period2);
   double price1=iClose(_Symbol,_Period,1);
   double price2=iClose(_Symbol,_Period,Period2);
    myline1.Create(0,"STrend",0,time1,price1,time2,price2);
    myline1.Create(0,"STrend",0,time2,price2,time1,price1);
 
Oleg Kolesov:

Hello, can you help me? Question. I am trending by the angle in my EA. When a new bar comes it sees one, butignores the secondanchor point.

Why do you create the same object twice? But you don't initialize the line angle (CChartObjectTrendByAngle::Angle method) ?

 
Vladimir, the last one is redundant. I wanted to show (if you swap the variables), does it draw the trend lines by one point only?
 
Vladimir angle(Get) property, you need to get. myangle1.Angle(); // Object angle value
 
double CChartObjectTrendByAngle::Angle(void) const?
 
ChartRedraw (0); doesn't work! Does it draw one point at a time?
 
Oleg Kolesov:
Vladimir, the last one is redundant. I wanted to show (if you swap the variables), does it draw trend lines only by one point?

Read the reference - where did you get the idea of one or two dots?

Create

Creates "Trend Lineby Angle"graphical object

Properties

Angle

Get/set "Angle" property

Документация по MQL5: Стандартная библиотека / Графические объекты / Объекты "Линии" / CChartObjectTrendByAngle / Create
Документация по MQL5: Стандартная библиотека / Графические объекты / Объекты "Линии" / CChartObjectTrendByAngle / Create
  • www.mql5.com
Create(long,string,long,datetime,double,datetime,double) - CChartObjectTrendByAngle - Объекты "Линии" - Графические объекты - Стандартная библиотека - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Oleg Kolesov:
ChartRedraw (0); doesn't work! Does it draw one point at a time?

Here's the working code:

//+------------------------------------------------------------------+
//|                                     CChartObjectTrendByAngle.mq5 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//---
#include <ChartObjects\ChartObjectsLines.mqh>
CChartObjectTrendByAngle m_trend_by_angle;   // object of CChartObjectTrendByAngle class
//---
#property script_show_inputs
//--- input parameters
input int      Input1=9;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   MqlRates rates[];
   ArraySetAsSeries(rates,true);
   int start_pos=0,count=6;
   if(CopyRates(Symbol(),Period(),start_pos,count,rates)!=count)
      return;
//---
   m_trend_by_angle.Create(ChartID(),"Trend By Angle",0,rates[0].time,rates[0].high,rates[count-1].time,rates[count-1].low);
   int d=0;
  }
//+------------------------------------------------------------------+
 
Vladimir Karputov:

Here's the working code:

Thank you Vladimir. I'll give it a try.