NexusFi: Find Your Edge


Home Menu

 





Trading Time Restriction Strategy


Discussion in EasyLanguage Programming

Updated
    1. trending_up 165 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Trading Time Restriction Strategy

  #1 (permalink)
FutureTrader112
Amsterdam Netherlands
 
Posts: 34 since Aug 2020
Thanks Given: 10
Thanks Received: 17

Hi all,

I'm attempting to add a time restriction rule to my strategy, however it appears to be ignored by the strategy, which trades 24/5 now. Does anyone know what I am missing in the code? Any hint is welcome!


inputs:

// Time
StartTime (0930),
EndTime (2200);

Condition1 = Time >= StartTime and Time <= EndTime;

Thanks in advance,
FutureTrader112

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
Cheap historycal L1 data for stocks
Stocks and ETFs
What broker to use for trading palladium futures
Commodities
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

FutureTrader112,

the code snippet itself looks fine, and more information would be required for checking what might cause what you are seeing. How do implement the snippet into your actual code and what chart and timeframe do you apply the code to?

Regards,

ABCTG


FutureTrader112 View Post
Hi all,

I'm attempting to add a time restriction rule to my strategy, however it appears to be ignored by the strategy, which trades 24/5 now. Does anyone know what I am missing in the code? Any hint is welcome!


inputs:

// Time
StartTime (0930),
EndTime (2200);

Condition1 = Time >= StartTime and Time <= EndTime;

Thanks in advance,
FutureTrader112


Follow me on Twitter Reply With Quote
  #3 (permalink)
FutureTrader112
Amsterdam Netherlands
 
Posts: 34 since Aug 2020
Thanks Given: 10
Thanks Received: 17


Hi ABCTG,

Thanks for your quick reply.

I try to make it work for a 5min candle chart for YM.

Code:

inputs:

// Indicator
Length(14),
MA_Length(7),

// EMA
Price(Close),
LengthEMA(9),


// Time
StartTime (0930),
EndTime (2200);

vars:
// Indicator
Indicator1(0),
Indicator2(0),
Indicator3(0),

// SMA
double AvgExp( 0 );

// Calculation
Indicator2= Average(Close, Length);
Indicator3= Average(Close, Length * 2);

Indicator1= (Indicator2- Indicator3) / Indicator3 * 100;

AvgExp = XAverage( Price, LengthEMA );

// Buy Signal
Condition1 = Time >= StartTime and Time <= EndTime;
Condition2 = (Indicator1> Indicator1[1]) and (0 > Indicator1[1]) and (Open < AvgExp);

if Condition1 and Condition2 then
Buy ("Buy") next bar at market;

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

FutureTrader112,

what exactly do you mean when you say "it appears to be ignored by the strategy"? Please describe what happens (screenshots might be helpful here) and what you want the strategy to do instead.

Regards,

ABCTG


FutureTrader112 View Post
Hi ABCTG,

Thanks for your quick reply.

I try to make it work for a 5min candle chart for YM.

Code:

inputs:

// Indicator
Length(14),
MA_Length(7),

// EMA
Price(Close),
LengthEMA(9),


// Time
StartTime (0930),
EndTime (2200);

vars:
// Indicator
Indicator1(0),
Indicator2(0),
Indicator3(0),

// SMA
double AvgExp( 0 );

// Calculation
Indicator2= Average(Close, Length);
Indicator3= Average(Close, Length * 2);

Indicator1= (Indicator2- Indicator3) / Indicator3 * 100;

AvgExp = XAverage( Price, LengthEMA );

// Buy Signal
Condition1 = Time >= StartTime and Time <= EndTime;
Condition2 = (Indicator1> Indicator1[1]) and (0 > Indicator1[1]) and (Open < AvgExp);

if Condition1 and Condition2 then
Buy ("Buy") next bar at market;


Follow me on Twitter Reply With Quote
  #5 (permalink)
FutureTrader112
Amsterdam Netherlands
 
Posts: 34 since Aug 2020
Thanks Given: 10
Thanks Received: 17

After I put the time constraints, it was ignored. Trades continue to occur before and after the timestamps specified in the code. I just want to make sure the strategy doesnt trade before 0930 and after 2200.

Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

FutureTrader112,

your code works fine on my end, without any entries outside the time window.

Regards,

ABCTG


FutureTrader112 View Post
After I put the time constraints, it was ignored. Trades continue to occur before and after the timestamps specified in the code. I just want to make sure the strategy doesnt trade before 0930 and after 2200.


Follow me on Twitter Reply With Quote
Thanked by:
  #7 (permalink)
 bfulks 
Boston MA
 
Experience: Advanced
Platform: TradeStation
Trading: Stocks and options
Posts: 24 since Aug 2022
Thanks Given: 2
Thanks Received: 4


FutureTrader112 View Post
Hi all,

I'm attempting to add a time restriction rule to my strategy, however it appears to be ignored by the strategy, which trades 24/5 now. Does anyone know what I am missing in the code? Any hint is welcome!


inputs:

// Time
StartTime (0930),
EndTime (2200);

Condition1 = Time >= StartTime and Time <= EndTime;

Thanks in advance,
FutureTrader112



Add a plot statement to see what is happening:

inputs:

// Time
StartTime (0930),
EndTime (2200);

Condition1 = Time >= StartTime and Time <= EndTime;

if Condition1 then Plot1(1, "Plot") else Plot1(0, "Plot");


bfulks

Reply With Quote




Last Updated on March 23, 2024


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts