Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

First independent community of traders

First independent community of traders Logo First independent community of traders Logo

First independent community of traders Navigation

  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • Buy Theme
  • Home
  • About Us
  • Blog
  • Contact Us
Home/ Questions/Q 2720
Next
In Process
barabashkakvn
barabashkakvn

barabashkakvn

  • 7 Questions
  • 175 Answers
  • 0 Best Answers
  • 340 Points
View Profile
  • 0
barabashkakvn
Asked: December 26, 20202020-12-26T12:29:48+00:00 2020-12-26T12:29:48+00:00In: Forex Expert Advisors

CustomXXXX functions

  • 0

If you create a custom symbol programmatically, how do you visually update the graph?
Here’s the adviser:
//+------------------------------------------------------------------+
//|                                                  Test Custom.mq5 |
//|                              Copyright © 2018, Vladimir Karputov |
//|                                           |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2018, Vladimir Karputov"
#property link      "
#property version   "1.00"
//--- input parameters
input string      CustomSymbolName="EURUSD.renko";
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   ResetLastError();
   if(!CustomSymbolCreate(CustomSymbolName))
     {
      if(_LastError!=5304)
        {
         Alert(__FUNCTION__," ERROR CustomSymbolCreate(",CustomSymbolName,") : ",GetLastError());
         return(INIT_FAILED);
        }
     }
   int custom_rates_delete=CustomRatesDelete(CustomSymbolName,0,TimeCurrent()+60*60*24);
   if(custom_rates_delete==-1)
     {
      Alert(__FUNCTION__," ERROR CustomRatesDelete(",CustomSymbolName,") : ",GetLastError());
      return(INIT_FAILED);
     }
   MqlRates rates[];
   ArraySetAsSeries(rates,true);
   ArrayResize(rates,6);
   datetime time_current=TimeCurrent();
   for(int i=0;i<6;i++)
     {
      rates[i]. time = time_current -60*i; / / period start time
      rates[i]. open = 1.65458-0.00100*i; / / opening price
      rates[i]. high = 1.65499-0.00100*i; / / highest price for the period
      rates[i]. low = 1.65401-0.00100*i; / / lowest price for the period
      rates[i]. close = 1.65478-0.00100*i; / / closing price
/*rates[i]. tick_volume; // tick volume
      rates[i]. spread; / / spread
      rates[i]. real_volume; / / exchange volume */

     }
   int custom_rates_replace=CustomRatesReplace(CustomSymbolName,0,time_current+60*60*24,rates);
   if(custom_rates_replace==-1)
     {
      Alert(__FUNCTION__," ERROR CustomRatesReplace(",CustomSymbolName,") : ",GetLastError());
      return(INIT_FAILED);
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   MqlRates rates[];
   ArraySetAsSeries(rates,true);
   ArrayResize(rates,9);
   datetime time_current=TimeCurrent();
   double start_price=NormalizeDouble(MathRand()/32767.0+1.0,5);
   for(int i=0;i<9;i++)
     {
      rates[i]. time = time_current -60*i; / / period start time
      rates[i]. open = start_price-0.00100*i; / / opening price
      rates[i]. high = start_price+0.00040-0.00100*i; // highest price for the period
      rates[i]. low = start_price-0.00040-0.00100*i; // lowest price for the period
      rates[i]. close = start_price+0.00020-0.00100*i; / / closing price
/*rates[i]. tick_volume; // tick volume
      rates[i]. spread; / / spread
      rates[i]. real_volume; / / exchange volume */

     }
   int custom_rates_replace=CustomRatesReplace(CustomSymbolName,0,time_current+60*60*24,rates);
   if(custom_rates_replace==-1)
     {
      Alert(__FUNCTION__," ERROR CustomRatesReplace(",CustomSymbolName,") : ",GetLastError());
      return;
     }
  }
//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction &trans,
                        const MqlTradeRequest &request,
                        const MqlTradeResult &result)
  {
//---

  }
//+------------------------------------------------------------------+

A custom character is created and overwritten. But the graph of this custom symbol is not updated.

  • 10 10 Answers
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    10 Answers

    • Voted
    • Oldest
    • Recent
    1. ya_programmer

      ya_programmer

      • 0 Questions
      • 27 Answers
      • 0 Best Answers
      • 76 Points
      View Profile
      ya_programmer
      2020-12-26T12:31:02+00:00Added an answer on December 26, 2020 at 12:31 pm

      like!

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. barabashkakvn

      barabashkakvn

      • 7 Questions
      • 175 Answers
      • 0 Best Answers
      • 340 Points
      View Profile
      barabashkakvn
      2020-12-26T12:30:57+00:00Added an answer on December 26, 2020 at 12:30 pm
      CustomXXXX functions

      Vladimir Karputov:

      To carry out the next construction, first you need to calculate how many steps the price (“Bid“) went from the last value (array “rates_prev“, index “0”). 

      Time is not taken into account yet.

      In the case of building Renko charts, the question of ticks arises: on the one hand, if ticks are translated directly from the current symbol to the user one, the terminal will automatically build new bars based on ticks. These bars on the custom symbol will be like normal bars on the current symbol – with high and low tails, with a new bar at each minute. On the other hand, if the ticks are not broadcast at all, then you will not be able to trade on the basis of a custom symbol – it will not match prices with the current symbol.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    3. dmitrievsky

      dmitrievsky

      • 0 Questions
      • 7 Answers
      • 0 Best Answers
      • 34 Points
      View Profile
      dmitrievsky
      2020-12-26T12:30:52+00:00Added an answer on December 26, 2020 at 12:30 pm

      fxsaber:

      Everything is the same as you get in the kitchen Terminal arbitrage quick quotes from other sources. Received a quote – sent it by tick to a custom symbol. Done!

      with the loading of the missing ones, it will be inconvenient to constantly ask another adviser to unload ticks from another broker )

      I thought that you can somehow connect to the working file of quotes of another terminal, but the campaign does not

      Yes, just for the sake of the backtest, it is interesting to do

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    4. fxsaber

      fxsaber

      • 1 Question
      • 57 Answers
      • 0 Best Answers
      • 140 Points
      View Profile
      fxsaber
      2020-12-26T12:30:46+00:00Added an answer on December 26, 2020 at 12:30 pm

      Maxim Dmitrievsky:

      what is the best way to load a custom character from another online terminal? i.e., you can first create a cast. the symbol and simply export the tick archive manually, and then in realtime update the symbol with new quotes from another terminal (must be opened). This is not yet in the codebase

      Everything is the same as you get in the kitchen Terminal arbitrage quick quotes from other sources. Received a quote – sent it by tick to a custom symbol. Done!

      Then on the backtests it is good to watch the unsync…

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    5. barabashkakvn

      barabashkakvn

      • 7 Questions
      • 175 Answers
      • 0 Best Answers
      • 340 Points
      View Profile
      barabashkakvn
      2020-12-26T12:30:33+00:00Added an answer on December 26, 2020 at 12:30 pm

      Maxim Dmitrievsky:

      Vladimir, could you think about how to load a custom character from another online terminal? that is, you can first create a cast. the symbol and simply export the tick archive manually, and then in realtime update the symbol with new quotes from another terminal (must be opened). This is not yet in the codebase

      I here generally thought different examples to do on user characters. But for now, stop: as you can see, I found it in an open field … the pit 🙂

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    6. dmitrievsky

      dmitrievsky

      • 0 Questions
      • 7 Answers
      • 0 Best Answers
      • 34 Points
      View Profile
      dmitrievsky
      2020-12-26T12:30:28+00:00Added an answer on December 26, 2020 at 12:30 pm

      Vladimir, could you think of a better way to load a custom character from another online terminal? i.e., you can first create a cast. the symbol and simply export the tick archive manually, and then in realtime update the symbol with new quotes from another terminal (must be opened). This is not yet in the codebase

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    7. barabashkakvn

      barabashkakvn

      • 7 Questions
      • 175 Answers
      • 0 Best Answers
      • 340 Points
      View Profile
      barabashkakvn
      2020-12-26T12:30:13+00:00Added an answer on December 26, 2020 at 12:30 pm
      CustomXXXX functions

      Rashid Umarov:

      And the Symbol named “EURUSD. renko” is selected in the market review?

      Yes. Selected:

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    8. rosh

      rosh

      • 1 Question
      • 11 Answers
      • 0 Best Answers
      • 40 Points
      View Profile
      rosh
      2020-12-26T12:30:08+00:00Added an answer on December 26, 2020 at 12:30 pm

      Vladimir Karputov:

      At the start, I create six bars.

      In OnTick() I’m trying to add one tick at a time:

      When I try to add ticks, I get

      ERR_CUSTOM_TICKS_WRONG_ORDER

      5310

      Non-time-ordered array of ticks

      And the Symbol named “EURUSD. renko” is selected in the market review?

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    9. barabashkakvn

      barabashkakvn

      • 7 Questions
      • 175 Answers
      • 0 Best Answers
      • 340 Points
      View Profile
      barabashkakvn
      2020-12-26T12:29:57+00:00Added an answer on December 26, 2020 at 12:29 pm

      Rashid Umarov:

      Does CustomTicksAdd not help?

      While this option is not suitable – not up to ticks yet. It would be easy to deal with the bars.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    10. rosh

      rosh

      • 1 Question
      • 11 Answers
      • 0 Best Answers
      • 40 Points
      View Profile
      rosh
      2020-12-26T12:29:53+00:00Added an answer on December 26, 2020 at 12:29 pm

      Does CustomTicksAdd not help?

      Note

      The CustomTicksAdd function only
      works for custom characters that are open in the window
      MarketWatch (market Overview). If the symbol is not selected in MarketWatch, then for
      you must use CustomTicksReplace to insert ticks.

      Function
      CustomTicksAdd allows you to broadcast ticks as if they
      came from the broker’s server. Data is not written directly to the database
      ticks, and are sent to the “market Overview” window. And already from it, the terminal
      saves ticks in its database. When a large amount of data is transferred in a
      single call, the function changes its behavior to save resources. If more
      than 256 ticks are transmitted, the data is divided into two parts. The first part
      (large) is immediately written directly to the tick database (as CustomTicksReplace does). The second part, consisting of the last 128 ticks, is transmitted to the “market Overview” window and then saved by the terminal in the database.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    Stats

    • Questions 521
    • Answers 2k
    • Posts 5
    • Comments 0
    • Best Answers 0
    • Users 706
    • Popular
    • Comments
    • Tags
    • forexcommunity

      Highlighting what’s important about questions & Answers on Discy Community!

      • 0 Comments
    • forexcommunity

      Introducing Keyboard Shortcuts, our first Labs feature

      • 0 Comments
    • forexcommunity

      Defining quality on Discy Engine — what a helpful answer ...

      • 0 Comments
    • forexcommunity

      Organizational and company accounts on Discy Engine the next step

      • 0 Comments
    • forexcommunity

      Hello world!

      • 0 Comments

    Related Questions

    • savinkins

      Getting data by the indicator from another indicator on a ...

      • 6 Answers
    • fresto

      Error opening the OptimOne file error: 5004

      • 2 Answers
    • asot650

      You need to write an Expert Advisor on the indicator

      • 4 Answers
    • miron_like

      Translation to mql5

      • 1 Answer
    • dynamiteman

      Script for commenting on an MT4 or MT5 trade

      • 2 Answers

    Users

    Brianacink

    Brianacink

    • 0 Questions
    • 0 Answers
    asot650

    asot650

    • 1 Question
    • 2 Answers
    investr777

    investr777

    • 1 Question
    • 0 Answers

    Footer

    First independent community of traders

    About

    An independent community of forex traders. This is where traders communicate. You can ask your questions and you will receive an answer to your question.
    • Terms of Use
    • Privacy Policy
    • Cookie Policy
    • Knowledge Base
    • Support

    © 2021 Forexcommunity.net. All Rights Reserved