Just to make sure, all I want is to limit the order executions and the calculations of all system settings for the predefined time period 600 to 1300.
In other words by setting up a custom session (600 - 1300) under properties and comparing the system results with results generated by a code that contains your time limitation (... if Time >= BegMACDCalcTime and Time <= EndMACDCalcTime...) and has a 24 hour chart (Forex - regular session) then the very same results should be expected. Unfortunately just the entries and exits are within the custom session but they differ. That's why I believe that the calculation of the indicators does not work.
Below you will find two different examples. It is confusing that it does not matter if variables and inputs are set before or after the time restriction (..if Time >= BegCalcTime and Time <= EndCalcTime..)
Please help, thank you very much. Regards.
Code: Select all
// MACD
inputs: BegCalcTime( 600 ), EndCalcTime( 1300 ) ;
if Time >= BegCalcTime and Time <= EndCalcTime then
begin
inputs: Length( 14 ), OverSold( 20 ), OverBought( 80 ) ;
variables: oFastK( 0 ), oFastD( 0 ), oSlowK( 0 ), oSlowD( 0 ) ;
Value1 = Stochastic( H, L, C, Length, 3, 3, 1, oFastK, oFastD, oSlowK, oSlowD ) ;
if CurrentBar > 2 and oSlowK crosses over oSlowD and oSlowK < OverSold then
Buy ( "StochLE" ) next bar at market ;
if CurrentBar > 2 and oSlowK crosses under oSlowD and oSlowK > OverBought then
Sell ( "StochLX" ) next bar at market ;
end ;
Code: Select all
// Stoch
inputs: BegMACDCalcTime( 600 ), EndMACDCalcTime( 1300 ) ;
variables: MyMACD( 0 ), MACDAvg( 0 ), MACDDiff( 0 ) ;
variables: MACDValue( 0 ) ;
if Time >= BegMACDCalcTime and Time <= EndMACDCalcTime then
begin
inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
MyMACD = MACD( Close, FastLength, SlowLength ) ;
MACDAvg = XAverage( MyMACD, MACDLength ) ;
MACDDiff = MyMACD - MACDAvg ;
MACDValue = MACD( Close, 12, 26 ) ;
{ put other code here }
if CurrentBar > 2 and MACDDiff crosses over 0 then
Buy ( "MacdLE" ) next bar at market ;
if CurrentBar > 2 and MACDDiff crosses under 0 then
Sell ( "MacdLX" ) next bar at market ;
end ;