I am familiar with zorro since last year but live trading since fews weeks now and I would like to report something curious.
I am using Zorro 1.72 and I have observed the following behavior.
According to the documentation of zorro (which is great by the way) :
"All stop, profit, trail, or entry limits are handled by software and controlled at each tick. They are not sent to the broker's server (except for the 'safety net' stop given by StopFactor) and thus not visible to the broker, this way preventing "stop hunting" or similar practices. This also steps around NFA Compliance Rule 2-43(b) that does not allow US citizens to place stop or profit targets"
It works well when live trading only one asset : - When the take profit is hit, the trade is closed immediately.
But when I use that same algo but with multiple assets in a loop ( while(loop(Assets)) :
- when the take profit is hit, the trade is closed as next bar. - The only exception is for the asset that is selected in the GUI (see attached files). in that way is works fine.
Is it a behavior that is wanted ? or is it a feature for Zorro S user only ? or is it a bug ? Please let me know that you think.
This cause trouble because since it close the trade at the next bar, the profit can be quite different from expected.
Best regards, Johan
Last edited by JohanAu; 10/31/1712:58.
Re: TMF not executed at each ticks
[Re: JohanAu]
#468989 11/01/1709:5111/01/1709:51
No, Stops and TPs must work in the same way with single and with multiple assets.
If your script behaves different dependent on whether you select the asset by script or with the scrollbox, then I would first suspect some wrong initialization. Make sure that you set the parameters for the right asset, after and not before selecting it. And set Stop and TP before entering the trade, not after it.
Re: TMF not executed at each ticks
[Re: jcl]
#469008 11/02/1707:3611/02/1707:36
Yes, that looks quite wrong. I wonder why you get no runtime error with this script.
The order of commands does matter in programming. First set all script parameters, such as the bar period, TICKS, etc, and then load the asset. Not the other way around. Otherwise the asset is not loaded in TICKS mode, but in low resolution. The INITRUN clause is not needed.
You can see in workshop 6 in the manual how a portfolio script should look like.
Re: TMF not executed at each ticks
[Re: jcl]
#469365 11/13/1709:2511/13/1709:25
Thank you for your response. I have modified the function according to your comments :
Code:
function TradeBBands()
{
var NbDevUp=1.7;
var NbDevDn=1.7;
var MaxTradePerAsset = 4;
vars Price = series(price());
BBands((series(1000*priceClose())),20,NbDevUp,NbDevDn,MAType_SMA);
vars upperBand = series(rRealUpperBand/1000);
vars lowerBand = series(rRealLowerBand/1000);
Lots = 1;
if (crossUnder(Price, lowerBand) && NumOpenLong <MaxTradePerAsset)
{
TakeProfit = 1.0375*price();
enterLong();
}
}
function run()
{
set(LOGFILE+PRELOAD+NFA+TICKS);
BarPeriod = 15;
Weekend = 0;
Verbose=7;
Capital = 0.009;
StartDate = 20150615;
EndDate = 20171001;
assetList("AssetsToUse.csv"); // load asset list
while (asset(loop(Assets)))
{
TradeBBands();
}
}
Tested it again and the issue is still present. The trade is close at the right time only for one asset. I don't know what variable I can check to diagnose the faulty element. Do you have any tips ?
BR, Johan
Re: TMF not executed at each ticks
[Re: JohanAu]
#469367 11/13/1710:3911/13/1710:39
Looks better now. At least I see no obvious reason for a delayed exit. But I would not use price() for a TakeProfit. That means the limit can be already below the current price.
For diagnose, use a TMF that prints the current time, asset, TradeProfitLimit, and TradePriceClose. That should give insight in the trade exit behavior.