Grid Trading - dynamic

Posted By: danatrader

Grid Trading - dynamic - 07/01/20 17:15

I'd like to create a dynamic grid system and maybe someone can give me a starting point.

The grid should be created out of points that happened in the past, e.g. SMA10 cross SMA50 (really bad example, I got better things with more validity), the cross is the horizontal level to remember.
Later on, the levels if crossed by price with a certain condition, e.g. Momentum > x should trigger a trade.

Any help how to get started on something like that would be really nice.

Question is, how to remember the levels?
Any level crossed should loose validity, oldest to newer.

Would anyone here be interested to develop such a system together?
Posted By: Qw3rty

Re: Grid Trading - dynamic - 07/21/20 06:01

You can try the Grid trading system that comes with Zorro as a base and build on that.

// Grid trader

// find all trades at a grid line
bool findTrade(var Price,var Grid,bool IsShort)
{
int result = false;
for(open_trades)
if((TradeIsShort == IsShort)
and between(TradeEntryLimit,Price-Grid/2,Price+Grid/2)) {
result = true;
break_trades;
}
return result;
}

int run()
{
BarPeriod = 1440;
Hedge = 2; // allow long & short trades at the same time

EntryTime = LifeTime = 250; // close trades after 1 year
var Price, Grid = 200*PIP; // set grid distance to 200 pips
var Close = priceClose();

// place pending trades at 5 grid lines
// above and below the current price
for(Price = 0; Price < Close+5*Grid; Price += Grid)
{
// find the lowest grid line
if(Price < Close-5*Grid) continue;
// place not more than 200 trades
if(NumOpenTotal + NumPendingTotal > 200) break;
// place short trades below the current price
if(Price < Close and !findTrade(Price,Grid,true))
enterShort(1,Price,20*Grid,Grid);
// place long trades above the current price
else if(Price > Close and !findTrade(Price,Grid,false))
enterLong(1,Price,20*Grid,Grid);
}
}
Posted By: danatrader

Re: Grid Trading - dynamic - 07/21/20 10:35

Actually yes, that would be a start, but how would you memorize the levels based on price activity that happend in the past?
Use a series of the price levels.
How limit the amount of levels -> limit the series by it's length.

Yes, thank you that could be a start.
Posted By: Qw3rty

Re: Grid Trading - dynamic - 07/22/20 09:42

Grid trading seems to be more tricky to code for this very reason of dynamic entries based on past results. That's why a lot of grid strategies are based on moving averages or static gridlines 100pips apart.

I guess you could potentially store the values/condition in an array and enter the trade based on the historical key points e.g. if (price > array[0] or price > array[1] or price > array[2] etc.) then enter long
© 2024 lite-C Forums