I am trying out the time frame functions in this case a weekly system
but I have run into some issues I am not sure how to fix.
The example system I am using is below.
TradeDelay=Param("TradeDelay",0,0,5,1);
SetTradeDelays(TradeDelay,TradeDelay,TradeDelay,TradeDelay);
RoundLotSize = 1;
Qty = Optimize("Quantity", 10, 1, 20, 1 );
Pct=100/Qty;
PositionSize = -Pct;
PositionScore = RSI();
SetOption( "ActivateStopsImmediately", True);
SetOption( "AllowPositionShrinking", True);
SetOption( "InterestRate", .05);
SetOption( "MaxOpenPositions", Qty);
SetOption( "WorstRankHeld", 10);
SetOption( "MinShares",1);
SetOption( "MinPosValue", 1);
SetOption( "PriceBoundChecking", True);
SetOption( "CommissionMode", 1);
/*0 - use portfolio manager commission table
1 - percent of trade
2 - $ per trade
3 - $ per share/contract */
SetOption( "CommissionAmount", .01);
SetOption( "AccountMargin", 100);
SetOption( "ReverseSignalForcesExit", True);
SetOption( "UsePrevBarEquityForPosSizing", True);
SetOption( "PortfolioReportMode", 0); /*- sets backtester report mode:
0 - trade list
1 - detailed log
2 - summary
3 - no output (custom only) */
//SetOption( "EarlyExitBars", 20);
//SetOption( "EarlyExitFee", 0);
//SetOption(" HoldMinDays", 28);
//SetOption( "EarlyExitDays", 20);
SetOption( "DisableRuinStop", False);
TimeFrameSet( inWeekly); // switch to weekly
range = Optimize( "Range", 8, 2, 10, 2 );
Ksmooth = Optimize("%K smooth", 2, 2, 4, 1 );
Dsmooth = Optimize("%D smooth", 2, 2, 4, 1 );
SlowK= StochK (range,Ksmooth);
SlowD=StochD(range,Ksmooth,Dsmooth);
Buy=Cross( StochK (range,Ksmooth), StochD (range,Ksmooth,Dsmooth) );
Sell = Cross( StochD(range,Ksmooth,Dsmooth), StochK(range,Ksmooth) );
Plot(Slowk,"%K",colorBlue);
Plot(SlowD,"%D",colorRed);
TimeFrameRestore(); // restore time frame to original
The goal is to hold for at least a minumum of 1 week then sell if a
signal is generated at the next signal whenever that happens. What
happens quite often though is that it will Buy on the open of the
week and then if a Sell signal is generated during the following week
it will show a closing date of the end of the week but the exit price
is the opening price of that exit week. I have played with the delay
settings but cant't seem to correct it. Any suggestions on how to fix
is appreciated.
Also, how complicated would it be to exit on the day a Sell signal is
generated using a weekly system versus having to sell a week later?
Trying to grasp the functions and but not quite there yet. If its a
custom backtestor item I am not quite there yet in my learning curve.
DM