Skip to main content

Trade Once A Month for Amibroker (AFL)

mrcashflow over 5 years ago Amibroker (AFL)

  • Rating:
    5 / 5 (Votes 1)
  • Tags:
    amibroker

You can use this “switch code” to trigger a trade that will execute only once a month.

Indicator / Formula

Copy & Paste Friendly

This can be used as part of your trading system


/////Month Switch 

MonthCalc = Month();
newMonth = MonthCalc != Ref(Month(),-1);
monthswitch = 0;
monthswitcharray[0] = monthswitch[0];



for( j = 1; j < BarCount; j++ )
{
 
 monthswitch = monthswitcharray[j-1];
 
 
 if(newmonth[j] == 1)
 
 {
 
 monthswitch = 1; 
 
 }
 
 
 if (monthswitch == 0)
 
 
 {
 
 Buy[j] = 0;
 Short[j] =0;
 
 }
 
 
 
 if (Buy[j] OR Short[j]) 
 
 {
 
 monthswitch = 0;
 
 }
 
 
 monthswitcharray[j] = monthswitch;
 
 
 
 
 
}

3 comments

2. sersev
over 5 years ago
/////Month Switch 
 
MonthCalc = Month();
newMonth = MonthCalc != Ref(Month(),-1);
monthswitch = 0;
monthswitcharray[0] = monthswitch[0];
 
 
 
for( j = 1; j < BarCount; j++ )
{
  
 monthswitch = monthswitcharray[j-1];
  
  
 if(newmonth[j] == 1)
  
 {
  
 monthswitch = 1; 
  
 }
  
  
 if (monthswitch == 0)
  
  
 {
  
 Buy[j] = 0;
 Short[j] =0;
  
 }
  
  
  
 if (Buy[j] OR Short[j]) 
  
 {
  
 monthswitch = 0;
  
 }
  
  
 monthswitcharray[j] = monthswitch;
  
  
  
  
  

Leave Comment

Please login here to leave a comment.