- 'Rolling' grid inputs: imagine this scenario. All your buy stop orders have filled and the market has screamed to the stars. This feature tells Desky to add a new stop order grid to take advantage of the market moving so strongly in your favour:
- RollingGrid: turns this feature on/off.
- MaxRolledTrades: this limits the number of trades to open market trades + GridSize.
Code: Select all
//Adding to the grid when there is a strong move in our favour and all the stop orders have filled
extern string rgi="--Rolling grid inputs --";
extern bool RollingGrid=false;
extern int MaxRolledTrades=20;
Code: Select all
extern string sep3="================================================================";
extern string gri="---- Grid inputs ----";
extern string ggi="-- General grid inputs --";
extern bool UseGridTrading=false;
extern GridTypes TypeOfGrid=Both;
extern int GridSize=5;
extern int DistanceBetweenTradesPips=30;
extern bool UseAtrForGrid=false;
extern ENUM_TIMEFRAMES GridAtrTimeFrame=PERIOD_D1;
extern int GridAtrPeriod=20;
extern double GridAtrDivisor=5;
//Pending order deletion following a FLAT or opposite direction signal.
extern string god="-- Pending order deletion inputs --";
extern bool DeletePendingOrdersOnFlatSignal=true;
extern bool DeletePendingOrdersOnOppositeSignal=true;
//Adding to the grid when there is a strong move in our favour and all the stop orders have filled
extern string rgi="--Rolling grid inputs --";
extern bool RollingGrid=false;
extern int MaxRolledTrades=20;
extern string gtp="-- Grid trades take profit --";
//This tells Desky to set the take profit for each trade at the open price of the next trade in the grid.
extern bool UseNextLevelForTP=false;
////////////////////////////////////////////////////////////////////////////////////////
double DistanceBetweenTrades=0;
////////////////////////////////////////////////////////////////////////////////////////
void DoPendingOrdersDeletionAndReplacement(string symbol, int signal, int pairIndex)
Press F7 and double click the resulting error message to take you to this line of code:
DoPendingOrdersDeletionAndReplacement(symbol, signal);
Add the same parameter so the code looks like this:
DoPendingOrdersDeletionAndReplacement(symbol, signal, pairIndex);
Go back to void DoPendingOrdersDeletionAndReplacement(string symbol, int signal, int pairIndex). Scroll down to this comment: "//if (UseGridTrading)" - comments are preceded by // and are in grey text. Insert this code above the comment:
Code: Select all
//Rolling grid. I have applied this to stop orders only - limit orders would not make sense.
if (RollingGrid)//Are we using this feature?
if (IsTradingAllowed(symbol, pairIndex) )//Make sure there is nothing to stop us trading eg spread
if (MarketTradesTotal > 0)//There are open trades
if (MarketTradesTotal + GridSize <= MaxRolledTrades)//A new grid will not exceed our maximum allowed
{
//Buy grid
if (BuyOpen)//There are market buy trades
{
//Buy grid
if (BuyStopsCount == 0)
{
SendBuyGrid(symbol, OP_BUYSTOP, HighestBuyPrice, Lot, GridSize);
}//if (BuyStopsCount == 0)
}//if (BuyOpen)
//Sell grid
if (SellOpen)//There are market sell trades
{
//Sell grid
if (SellStopsCount == 0)
{
SendSellGrid(symbol, OP_SELLSTOP, LowestSellPrice, Lot, GridSize);
}//if (SellStopsCount == 0)
}//if (SellOpen)
}//if (MarketTradesTotal + GridSize <= MaxRolledTrades)//A new grid will not exceed our maximum allowed