Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 841 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Grid.c #449676
03/28/15 05:58
03/28/15 05:58
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline OP
Newbie
forexcoder  Offline OP
Newbie

Joined: Feb 2015
Posts: 45
Italy
Good morning everyone. I have some questions to ask about the code in the file Grid.c (in the folder 'Strategy'). First, if you go to take the test, there is an error in 'set (HEDGING);'. I think that the solution is 'Hedge = 2'. Then when it goes to do the loop: 'for (Price = 0; Price <Close + 5 * Grid; Price + = Grid)', at the beginning Price = 0 and then run: 'if (Price <Close and! FindTrade (Price, Grid, true))
enterShort (1, Price, 20 * Grid, Grid); '. Then 'Price = 200Pip' and then performs the same if. Then 'Price=400Pip' and performs the same if and so on until the end of the for statement. So do not ever place the pending orders over the 'Close', that is never run the statement 'else if(Price > Close...'. Is it correct? Thank You.

Re: Grid.c [Re: forexcoder] #449744
03/30/15 17:15
03/30/15 17:15
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, 'Hedge = 2' is correct - this will be fixed.

Pending orders are placed higher than the Close, though, because the for loop runs until the price is 5 grid lines above the close.

Re: Grid.c [Re: jcl] #449752
03/30/15 21:23
03/30/15 21:23
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline OP
Newbie
forexcoder  Offline OP
Newbie

Joined: Feb 2015
Posts: 45
Italy
Thanks Jcl for your reply!!! And excuse me for my English. But I don't understood how the program place the pending orders higher than the Close. The cycle is this:
Code:
for(Price = 0; Price < Close+5*Grid; Price += Grid)


Suppose we are using EURUSD, with last price 1,32, so Close=1,32.
So at the biginning of the cycle,
Price=0
Then, after the first cycle:
Price=Price+Grid=0+200PIP=0+200*0,0001=0+0,02=0,02
Then, the next cycle:
Price=0,02+0,02=0,04
As you can see there will be a lot of cycles before arriving to 1,32+5*200
Instead I think that the solution could be this:
Code:
for(Price = Close; Price < Close+5*Grid; Price += Grid)


And than it it would take another cycle to place the pending orders lower the Close:
Code:
for(Price = Close; Price < Close-5*Grid; Price -= Grid)


I hope I explained.
Thanks again.

Re: Grid.c [Re: forexcoder] #450131
04/07/15 08:33
04/07/15 08:33
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
No, the loop should begin with 0 and not with Close. If it began with Close, the grid lines would be at a different place whenever you restart the system. Beginning with a constant, such as 0, makes sure that you get the same grid lines regardless of the current price.

Re: Grid.c [Re: jcl] #450134
04/07/15 09:23
04/07/15 09:23
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline OP
Newbie
forexcoder  Offline OP
Newbie

Joined: Feb 2015
Posts: 45
Italy
I'm sorry but I do not understand what you say. If the price starts from zero than you would have the following:
suppose we are using EURUSD, with last price 1,32, so Close=1,32.
So at the biginning of the cycle, Price = 0 euro:
Price=0
Then, after the first cycle:
Price=Price+Grid=0+200PIP=0+200*0,0001=0+0,02=0,02
Then, the next cycle:
Price=0,02+0,02=0,04
As you can see there will be a lot of cycles before arriving to 1,32+5*200
Where I am wrong?

Re: Grid.c [Re: forexcoder] #450151
04/07/15 13:41
04/07/15 13:41
Joined: May 2013
Posts: 245
S
swingtraderkk Offline
Member
swingtraderkk  Offline
Member
S

Joined: May 2013
Posts: 245
you are not wrong, but the next line simply moves quickly on if price is below Close - 5*Grid



Code:
// find the lowest grid line
if(Price < Close-5*Grid) continue;


Re: Grid.c [Re: swingtraderkk] #450188
04/08/15 11:40
04/08/15 11:40
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline OP
Newbie
forexcoder  Offline OP
Newbie

Joined: Feb 2015
Posts: 45
Italy
Ok now it's clear. Thanks very much swingtraderkk. I have only a last question. Why is it necessary use the instruction '(TradeIsShort == IsShort)' in the:
'if((TradeIsShort == IsShort) and between(TradeEntryLimit,Price-Grid/2,Price+Grid/2))' ?
I think it is sufficient write only:
'if between(TradeEntryLimit,Price-Grid/2,Price+Grid/2)'
because it isn't necessary to know if a trade is short or long.
Is it correct?
Thanks a lot.

Last edited by forexcoder; 04/08/15 11:41.
Re: Grid.c [Re: forexcoder] #450192
04/08/15 14:01
04/08/15 14:01
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
(TradeIsShort == IsShort) checks only long resp. short trades. This allows you to have a long and a short trade pending on any grid line. Otherwise you had only either a long or a short trade, whichever was placed first.

Re: Grid.c [Re: jcl] #450205
04/08/15 21:11
04/08/15 21:11
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline OP
Newbie
forexcoder  Offline OP
Newbie

Joined: Feb 2015
Posts: 45
Italy
Now is all clear! Thanks a lot.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1