// plotting Equity & Balance curves on your Zorro result charts.
function plot_balance_equity(); // forward declaration of the new function
//---------------------------------------
function run()
//---------------------------------------
{
set(PLOTNOW); // set this to automatically produce the result chart at the end of a [Test]
// your strategy code goes here, for instance:
while(asset(loop("EUR/USD"/*,"AUD/USD","GBP/USD","GER30","NAS100","SPX500","UK100","UKOil","US30","USD/CAD","USD/CHF","USD/JPY","USDOLLAR","USOil","XAG/USD","XAU/USD"*/)))
{
// ... your trading decisions come here ...
var *ClosePrice = series(priceClose());
var *distfromMA = series(*ClosePrice-EMA(ClosePrice,100));
if (distfromMA[0] > 0) enterLong(); // enter Long above MA (& close all Shorts)
if (distfromMA[0] < 0) enterShort(); // enter Short below MA (& close all Longs)
//---------------------------------------
// now plot the Balance & Equity curves
plot_balance_equity();
//---------------------------------------
} // asset(loop(...))
// set the size of the resulting chart PNG file
PlotWidth = 2000;
PlotHeight1 = 500;
}
//---------------------------------------
function plot_balance_equity()
//---------------------------------------
{
var *EquityCurve = series(WinTotal - LossTotal + WinValTotal - LossValTotal);
plot("Balance",Balance,NEW,BLUE);
plot("Equity",*EquityCurve,0,GREEN);
}
//end