How to plotHistogram in combined strategy?

Posted By: AdamWu

How to plotHistogram in combined strategy? - 07/31/20 11:34

Dear all, according to manual this code is working perfectly:
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.
Posted By: AdamWu

Re: How to plotHistogram in combined strategy? - 07/31/20 12:58

By debuging around, I seems this loop causes the problem:

Code
while(algo(loop("TRND","CNTR"))){}


But I have no idea how to solve this problem. Any idea is warmly welcome!
Posted By: AndrewAMD

Re: How to plotHistogram in combined strategy? - 07/31/20 13:38

I would start by looking closely at the description of warning 047, there are many helpful hints!
https://zorro-trader.com/manual/en/errors.htm
© 2024 lite-C Forums