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.
ya_programmer
like!
barabashkakvn
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.
dmitrievsky
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
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!
Then on the backtests it is good to watch the unsync…
barabashkakvn
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 🙂
dmitrievsky
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
barabashkakvn
Yes. Selected:
rosh
And the Symbol named “EURUSD. renko” is selected in the market review?
barabashkakvn
While this option is not suitable – not up to ticks yet. It would be easy to deal with the bars.
rosh
Does CustomTicksAdd not help?