Premarket reference Strategy  [SOLVED]

Questions about MultiCharts and user contributed studies.
newdesigner
Posts: 7
Joined: 10 Feb 2009
Has thanked: 1 time

Premarket reference Strategy

Postby newdesigner » 28 Oct 2020

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;

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Premarket reference Strategy  [SOLVED]

Postby TJ » 28 Oct 2020

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;

newdesigner
Posts: 7
Joined: 10 Feb 2009
Has thanked: 1 time

Re: Premarket reference Strategy

Postby newdesigner » 29 Oct 2020

Thanks TJ works great.


Return to “MultiCharts”