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
2 registered members (AndrewAMD, TipmyPip), 12,420 guests, and 5 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
Coding gap trading strategies #421047
04/09/13 05:04
04/09/13 05:04
Joined: Nov 2012
Posts: 19
B
Boris Offline OP
Newbie
Boris  Offline OP
Newbie
B

Joined: Nov 2012
Posts: 19
I am back again. I have been working with zorro for a few months now and I was very happy with its performance.

I am currently trying to begin coding a very simple strategy that exploits the natural tendencies of gaps in price over the weekend to close. But of course I am having trouble creating the code.

I need the computer to compare the opening price on Sunday 5pm to the closing price at the prior Friday 5pm.

So looking through the manual I figure it should be something along these lines perhaps.

If (current bar's opening time is equal to 5pm EST Sunday night) then (subtract fridays 5pm EST close price) to generate a value called GAP

if abs(GAP) > some value we trade and if less than that value we do nothing

If we trade I will use this GAP value to calculate the entries, stops and limits.



I was confused about coding the first part, the comparison. Would this work:

If hour(0) = 5 and dow(0) = 7 then I would calculate a variable designated GAP like this:

GAP = OpenPrice(0) - timeOffset(ET,1,16,0)

Then I would use this GAP variable further down to decide on whether I will place a trade and how to place it.

Is this the way to code this? Any ideas or advice would be greatly appreciated.

Re: Coding gap trading strategies [Re: Boris] #421069
04/09/13 13:47
04/09/13 13:47
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
No, the price difference from Friday 5pm to Sunday 5pm ET is calculated like this:

Code:
if(dow() == SUNDAY && lhour(ET) == 5) { 
  int FridayBar = timeOffset(ET,SUNDAY-FRIDAY,5,0);
  var PriceChange = priceClose(0) - priceClose(FridayBar);
  ...
}



Re: Coding gap trading strategies [Re: jcl] #421435
04/17/13 09:06
04/17/13 09:06
Joined: Nov 2012
Posts: 19
B
Boris Offline OP
Newbie
Boris  Offline OP
Newbie
B

Joined: Nov 2012
Posts: 19
Thank you very much JCL.

Your help is indispensable.

Re: Coding gap trading strategies [Re: Boris] #421676
04/22/13 20:11
04/22/13 20:11
Joined: Nov 2012
Posts: 19
B
Boris Offline OP
Newbie
Boris  Offline OP
Newbie
B

Joined: Nov 2012
Posts: 19
Well I coded what I wanted and it is compiling but when it runs it stops at the first execution. I am not sure what is wrong.

function run()
{
set(NFA + PLOTLONG);
BarPeriod = 60;
if(dow() == SUNDAY && lhour(ET) == 5) {
int FridayBar = timeOffset(ET,SUNDAY-FRIDAY,5,0);
var PriceChange = priceOpen(0) - priceClose(FridayBar);


if (abs(PriceChange) > 19 && priceOpen(0) > priceClose(FridayBar))



enterShort();
Stop = abs(PriceChange);
TakeProfit = abs(PriceChange);

if (abs(PriceChange) > 19 && priceOpen(0) < priceClose(FridayBar))



enterLong();
Stop = abs(PriceChange);
TakeProfit = abs(PriceChange);

}





}


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