Antonio Bartolucci:
So I created an expert advisor to load custom charts and it works perfectly, what I'm wondering right now is: is there anyway to prevent OnTick event to open the chart for the desired Symbol everytime a new tick arrives?
To do so my simple question is: is there anyway to count opened charts? Something like this:
Try this
input string CustomChartName="GBPUSD";//Custom Chart Name input ENUM_TIMEFRAMES CustomChartTimeframe=PERIOD_H4;//Custom Chart Timeframe input bool MaintainOpen=false;//Maintain chart opened //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- ThisChartID=ChartID(); ChartOpened=false; //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- if(ChartOpened){ChartClose(CustomChartID);ChartOpened=false;} } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ long ThisChartID,CustomChartID; bool ChartOpened; void OnTick() { //--- if(MaintainOpen&&ChartOpened) { if(ChartSymbol(CustomChartID)=="") ChartOpened=false; } //if chart not opened if(!ChartOpened) { CustomChartID=ChartOpen(CustomChartName,CustomChartTimeframe); ChartOpened=true; } }
Lorentzos Roussos:
Try this
ok but this would work if the EA is opened on new chart, I mean to do this from one EA attached to one chart (some forex pair go benefit of the wide amounts of ticks).
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
So I created an expert advisor to load custom charts and it works perfectly, what I'm wondering right now is: is there anyway to prevent OnTick event to open the chart for the desired Symbol everytime a new tick arrives?
To do so my simple question is: is there anyway to count opened charts? Something like this: