I've managed to finally put together my first test script and am running it in demo, but I need some clarification on some things that don't make sense.

The script is just a test script to practice coding, so please don't worry about profitability and such. I've written it the way I have in order to build to something bigger later, so that's why it's only looping one algo, but is set up to add algos later on.

The algo is just the one in Workshop 4, with optimization as in Workshop 5 and looping assets as in Workshop 6 with some small changes:

function tradeTrend()
{
TimeFrame = 1;
vars Price = series(price());
vars Trend = series(LowPass(Price,optimize(1000,500,1500)));
vars Signals = series(0);

Stop = 10*ATR(20);
TakeProfit = 20*ATR(20);
Entry = -2*PIP;
EntryDelay = 6*30;
if(valley(Trend)) {
Signals[0] = 1;
if(Sum(Signals+1,3) == 0)
enterLong();
} else if(peak(Trend)) {
Signals[0] = 1;
if(Sum(Signals+1,3) == 0)
enterShort();
}
}

function run()
{
set(PARAMETERS+TICKS+TESTNOW);
BarPeriod = 240;
LookBack = 500;
StartDate = 2002;
NumWFOCycles = 10;

if(ReTrain) {
UpdateDays = -1;
SelectWFO = -1;
}

while(asset(loop("AUD/USD","USD/CHF")))
while(algo(loop("TRND1A")))

{
if(strstr(Algo,"TRND1A") and strstr(Asset,"AUD/USD"))
tradeTrend();
else if(strstr(Algo,"TRND1A") and strstr(Asset,"CHF/USD"))
tradeTrend();
}

PlotWidth = 600;
PlotHeight1 = 300;
}

So here are my questions, which I hope someone can help me with:

1) As you can see, the algo uses stops and take profit: SL 10*ATR, TP 20*ATR. Should these stops and limits appear on the broker's platform, or do they function internally within Zorro?

2) In line with the above, the algo opened two trades as follows:

[AUD/USD:TRND1A:L8153] Long 1@0.9113 Risk 345.
[USD/CHF:TRND1A:L8194] Long 1@0.9093 Risk 391.

a) the algo is trading 0.01 lots – I assume the risk is in pips not $?

b) in the case of of AUDUSD, 10*ATR at the time of opening the trade was 345 pips, so this is correct, but 10*ATR at the time of opening USDCHF was 220 pips, so this obviously doesn't match Zorro's risk – what is going on here?

c) should take profit appear in the Zorro window as well as risk? i.e. how do I know Zorro is getting the TP right, esp. since it apparently didn't get the SL right in the case of CHF?

d) In the case of both trades, stops did appear on my broker platform when the trades opened, but the stops are completely unrealistic and don't align in any way with ATR:

- in the case of AUDUSD the stop is 0.39362, compared with open price of 0.9113, i.e. 5,177 pips away (15x the risk in the Zorro window)

- in the case of USDCHF the stop is 0.37616, compared with open price of 0.9093, i.e. 5,332 pips away (13.6 times the risk in the Zorro window and 24x what the risk should be)

What is going on with this? Also, no TP appeared on the broker platform. In case it matters, I haven't set up any risk or margin sliders or such.

3) On another note, how do I change the algo to trade 0.1 lots instead of 0.01?

I hope someone can help me with this. Many thanks in advance!!