[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] DayofWeek function help.



PureBytes Links

Trading Reference Links

Hi, need some help to get my head around DayofWeek() function.

Using the following code I get buys on Wednesdays and not Mondays? Can 
someone see what I am doing wrong?

TIA....Keith

Filter = 1;                                     /* for scanning purposes */

SetBarsRequired(100000,100000);              /* Load 100,000 bars */
SetTradeDelays(1,1,0,0);                     /* I will get buy/sell 
signals after EOD and trade on the OPEN */
Total_Equity = 200000;                         /*Param("Total Equity", 
300000, 100000, 300000, 25000) */
SetOption("InitialEquity", Total_Equity);
Max_Pos = Param("Max Positions",  100,  10,  200,  1);
SetOption("Maxopenpositions", Max_Pos);
SetChartOptions(1,chartShowDates, chartShowArrows);

/* RISK MANAGEMENT & POSITION SIZING*/

Equity_per_Trade = 0.1; /* Maximum of 10% of Equity invested in any trade */
Equity_at_Risk = 0.01;     /* Maximum of 1.00% of current equity risked 
in any trade */
Risk_using_ATR = Param("Risk using ATR", 3, 1, 4, 0.05);

Max_Equity_per_Trade = Equity_per_Trade * Total_Equity;
Max_Risk_per_Trade = Equity_at_Risk * Total_Equity;

PositionSize_using_ATR = Max_Risk_per_Trade / Nz(Risk_using_ATR * ATR(14));
PositionSize = IIf(PositionSize_using_ATR >= Max_Equity_per_Trade, 
Max_Equity_per_Trade, PositionSize_using_ATR);

// Buy CONDITIONS //

Buy = C > Ref(C,-30) AND C < Ref(C,-9) AND DayOfWeek() == 2;  
BuyPrice = O;

// MONEY MANAGEMENT //

Sell = 0;
SellPrice = C;

// STOPS //

Equity(1);

/*
1 - regular exit
2 - Max. loss
3 - profit target
4 - trailing
5 - n-bar stop
6 - ruin stop
*/
     ApplyStop(stopTypeNBar, stopModeBars, 1 , exitatstop = 0, volatile 
= False);