Gold Overnight Trading Strategy (Amibroker And Tradestation Code)

The original article can be found here.

Login in plain English:

Strategy 1:

  • Buy the close
  • Sell the next day’s open

Strategy 2:

  • Buy the open
  • Sell at the close on the same day

Amibroker code:

setOption("holdminbars",1);

Buy= C>0 ; //close biggerthan zero - forced entry
buyPrice=Close;
Sell= C>0;   //forced exit next day
sellPrice=Open ;
//setOption("holdminbars",1);  //we disable this option to force a day trade

Buy= C>0 ;
buyPrice=Open;
Sell= C>0;   //forced exit next day
sellPrice=Close ;

Tradestation code:

{
Strategy - Gold overnight
https://www.quantifiedstrategies.com/lessons/gold-overnight-trading-strategy-amibroker-code/
}

buy this bar on close;
sell next bar on open;
{
Strategy - Gold overday
https://www.quantifiedstrategies.com/lessons/gold-overnight-trading-strategy-amibroker-code/
}

buy next bar on open;
sell this bar on close;