Page 1 of 1

Premarket reference Strategy

Posted: Oct 28 2020
by newdesigner
I have a basic MA entry strategy where a specific condition/criteria is to happen during Premarket Hours. See code below.
The intention is not to send orders during the premarket period only to send orders during the regular session if the premarketcriteria and the regular session criteria are both true. For some reason it is not generating orders. Please help.
Thanks

Code: Select all

Inputs: Barsago(5); variables: intrabarpersist bool PreMarketCriteria(false); PreMarketCriteria = false; if Time > 810 and Time < 920 and Average(Close, 30) < Close then begin PreMarketCriteria = true; end else begin PreMarketCriteria = false; end; if Time > 940 and Time < 1600 and PreMarketCriteria and Average(Close, 5) < Close[Barsago] and MarketPosition = 0 then begin Buy ("LEMAXTIME") Next bar at Market; end; // Built in Stops and Targets SetStopLoss( 30 ) ; SetProfitTarget( 30 ) ; // Set Exit on Close for Backtesting SetExitonClose;

Re: Premarket reference Strategy  [SOLVED]

Posted: Oct 28 2020
by TJ
Try this:

Code: Select all

Inputs: Barsago(5); variables: intrabarpersist bool PreMarketCriteria(false); //PreMarketCriteria = false; if Time > 810 and Time < 920 then begin if Average(Close, 30) < Close then begin PreMarketCriteria = true; end else begin PreMarketCriteria = false; end; end; if Time > 940 and Time < 1600 and PreMarketCriteria and Average(Close, 5) < Close[Barsago] and MarketPosition = 0 then begin Buy ("LEMAXTIME") Next bar at Market; end; // Built in Stops and Targets SetStopLoss( 30 ) ; SetProfitTarget( 30 ) ; // Set Exit on Close for Backtesting SetExitonClose;

Re: Premarket reference Strategy

Posted: Oct 29 2020
by newdesigner
Thanks TJ works great.