The following plots a 1 (TRUE) on the first day of the month.
The last day of the prev month is one bar back from the 1.

FOM = Month() != Ref(Month(),-1);
Plot(Fom,"FirstOfMonth",1,1);
Plot(FOM == 0 AND Ref(First,1) == 1,"LastDayOfMonth",colorRed,1);

The code looksahead ... that shouldn't matter for BT if you use it carefully.

--- In [email protected], "Patrick" <patsgreatde...@...> wrote:
>
> I want to testing buying and selling based on months. Using the very simple 
> forumla below will not work (month end mainly) if there is no trading day on 
> the 28th. 
> 
> Is there a way to write to code... "Buy on the first trading day of the 
> month, and sell on the last trading day of the month" ??
> 
> 
> MO = 1;
> Buy = (Month() == MO) AND(Day() = 1 );
> Sell = (Month() == MO) AND (Day() = 28);
>


Reply via email to