Gamestudio Links
Zorro Links
Newest Posts
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
ZorroGPT
by TipmyPip. 04/08/26 17:08
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
4 registered members (PeWi, AndrewAMD, TipmyPip, Geir), 15,254 guests, and 21 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Geir, ondrej, mredit, vestriaa, Lukudo
19206 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,093
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,093
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