Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, degenerate_762, AndrewAMD, ozgur), 774 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: The7 strategy [Re: jcl] #410594
11/05/12 23:17
11/05/12 23:17
Joined: Nov 2012
Posts: 4
Colombia
M
maudur Offline
Guest
maudur  Offline
Guest
M

Joined: Nov 2012
Posts: 4
Colombia
Originally Posted By: jcl
If you want to experiment with this strategy, here's another suggestion:

...
Try to run the system with different BarOffset values. With no BarOffset, Zorro starts daily bars at GMT midnight, so with BarOffset you can determine the minute into the day when the candle opens. If it's a seasonal effect, the system will only work within a certain BarOffset range that should be different for every currency. F.i. AUD/USD is mostly traded in the Sydney season and USD/CAD mostly in the New York season.

By using individual bar offsets per currency you can most likely get even more profit out of the system. Keep in mind to set BarOffset first before calling asset().


JCL,

In the code you have:

while(asset(loop("EUR/USD","AUD/USD","USD/CHF")))

How do you set BarOffset before calling asset in it loop? Inside the while body you already called asset.

Thanks.

Last edited by maudur; 11/05/12 23:18.
Re: The7 strategy [Re: maudur] #410595
11/05/12 23:22
11/05/12 23:22
Joined: Oct 2012
Posts: 75
H
hughbriss Offline
Junior Member
hughbriss  Offline
Junior Member
H

Joined: Oct 2012
Posts: 75
Just put...

BarOffset = whatever;
while(asset(loop("EUR/USD", etc)))

Re: The7 strategy [Re: hughbriss] #410596
11/05/12 23:29
11/05/12 23:29
Joined: Nov 2012
Posts: 4
Colombia
M
maudur Offline
Guest
maudur  Offline
Guest
M

Joined: Nov 2012
Posts: 4
Colombia
Originally Posted By: hughbriss
Just put...

BarOffset = whatever;
while(asset(loop("EUR/USD", etc)))


Thank you Hugh, but my question is:

I understand the Loop executes the body of the while for each pair, so to put the statement before the while, not setup BarOffset for each pair. What I need is to place a Baroffset different for each pair as suggested by JCL.

Thanks.

Re: The7 strategy [Re: maudur] #410599
11/06/12 05:46
11/06/12 05:46
Joined: Oct 2012
Posts: 75
H
hughbriss Offline
Junior Member
hughbriss  Offline
Junior Member
H

Joined: Oct 2012
Posts: 75
Sorry, I misunderstood. That is a tricky one.

Re: The7 strategy [Re: hughbriss] #410622
11/06/12 12:50
11/06/12 12:50
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You have then not only different assets, but also different bar offsets. So you can not just set the asset directly in the while parameter, but must store the instrument string f.i. in another string, and use it to set Baroffset and call asset() inside the loop:

Code:
string myAsset;
while(myAsset = loop("EUR/USD","AUD/USD","USD/CHF"))
{
  if(myAsset == "EUR/USD") BarOffset = 123;
  if(myAsset == "AUD/USD") BarOffset = 456;
  ...
  asset(myAsset);



I haven't tried this myself, but theoretically it should work this way. Mind the '=' and '=='.

Re: The7 strategy [Re: jcl] #411890
11/20/12 19:35
11/20/12 19:35
Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
P
PriNova Offline
Junior Member
PriNova  Offline
Junior Member
P

Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
I have another question which makes me crazy about the logic how Zorro handles BarOffsets with Pricedata. Here is an example code and a picture to compare.

this is only an experiment to understand the logic. i took the The7 Strategy Signals.

So the Strategie says for a Short Position. Check if OPEN of the last Candle (priceOpen(1)) is above than EMA_High(1) AND the CLOSE of the last candle (priceClose(1)) is below EMA_High(1) AND the CLOSE of the last candle (priceClose(1)) is above EMA_Low(1).

So here is the code and compare the TimeOffset in the two codes:

Code:
function run()
{
	StartDate = 2012;
	BarPeriod = 60;
	var* priceH = series(priceHigh());
	var* priceL = series(priceLow());
	var *EMAHigh = series(EMA(priceH,5));
	var *EMALow = series(EMA(priceL, 5));
	
	
	//Short 0
	if(priceOpen(1) > EMAHigh[0]
	and priceClose(1) < EMAHigh[1]
	and priceClose(1) > EMALow[1])
	{
		enterShort();
	}
        PlotBars  =150;
	plot("EMAH", EMAHigh[0], 0, BLUE);
	plot("EMAL", EMALow[0], 0, BLUE);
}



And here is the resulting picture. Interesting to see, that the orders are 1 Candle too late.




But if i change the code-logic, which makes me trouble in my head, to this:

Code:
function run()
{
	StartDate = 2012;
	BarPeriod = 60;
	var* priceH = series(priceHigh());
	var* priceL = series(priceLow());
	var *EMAHigh = series(EMA(priceH,5));
	var *EMALow = series(EMA(priceL, 5));
	
	
	//Short 0
	if(priceOpen(0) > EMAHigh[0]
	and priceClose(0) < EMAHigh[0]
	and priceClose(0) > EMALow[0])
	{
		enterShort();
	}
	PlotBars  =150;
	plot("EMAH", EMAHigh[0], 0, BLUE);
	plot("EMAL", EMALow[0], 0, BLUE);
}



Then the results are like in this picture:



And the Orders are exactly at the candle, where they shoudl be.
I don't understand this logic, cause like in the first code, this is how MT4 handles the logic naturally:

MT4:
1. If new candle opens
2. check conditions on last candle, for example MT4-Code: High[1]
3. execute Order on actuall candle with the next tick

Zorro:
1. exactly at close of actual candle
2. check conditions on this candle, which is like the recent last candle in MT4, Zorro: priceHigh(0)
3. execute order on new candle with first tick.

Overall, this is a turnaround in my head. I see problems with some logics, where a trade must be executed on the actual candle (!)befor it closes. for example the actual candle reaches a defined body-size, which implies it as an impulsive candle and i'd like to trade it immediatly instead waiting for candle close.
I read in the manual, that if Zorro is in TRADINGMODE, that the Orderexecution is TICK-based, but how could i calculate the Body from the recent Open to the actual Tick-Price?
This could not be possible, because priceOpen(0) gives me the Openprice of the already closed candle (Open(1) in MT4)

i hope that someone understand what i try to explain here.

Last edited by PriNova; 11/20/12 19:37.
Re: The7 strategy [Re: PriNova] #411897
11/20/12 23:45
11/20/12 23:45
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
All existing trade platforms follow the same simple logic. When a trade signal is generated from the current candle, the order is executed at the next tick, which is the Open of the next candle. You can obviously not execute a trade in the middle of the same candle that generated the trade signal, at least not without a time machine.

If you want to execute a trade in the middle of a candle, in your example by using an entry price limit, you must have generated the trade signal from the candle before. An entry condition can only delay your trade, but can not make it happen earlier.

Re: The7 strategy [Re: jcl] #411901
11/21/12 06:09
11/21/12 06:09
Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
P
PriNova Offline
Junior Member
PriNova  Offline
Junior Member
P

Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
Originally Posted By: jcl
All existing trade platforms follow the same simple logic. When a trade signal is generated from the current candle, the order is executed at the next tick, which is the Open of the next candle. You can obviously not execute a trade in the middle of the same candle that generated the trade signal, at least not without a time machine.


this is partially not true and i will show it in a video i make now, because it has nothing to do with a time-machine.

if a trade signal is generated from the current candle, the orders is executed with the next tick, BUT it hasn't to be the open of the next candle. if i'm willing my order could be executed in the same current candle.

pictures are more than words.

Last edited by PriNova; 11/21/12 06:12.
Re: The7 strategy [Re: PriNova] #411904
11/21/12 07:38
11/21/12 07:38
Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
P
PriNova Offline
Junior Member
PriNova  Offline
Junior Member
P

Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
Here is the video now: i hope it is now clearer what i mean, that execution could happen in the current candle as many orders i like and that condition-checks are made in the recent candle indexed at 1.
this is why in my first code the order is executed 1 Candle too late.

[video:youtube]http://www.youtube.com/watch?v=N6Jg-vz5IYQ[/video]


Last edited by PriNova; 11/21/12 07:43.
Re: The7 strategy [Re: PriNova] #411905
11/21/12 08:18
11/21/12 08:18
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Maybe there are some misunderstandings of the concepts of candles and bars.

- Candles are counted 0, 1, 2 and so on. 1 is not the recent candle as you seem to think, 0 is the recent candle. When candles consists of several bars, the 0 candle can be partial.

- The run function is executed at the end and not in the middle of a bar. A bar has no "middle". Only a candle can have a middle. If you want a run in the middle of a candle for some reason, just make the bar period shorter or the candle time frame longer so that a candle covers several bars.

This is however unusual for a strategy, so I'm not sure if that's what you really want. I have more the impression that you just mean an entry limit.

For details look in the manual on the following pages:

http://zorro-trader.com/manual/en/bar.htm
http://zorro-trader.com/manual/en/run.htm
http://zorro-trader.com/manual/en/barperiod.htm

I hope this helps; otherwise just let me know what you do not understand.

If you think you have to trade in the middle of a candle for some reason, and you don't know how to do that, I'll help. Just open a new thread, as this has nothing to do with the "7" system, and explain the system that you have in mind. There are often several ways to a certain solution.

Page 2 of 3 1 2 3

Moderated by  Petra 

Gamestudio download | chip programmers | 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