Not able to open different Symbol chart in Strategy Tester MQL5

Not able to open different Symbol chart in Strategy Tester MQL5

Manage alerts

Loading saved threads...

Jaffer Wilson · External communityPost link
External question — Stack Overflow Stack Exchange Author: Jaffer Wilson Original post: https://stackoverflow.com/questions/52588166 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I have tried the following code, it works properly on the live chart but not in the Strategy Tester: #define count_symbol 3 string Symbols[count_symbol]={"CADCHF","GBPAUD","EURUSD"}; input int Fetch_Candles=1000; input bool CallMyProgram= true; input bool writedata = true; input bool draw_charts = true; input bool showbuffer1 = true,showbuffer2 = false; int OnInit() { if(draw_charts){ for(int i=0; i < count_symbol; i++) { SymbolSelect(Symbols[i],true); chart_id[i] = ChartOpen(Symbols[i],0); int indicator = iCustom(Symbols[i],0,"Real Time Testing\\Trade_Real_Test",0,false,false,false); ChartIndicatorAdd(chart_id[i],1,indicator); ChartApplyTemplate(chart_id[i],"template.tpl"); } } EventSetMillisecondTimer(10); return(INIT_SUCCEEDED); } This code opens different chart with the respective symbols. But it doesn't work in the Strategy Tester. I could not see the respect charts open in the Strategy Tester with their respective Indicators. The code that I have placed above is of an indicator. I am backtesting the indicator. My humble request please read my question properly and ask the related questions, please. Kindly, let me know what I have missed here. I am calling the same indicator what I am testing on different chart with the respective parameters what I have fixed as you can see in the code. Also, I have the template placed on different charts. I have even tried removing the indicator line just applying the template so that I get the respective effect of indicator on it. Like the following: #define count_symbol 3 string Symbols[count_symbol]={"CADCHF","GBPAUD","EURUSD"}; input int Fetch_Candles=1000; input bool CallMyProgram= true; input bool writedata = true; input bool draw_charts = true; input bool showbuffer1 = true,showbuffer2 = false; int OnInit() { if(draw_charts){ for(int i=0; i < count_symbol; i++) { SymbolSelect(Symbols[i],true); chart_id[i] = ChartOpen(Symbols[i],0); ChartApplyTemplate(chart_id[i],"template.tpl"); } } EventSetMillisecondTimer(10); return(INIT_SUCCEEDED); } Please help me people in a great dilemma.
Quote
Report
Raphael Djangmah · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Raphael Djangmah Original post: https://stackoverflow.com/a/77444507 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. By default, ChartOpen does not work in strategy tester but there is a hack around it. Whenever you load an indicator onto a symbol, the strategy tester automatically opens the symbol and attach the indicator onto it. Therefore, you can simply create an indicator handler with the symbol, and it will open the chart with the moving average even though the indicator is not the goal. string Symbols[] = {"CADCHF", "GBPAUD", "EURUSD"}; for(int i = 0; i < ArraySize(Symbols); i++) { int maHandler = iMA(Symbols[i], PERIOD_CURRENT, 10, 1, MODE_EMA, PRICE_CLOSE); } The code above is in MT5.
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Jaffer Wilson Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/52588166 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I have tried the following code, it works properly on the live chart but not in the Strategy Tester: #define count_symbol 3 string Symbols[count_symbol]={"CADCHF","GBPAUD","EURUSD"}; input int Fetch_Candles=1000; input bool CallMyProgram= true; input bool writedata = true; input bool draw_charts = true; input bool showbuffer1 = true,showbuffer2 = false; int OnInit() { if(draw_charts){ for(int i=0; i < count_symbol; i++) { SymbolSelect(Symbols[i],true); chart_id[i] = ChartOpen(Symbols[i],0); int indicator = iCustom(Symbols[i],0,"Real Time Testing\\Trade_Real_Test",0,false,false,false); ChartIndicatorAdd(chart_id[i],1,indicator); ChartApplyTemplate(chart_id[i],"template.tpl"); } } EventSetMillisecondTimer(10); return(INIT_SUCCEEDED); } This code opens different chart with the respective symbols. But it doesn't work in the Strategy Tester. I could not see the respect charts open in the Strategy Tester with their respective Indicators. The code that I have placed above is of an indicator. I am backtesting the indicator. My humble request please read my question properly and ask the related questions, please. Kindly, let me know what I have missed here. I am calling the same indicator what I am testing on different chart with the respective parameters what I have fixed as you can see in the code. Also, I have the template placed on different charts. I have even tried removing the indicator line just applying the template so that I get the respective effect of indicator on it. Like the following: #define count_symbol 3 string Symbols[count_symbol]={"CADCHF","GBPAUD","EURUSD"}; input int Fetch_Candles=1000; input bool CallMyProgram= true; input bool writedata = true; input bool draw_charts = true; input bool showbuffer1 = true,showbuffer2 = false; int OnInit() { if(draw_charts){ for(int i=0; i < count_symbol; i++) { SymbolSelect(Symbols[i],true); chart_id[i] = ChartOpen(Symbols[i],0); ChartApplyTemplate(chart_id[i],"template.tpl"); } } EventSetMillisecondTimer(10); return(INIT_SUCCEEDED); } Please help me people in a great dilemma.

Cancel quote

Checking account access…