How to start with MQL5 - page 14

 
Ahmad861:

i do not understand, What do you mean ?

Styler - Developing programs
Styler - Developing programs - MetaEditor Help
Styler - Developing programs - MetaEditor Help
  • www.metatrader5.com
The styler quickly brings a source code design in line with the recommended standard. This makes the code look professional and easy to read. A well-designed code is much easier to analyze in the future both for its author and for other users. To launch Styler, click Styler in the Tools menu or press Ctrl+,. General Spaces and blank lines...
 
Vladimir Karputov:
Styler - Developing programs

Thank you for suggesting styler but it did not solve my problem of ChartOpen() and its return value. Since I'm using multiple symbols and multiple timeframes I use ChartOpen(sym,TF[j]) as a chartid parameter in ObjectCreate() and it ends up opening infinite charts, this is the problem I am facing and would like to know how to get chartid without executing the function.

Thank you

 
Ahmad861 :

Thank you for suggesting styler but it did not solve my problem of ChartOpen() and its return value. Since I'm using multiple symbols and multiple timeframes I use ChartOpen(sym,TF[j]) as a chartid parameter in ObjectCreate() and it ends up opening infinite charts, this is the problem I am facing and would like to know how to get chartid without executing the function.

Thank you

Don't use ChartOpen ()

I can’t answer you exactly, because I don’t know - "What exactly do you want to do"?

 
Vladimir Karputov:

Don't use ChartOpen ()

I can’t answer you exactly, because I don’t know - "What exactly do you want to do"?

I don't know how else to get chartid

I use my EA as a scanner, when the logic of my EA executes on a  specific symbol and timeframe it opens a new chart with ChartOpen() and an Alert() and draws trendlines according to my analysis, but using ChartOpen() as the Chartid parameter in ObjectCreate opens many charts till mt5 crashes, I tried using the ChartID() but this only returns the chartid of the chart I attached the EA to

 
Ahmad861 :

I don't know how else to get chartid

I use my EA as a scanner, when the logic of my EA executes on a  specific symbol and timeframe it opens a new chart with ChartOpen() and an Alert() and draws trendlines according to my analysis, but using ChartOpen() as the Chartid parameter in ObjectCreate opens many charts till mt5 crashes, I tried using the ChartID() but this only returns the chartid of the chart I attached the EA to

Why are you opening the chart? The EA can easily work with several symbols / timeframes and open positions on different symbols / timeframes.

 
Vladimir Karputov:

Why are you opening the chart? The EA can easily work with several symbols / timeframes and open positions on different symbols / timeframes.

I guess you could call my EA a semi-automated one, i use ChartOpen() to manually analyze the trade before opening because not all trade signals are winners, that's just how my strategy is 

 

How can i go about coding a spinning top candlestick pattern

 
Ahmad861:

How can i go about coding a spinning top candlestick pattern

There is the article about this kind of pattern (and about some others) with coding examples: Analyzing Candlestick Patterns
Analyzing Candlestick Patterns
Analyzing Candlestick Patterns
  • www.mql5.com
Construction of Japanese candlestick chart and analysis of candlestick patterns constitute an amazing area of technical analysis. The advantage of candlesticks is that they represent data in such a manner that you can track the dynamics inside the data. In this article we analyze candlestick types, classification of candlestick patterns and present an indicator that can determine candlestick patterns.
 
Ahmad861 :

How can i go about coding a spinning top candlestick pattern

You need to work with CopyRates . If you clarify your task, I can give you a more accurate advice and provide a code.

Documentation on MQL5: Timeseries and Indicators Access / CopyRates
Documentation on MQL5: Timeseries and Indicators Access / CopyRates
  • www.mql5.com
CopyRates - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Delete all pending orders of a certain type

The code: 'Pending Delete.mq5'

//+------------------------------------------------------------------+
//|                                               Pending Delete.mq5 |
//|                              Copyright © 2020, Vladimir Karputov |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2020, Vladimir Karputov"
#property version   "1.000"
//---
#include <Trade\Trade.mqh>
#include <Trade\OrderInfo.mqh>
//---
CTrade         m_trade;                      // object of CTrade class
COrderInfo     m_order;                      // object of COrderInfo class
//---
#property script_show_inputs
//---
//+------------------------------------------------------------------+
//| Enum Pending                                                     |
//+------------------------------------------------------------------+
enum ENUM_PENDING
  {
   buy_limit=2,   // Buy Limit
   sell_limit=3,  // Sell limit
   buy_stop=4,    // Buy Stop
   sell_stop=5,   // Sell Stop
  };
//--- input parameters
input ENUM_PENDING   InpPending  = buy_limit; // Delete all:
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   DeleteOrders((ENUM_ORDER_TYPE)InpPending);
  }
//+------------------------------------------------------------------+
//| Delete Orders                                                    |
//+------------------------------------------------------------------+
void DeleteOrders(const ENUM_ORDER_TYPE order_type)
  {
   for(int i=OrdersTotal()-1; i>=0; i--) // returns the number of current orders
      if(m_order.SelectByIndex(i))     // selects the pending order by index for further access to its properties
         if(m_order.OrderType()==order_type)
           {
            m_trade.OrderDelete(m_order.Ticket());
            continue;
           }
  }
//+------------------------------------------------------------------+
Files:
Reason: