Some help please with grid level coding.

 

Dear members..

I am trying to create a new ea based on a newly selfdesigned system.

And I like some help to get started with it.

I have coded some personal ea's based on crossings, however this subject for the new system is new for me in programming.

The system I designed is completely without of use of any indicator and is a trend trading based system.

You can trade it manually, but man, that would take many continues hours behind the screen..and guess what.. I dont want to do that with a full time job and three kids .

I designed this system a long time ago, and somehow, recently I came across a Renko system, and I never understood what that was.. hah was I in for a suprise..that was the basics of my system!

You see, 90+ precnt of the traders trade of their basic time charts. The daily, , weekly, 5 minute, or whatever timeframe they like with their system. So this one guy spoke to me and said, I should not trade with inidicators, but I should trade on price action only. And he did not mean the way a candle looks like.. He really meant the price itself.

And I never understood him how you could do that.

So after a lot of thinking, working with fib's RSi and other indicators, which none of them helped of course, this bright moment came to me, and I said to myself. What if I think like a bank or like some other institute? And I remembered some guy from BoJ saying, if we reach that certain pricelevel we are going to intervent.. So alle parts fell on their place, and I saw the big people trading on price.

So I came up with this idea of slicing the chart into horizontal levels..20, 30 , 40 or 50 pips. Whatever suits you.

As soon as price moves up 2 levels, we go long, and as soon as it moves two pricelevels down, we go short.

And we don't get out ever!! We do not work with indicators, we do not work with targets, or with stoplosses (because your stoploss is equal to your reversal signal) We just react on price hitting a pricelevel.

For example, we decide to slice our chart into 20 pips and the price is 1.3046 for example at the moment, and it came down from 1.3085. which was the last top from the previous upmove.

So, we have a price level at 1.3080, 1.3060, 1.3040, 1.3020, 1.3000 and so on..and ofcourse up and down.

I price at that moment would go up again towards 1.3100 for example, we still would be in the uptrend as price did not break the 1.3040 level which is 2 levels lower as 1.3080. But when is does not go back up, but still moves downwards, and breaks the 1.3040 level, we would have broke 2 levels and that is the reversal signal to close the long position if we had one, and to go short. So now we are short on 1.3040 and our new reversal level has become 1.3080.(stoploss and long position).

If price goes down and reaches 1.3020 our new reversal level is .13060.

And so on, and on and on..

At this moment I am in the posession of the indicator Grid Builder, which shows me those price levels on the screen.

Yes I know, an indicator, and I said I dont use indicators,.. well this one is just to visualize the price a bit easier.

So here comes my question, is someone out there who has some code which I could start with to calculate the privelevels, and which I can use tot trigger my Buy and Sell functions with?

Or is someone out there who wants to give me a startup with some simple examples how to deal with this?

thank you very very much!

greetings

Jonkie76

 

Just download one of the many grid trading EA's and check out the code. Better still just use one of them as the code will have most likely been tested and debugged and coded by a decent programmer.

You may also want to read up on the possible issue that can arise when trading grid systems.

Good luck

Lux

 

Just found this thread:

JLPi Grid EA

https://www.mql5.com/en/forum/176535

 

tx Guys, I wil take a look a those recommendations.

@ LuxInterior, what kind of issues you are talkin' about?

I am not trading the grid as with the close of a candle or something like that, or to keep buying bigger lotsizes like MartinGale as price does not go in your direction. It's just a very simple price level trading system based on trend trading and on the tic..

I did some manual backtesting, and made around 2k pips on aud/usd this year, and something like that on eur/usd.

I have backtested a few currency pairs, and none of them were fails so far.. so that's why I need this ea to do some forward testing on a demo account before going live.

So far thank you very much for the tips, I see what I can dig up over there!

 

tx for the progeamm newdigital.. it made an light go on in my head ;-)

So I came up with my own code which suited me best.

I divide the current price bij the interval I uase for the grid.

The value of that result, I round off to 1 or 3 digits if the currency is 2,3,4 or 5 digits..

After the roundoff I multiple that result again with the gridvalue.

This result gives me the nearest Grid Level according to the currentprice.

Than I check if price is above or below it and I put the result in a certain Variable.

See the example below (comment is in Dutch, sorry for that)

NearestGridLevel=(Bid/Interval);

StringNearestGridLevel=DoubleToStr(NormalizeDouble(NearestGridLevel,RoundOff),Digits); // Dichtsbijzijnde gridlevel vaststellen. Dit kan boven of onder de huidige prijs liggen

NearestGridLevel=StrToDouble(StringNearestGridLevel); // afgeronde string waarde uit de berekening in de double variabele omzetten

NearestGridLevel=NearestGridLevel*Interval; // Berekende afgeronde value keer Interval geeft de dichtsbijzijnde gridlevel

if(NearestGridLevel>Bid) // Ligt de dichtsbijzijnde level boven de huidige prijs?

{

UpLevel=NearestGridLevel; // Zo ja, dan is dit de UpLevel,

DownLevel=UpLevel-Interval; // en ligt de Downlevel er xx pips onder (xx = waarde van de interval)

}

else

{

DownLevel=NearestGridLevel; // Zo nee, dan is dit de DownLevel,

UpLevel=DownLevel+Interval; // en ligt de Uplevel er xx pips boven (xx = waarde van de interval)

}
Reason: