Gamestudio Links
Zorro Links
Newest Posts
[MED] Import from FBX (2010) missing!!!
by USER0328. 09/03/26 18:03
Purchase A8 full licence version
by ukgamer. 08/30/26 14:27
ZorroGPT
by TipmyPip. 08/29/26 06:56
Retrieve optimize() variables order (edited)
by NorbertSz. 08/25/26 13:24
Max Number of Strategies in /Strategy folder
by Martin_HH. 08/17/26 07:54
Pause button for evaluation shell?
by AndrewAMD. 08/13/26 17:16
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 08/10/26 12:46
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (DexLoomer, 2 invisible), 2,126 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Student_64151, Koti
19230 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,133
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

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