Posted By: AdamWu
How to plotHistogram in combined strategy? - 07/31/20 11:34
Dear all, according to manual this code is working perfectly:
But when use similar code to a portfolio trend + counter trend strategy, it shows "Erro 047: No bars to plot":
How can I plotHistogram in this strategy? Thans a lot.
Code
#include <profile.c>
function run()
{
BarPeriod = 1440;
StartDate = 2015;
NumYears = 1;
LookBack = 0;
// run this simulation 1000 times
NumTotalCycles = 100;
// some random trading strategy
if(random() > 0)
enterLong();
else
enterShort();
// plot the result of every run in a bar graph
if(is(EXITRUN))
plotHistogram("Profits",Balance/PIPCost,250,1,RED);
}
But when use similar code to a portfolio trend + counter trend strategy, it shows "Erro 047: No bars to plot":
Code
#include <profile.c>
function run(){
if(Train){
StartDate = 20190131;
EndDate = 20200731;
NumWFOCycles = 3;
} else {
StartDate = 20200627;
}
BarPeriod = 60;
LookBack = 700;
NumTotalCycles = 6;
assetList("AssetsFXCMLite");
while(loop(Assets)){
asset(Loop1);
while(algo(loop("TRND","CNTR"))){
if(Algo == "TRND"){
tradeTrend();
}
if(Algo == "CNTR"){
tradeCounterTrend();
}
}
}
if(is(EXITRUN))
plotHistogram("Profits",Balance/PIPCost,100,1,RED);
}
How can I plotHistogram in this strategy? Thans a lot.