Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,631 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
TMF questions #432420
11/06/13 05:47
11/06/13 05:47
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
1. Suppose I have a situation where the market is between a limit buy entry and a limit sell entry and I am happy to take both. If I set up the code like I have shown below, does the TMF evaluate the IF statement on each tick using the previously fixed indicator values? Or do I need to split out the Long and Short trades into separate algos?

My concern is with the double use of the Entry parameter. FYI, the market is always between Indicator1[1] and Indicator2[1]. In the attached screen shot, the red channel is the Indicator and the second bar is the entry bar. As you can see, we can go long and short on the same bar.

In other words, Does Zorro continue evaluating the algo after entry is made in one direction just in case entry can occur in the other direction? I assume the market can dance around a limit order price but we only want to enter at that location once. So does the TMF continue running the algo for entry in the other direction?

var shortentry = Indicator1[1];
var longentry = Indicator2[1];

if(Indicator1[1] < Indicator1[2])
{
Entry = shortentry;
enterShort();
}
else if (Indicator2[1] > Indicator2[2])
{
Entry = longentry;
enterLong();
}

2. Extension question - Understanding Stop and Trail in the TMF - Is Stop set once in the trade even if the algo is assessed at each tick / new bar in the trade?

Is it Trail that is used to move the stop in the direction of the trade? And is it true that the TMF will not move Trail further away even if the algo tries to set a value that is further away?

3. Is it possible to output the initial Stop to the result file or a text file (I believe the later is possible but I have not looked at how.) How?

Is it possible to calculate a trade parameter after the trade has closed and output that to the results file or a text file, e.g. the expectancy of the trade which is the result / stop, i.e. reward to risk ratio for the trade?


These questions seem wordy, but basically I am just clarifying my understanding of the TMF.

Thanks in advance.

Attached Files
Screen1.png (115 downloads)
Re: TMF questions [Re: DMB] #432434
11/06/13 10:00
11/06/13 10:00
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
BONUS and possibly more important question - Can anyone tell me why Zorro keeps entering at the Close instead of the red line which is the Dot11High on limit?

Quote:

function ChannelSwing()
{

vars Price = series(price());
vars High = series(priceHigh());
vars Low = series(priceLow());
vars Close = series(priceClose());

vars Dot11High = series((Close[0]+High[0]+Low[0])/3*2-Low[0]);

var shortentry = Dot11High[1];
var shortstop = 100*PIP;
var shorttarget = 100*PIP;


if(Dot11High[0] < Dot11High[1])
{
Entry = shortentry;
Stop = shortstop;
TakeProfit = shorttarget;
enterShort();
}

plot("Dot11High",Dot11High[1],0,RED);

}

function run()
{
set(LOGFILE+TICKS+PLOTNOW);
BarPeriod = 1440;
LookBack = 100;


NumYears = 2;
Weekend = 2;


while(asset(loop("EUR/USD")))
while(algo(loop("ChannelSwing")))
{
if(Algo == "ChannelSwing")
ChannelSwing();
}

PlotScale = -10;
PlotWidth = 2000;
PlotHeight1 = 500;

}

Re: TMF questions [Re: DMB] #432437
11/06/13 11:07
11/06/13 11:07
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
1. Yes, a TMF executes its code every tick, including if-statements in the code.

2. The "Stop" and "Trail" variables are only used when enterLong/Short is called, otherwise they have no meaning.

3. You can output any variable to a file with a sprintf statement. For caluclating parameters of closed trades, use an all_trades loop.

Re: TMF questions [Re: jcl] #432456
11/06/13 13:47
11/06/13 13:47
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
Thanks for this answer.

On my code from my second post, it appears that my calculation of the Dot11High is creating a series that can be plotted, but extracting the values out of the series to use in the IF statement and to assign the Entry is not working. I have tried everything I can think of, like using different offsets in the [], but I can't figure out what I am doing wrong.

Thoughts anyone? This seems like one of those dumb simple problems.

Re: TMF questions [Re: DMB] #432459
11/06/13 14:01
11/06/13 14:01
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
I am not sure that I understand the problem. As far as I see you're accessing the series correctly.

Only if you want to use the same series in a TMF, you need a global variable. The difference between global and local variables is explained in the "Variables" chapter. Declare the vars outside the function:

vars Dot11High;

and set it in your run function:

Dot11High = series((Close[0]+High[0]+Low[0])/3*2-Low[0]);

Then you can access it also in a TMF.

If you get wrong values, print them all together in the log - you can then see which value is other than you expect.

Re: TMF questions [Re: jcl] #432463
11/06/13 14:32
11/06/13 14:32
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
Attached is a results chart for the above code. You can see that the Dot11High series is plotted with the red line but attempts to have a limit entry at that red line fails, as does the IF condition, resulting in an entry at every Close. This is all within the algo function. Are you saying that I need to create the series in the run() function?

If you get some understanding of the problem from the attached chart, great. Otherwise I will keep trying to understand the variables tomorrow.

Attached Files
Untitled.png (9 downloads)
Re: TMF questions [Re: DMB] #432506
11/07/13 01:38
11/07/13 01:38
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
This is driving me crazy! If I declare it in Run(), then I get the error that it is not declared in ChannelSwing(), obviously because ChannelSwing() has to be listed before Run(). But I really don't understand why I should have to do that. ChannelSwing() is capable of plotting a series called Dot11High. But does this series disappear every time ChannelSwing() is called (every tick?) because it is local?

Maybe someone can write me the code for the simple trading rule below. The chart in my previous post shows the red line that indicates the limit entry level. Once I have a functioning basis I can expand it to my full trading idea....

The upper channel value has the formula:

Dot11High = ((Close + High + Low)/3) * 2 - Low

It's extrapolating the Low and average HLC to the next bar. Thus it is known and fixed when the new bar opens.

IF Yesterday's Dot11High is less then the previous day's Dot11High
THEN place a limit entry SELL order at yesterday's Dot11High.

Then for simplicity of this example, place a Stop and Target at 100 pips.

Thanks in advance to anyone who can do me this huge favour.

Re: TMF questions [Re: DMB] #432510
11/07/13 07:19
11/07/13 07:19
Joined: May 2013
Posts: 627
Bonn
Sundance Offline
User
Sundance  Offline
User

Joined: May 2013
Posts: 627
Bonn
The first thing I see is to better insert a prototype function on top of the script and to move the ChannelSwing function to the bottom/below the run function.

void ChannelSwing();


When you can plot the Dot1High values in the ChannelSwing function then I would use the printf function to output the Dot11High[1] and Dot11High[0] values to the Zorro window.


At first sight I don't know if this line is correct:

vars Dot11High = series((Close[0]+High[0]+Low[0])/3*2-Low[0]);

I think it should be:

vars Dot11High = series((Close+High+Low)/3*2-Low);


Or you can define the Dot vars directly:

var Dot11High0 = (Close[0]+High[0]+Low[0])/3*2-Low[0];
var Dot11High1 = (Close[1]+High[1]+Low[1])/3*2-Low[1];

and use them accordingly.


But it also could be that I just wrote totally crap cause I have a headache this morning... :-(


see you

Re: TMF questions [Re: Sundance] #432513
11/07/13 08:42
11/07/13 08:42
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
Well, I think we need pointers on the Close, High and Low, according to the error message. The pointer being the [] bit.

When I use normal variables like you suggest the IF statement works a little better. Still not perfect for some reason. It seems to be a day late. Normally one would just adjust the pointers. But they are already 0 and 1. Anyway, I will keep playing with that one.

The bigger problem is why is the entry occurring at the close of every bar that meets the condition rather than a limit order at Dot11High[0]? The only exception is when the close is above Dot11High, the previous Dot11High becomes a stop entry, a day late.

As for the order in which to place scripts, this is something I totally don't understand. I am just following the basic format in the tutorials. I guess I also don't understand arrays. I have the Dot11High charted on my charting software. I can confirm the chart is correct and that each value is known when the bar opens (the live changing value is one bar in the future.) But I can't reference the array correctly or get the the value to be a limit order.

I might have to go commercial on this. Pay someone to create the basic strategy so that I have a correct basis to work with.

Re: TMF questions [Re: DMB] #432514
11/07/13 08:50
11/07/13 08:50
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
Actually, the IF condition is working correctly. It's the enterShort that is off. The rest above is correct...when the close is below the Dot11High, the market enters on close whether or not the markets gets to Dot11High. When it gets there and the close is above the Dot11High it places the order as a stop entry the next day. ???????

Page 1 of 2 1 2

Moderated by  Petra 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1