NexusFi: Find Your Edge


Home Menu

 





Opening Range Breakout


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 18 posts (14 thanks)
    2. looks_two GustavMejlvang with 8 posts (2 thanks)
    3. looks_3 Gann Trader with 8 posts (1 thanks)
    4. looks_4 DougN with 7 posts (1 thanks)
      Best Posters
    1. looks_one Jeff65 with 9 thanks per post
    2. looks_two wldman with 1.5 thanks per post
    3. looks_3 ABCTG with 0.8 thanks per post
    4. looks_4 GustavMejlvang with 0.3 thanks per post
    1. trending_up 31,864 views
    2. thumb_up 32 thanks given
    3. group 16 followers
    1. forum 48 posts
    2. attach_file 7 attachments




 
Search this Thread

Opening Range Breakout

  #1 (permalink)
 ptcm 
Taiwan
 
Experience: Intermediate
Platform: MC
Posts: 77 since Jun 2010
Thanks Given: 8
Thanks Received: 17

I have coded the opening range breakout(quite a few hedge funds actually traded this strategies to make money in ES), but somehow the signals are not being generated correctly. Can someone please point me to the right direction ? The codes work on TS2000i but after importing into MC, it doesn't work anymore. ESL expert. please help!! many thanks.


data1 = 5 min, data2 = daily


Input: orb(0.3);
Variables: MyTrueRange(0), PreTrueRange(0),tempOpen(0), answer(0), answerSell(0);

If date <> date[1] then begin
DailyOpen = Open;
PreTrueRange = TrueHigh[1] of data2 - TrueLow[1] of data2;
end;


answer = DailyOpen + (PreTrueRange * orb);
answerSell = DailyOpen - (PreTrueRange * orb);

IF Close >= DailyOpen + (PreTrueRange * orb) THEN BEGIN

{**********************************************************}
IF MarketPosition = -1 THEN Buy To Cover ("EXIT SHORT") THIS BAR ON CLOSE;


END;
{**********************************************************}
if MarketPosition = 0 THEN BEGIN;
BUY ("LONG +") 4 CONTRACTS NEXT BAR ON CLOSE;
end;
{**********************************************************}
IF MarketPosition = 1 THEN BEGIN

Alert("Still Long");
END;

END;



{*********************************************************************************************************}
{* SELL SIGNALS ARE HERE*}


IF Close <= DailyOpen - (PreTrueRange * orb) THEN BEGIN

{**********************************************************}

{IF MarketPosition = -1 THEN BEGIN
Alert("Still Short");
END;}



{**********************************************************}

IF MarketPosition = 0 THEN SELL ("SHORT") 4 CONTRACTS THIS BAR ON CLOSE;

END;
{**********************************************************}
IF MarketPosition = 1 THEN BEGIN

sell ("EXIT LONG") THIS BAR ON CLOSE;

end;

END;

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
Battlestations: Show us your trading desks!
26 thanks
The Program
18 thanks
  #3 (permalink)
Jeff65
Gurnee, IL
 
Posts: 46 since Apr 2010
Thanks Given: 17
Thanks Received: 97



ptcm View Post
I have coded the opening range breakout(quite a few hedge funds actually traded this strategies to make money in ES), but somehow the signals are not being generated correctly. Can someone please point me to the right direction ? The codes work on TS2000i but after importing into MC, it doesn't work anymore. ESL expert. please help!! many thanks.

I work with TradeStation with EasyLanguage. I took your code and it would not compile. There was also a few things about your code that made no sense to me. I made a few modifications and it now works under TradeStation 8.8. You might have to change the times since they are based on my time zone here in Chicago.

You should be able to take this to MC and compile it. Let me know if you have any questions.

 
Code
Input:
   orb(0.3);
Variables:
   MP(0),
   TodaysOpen(0),
   MyTrueRange(0), 
   PreTrueRange(0),
   tempOpen(0), 
   answer(0), 
   answerSell(0);

MP = MarketPosition;

// New Day

If date <> date[1] then begin
   TodaysOpen = Open;
   PreTrueRange = TrueHigh[1] of data2 - TrueLow[1] of data2;
   answer = TodaysOpen + (PreTrueRange * orb);
   answerSell = TodaysOpen - (PreTrueRange * orb);
end;

// Enter trade on breakout

If ( Time >= 900 ) And ( Time <= 1430 ) And ( MP = 0 ) And ( EntriesToday(Date) = 0 )  Then
Begin
   Buy ("LE") next bar at answer stop;
   Sellshort("SE") next bar at answerSell stop;
End;

// Stop Loss

If ( MP = 1 ) Then Sell next bar at answerSell stop;
If ( MP = -1 ) Then Buy to cover next bar at answer stop;
   
// Exit at end-of-day

If ( Time = 1500 ) And ( MP <> 0 ) Then
Begin
   Sell this bar at close;
   Buy to cover this bar at close;
End;

{************************************************* *********}
IF MarketPosition = 1 THEN BEGIN
Alert("Still Long");
END;

Reply With Quote
  #4 (permalink)
 
DougN's Avatar
 DougN 
Scottsdale, Arizona, USA and Puerto Penasco, Mx
 
Experience: Intermediate
Platform: Ninja 7, TOS
Trading: YM, ES, GC, CL
Posts: 42 since Nov 2013
Thanks Given: 35
Thanks Received: 33

Luckily I have found a couple of indicators here for Tradestation that would be useful. When the code is installed into the indicator list through Easylanguage the end result is that it is grayed out and says next to it "not verified". Can someone tell what step I'm missing on installing this code into Tradestation? I have searched the forums for the answer but just not searching correctly or???.

Thanks all.
Doug

Follow me on Twitter Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

DougN,

if you open the code in the editor and try to verify it, it will probably give you an error. What is the error message and can you post the code?

Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #6 (permalink)
 
DougN's Avatar
 DougN 
Scottsdale, Arizona, USA and Puerto Penasco, Mx
 
Experience: Intermediate
Platform: Ninja 7, TOS
Trading: YM, ES, GC, CL
Posts: 42 since Nov 2013
Thanks Given: 35
Thanks Received: 33


ABCTG View Post
DougN,

if you open the code in the editor and try to verify it, it will probably give you an error. What is the error message and can you post the code?

Regards,
ABCTG

Much obliged ABCTG...heres the code as it was copied and pasted from a thread here in the forum...


(TradeStation Forums)

[LegacyColorValue = true];

Inputs: iRangeLengthMin(30),

iBrakePoints(1),

iEntryTimeLimit(-90),

iContracts(1),

iProfitTarget(500),

Price(Close),

Length(12) ,



Var: OpenRangeTime(CalcTime(SessionStartTime(0,1), iRangeLengthMin)),

EntryTimeLimit(CalcTime(SessionEndTime(0,1), iEntryTimeLimit)),

RangeH(0),RangeL(0), // H&L of range

TimeH(0), TimeL(0), // time of H&L

RangeHtime(0), RangeLtime(0),

vDollarStop(500),

FirstTrade(true),

CustomCond(true),

Cond4trade(true),

vVolumeLenght(7),

ExpAvg(0),

firstcheck(true),

MaxP(0)

DateInFromTo(false);



// New day settings

if Date<>Date[1] then begin

//DateInFromTo= (Date>=iFromYYYMMDD and Date<=iToYYYMMDD);

FirstTrade=true;

RangeH=H; RangeL=L; // first bars High Low are Ranges h&l

TimeH=Time; TimeL=Time;

end;



// Range settings

If L<LowD(0)[1] then TimeL=Time; {if new H or L, remember the time of H or L}

If H>HighD(0)[1] then TimeH=Time;



If Time=OpenRangeTime then begin // if openning range is finished

RangeH=HighD(0);

RangeL=LowD(0);

RangeHtime=TimeH;

RangeLtime=TimeL;

end; // remember Range parameters



// ***************** Trade ******************

CustomCond= true;

Cond4trade = CustomCond and time>OpenRangeTime and time<EntryTimeLimit ; //and DateInFromTo



If Cond4Trade then begin

If FirstTrade and Close>=RangeH then

begin

Buy("BrOR_L1") iContracts contracts Next bar at open;

FirstTrade=false;

end;

If FirstTrade and Close<=RangeL then

begin

sellshort("RrOR_Sh1") iContracts contracts next bar at open;

FirstTrade=false;

end;

end;

SetStopContract;

SetStopLoss(100);

SetProfitTarget(100);



// ******************** Plots and Text ********************

Vars: Decimals($DecOfPriceScale),

PLot_hi(0),Plot_lo(0),

Low_line(-1),OR_Bar(-1),Hi_Line(-1),

Hi_text(-1),Lo_text(-1);



if time = OpenRangeTime then begin

Plot_hi = HighD(0);

Plot_lo = LowD(0);



{Draw Lines}

Hi_line = TL_new(date,time,Plot_hi,date,SessionEndTime(0,1),Plot_hi);

Tl_setstyle(Hi_line,tool_dashed2);

Tl_setcolor(Hi_line, yellow);

Low_line = TL_new(date,time,Plot_lo,Date,SessionEndTime(0,1),Plot_lo);

Tl_setstyle(Low_line,tool_dashed2);

Tl_setcolor(Low_line,yellow );

OR_bar = TL_new(date,time,Plot_hi,date,time,plot_lo);

TL_setcolor(OR_bar,lightgray);

{Text}

if ShowText then begin

Hi_text = Text_new(Date,SessionStartTime(0,1) ,Plot_hi ,numtostr(Plot_hi,decimals));

Lo_text = Text_new(Date,SessionStartTime(0,1),Plot_lo ,numtostr(Plot_lo,decimals));

end;

end;


and this is what shows in the indicator list... 2014-01-31_0640 - donzidoug's library

and here is what I could find for errors... 2014-01-31_0645 - donzidoug's library

Follow me on Twitter Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

DougN,

I didn't check the code below, but it compiles now. It was missing one semicolon, a comma, an input and I changed
the decimals variable (which I believe was coming from a function before).

Regards,
ABCTG

 
Code
Inputs: iRangeLengthMin(30),

iBrakePoints(1),

iEntryTimeLimit(-90),

iContracts(1),

iProfitTarget(500),

Price(Close),

Length(12),
ShowText (true);



Var: OpenRangeTime(CalcTime(SessionStartTime(0,1), iRangeLengthMin)),

EntryTimeLimit(CalcTime(SessionEndTime(0,1), iEntryTimeLimit)),

RangeH(0),RangeL(0), // H&L of range

TimeH(0), TimeL(0), // time of H&L

RangeHtime(0), RangeLtime(0),

vDollarStop(500),

FirstTrade(true),

CustomCond(true),

Cond4trade(true),

vVolumeLenght(7),

ExpAvg(0),

firstcheck(true),

MaxP(0),

DateInFromTo(false);



// New day settings

if Date<>Date[1] then begin

//DateInFromTo= (Date>=iFromYYYMMDD and Date<=iToYYYMMDD);

FirstTrade=true;

RangeH=H; RangeL=L; // first bars High Low are Ranges h&l

TimeH=Time; TimeL=Time;

end;



// Range settings

If L<LowD(0)[1] then TimeL=Time; {if new H or L, remember the time of H or L}

If H>HighD(0)[1] then TimeH=Time;



If Time=OpenRangeTime then begin // if openning range is finished

RangeH=HighD(0);

RangeL=LowD(0);

RangeHtime=TimeH;

RangeLtime=TimeL;

end; // remember Range parameters



// ***************** Trade ******************

CustomCond= true;

Cond4trade = CustomCond and time>OpenRangeTime and time<EntryTimeLimit ; //and DateInFromTo



If Cond4Trade then begin

If FirstTrade and Close>=RangeH then

begin

Buy("BrOR_L1") iContracts contracts Next bar at open;

FirstTrade=false;

end;

If FirstTrade and Close<=RangeL then

begin

sellshort("RrOR_Sh1") iContracts contracts next bar at open;

FirstTrade=false;

end;

end;

SetStopContract;

SetStopLoss(100);

SetProfitTarget(100);



// ******************** Plots and Text ********************

Vars: Decimals(Log(PriceScale)/ Log(10)),

PLot_hi(0),Plot_lo(0),

Low_line(-1),OR_Bar(-1),Hi_Line(-1),

Hi_text(-1),Lo_text(-1);



if time = OpenRangeTime then begin

Plot_hi = HighD(0);

Plot_lo = LowD(0);



{Draw Lines}

Hi_line = TL_new(date,time,Plot_hi,date,SessionEndTime(0,1),Plot_hi);

Tl_setstyle(Hi_line,tool_dashed2);

Tl_setcolor(Hi_line, yellow);

Low_line = TL_new(date,time,Plot_lo,Date,SessionEndTime(0,1),Plot_lo);

Tl_setstyle(Low_line,tool_dashed2);

Tl_setcolor(Low_line,yellow );

OR_bar = TL_new(date,time,Plot_hi,date,time,plot_lo);

TL_setcolor(OR_bar,lightgray);

{Text}

if ShowText then begin

Hi_text = Text_new(Date,SessionStartTime(0,1) ,Plot_hi ,numtostr(Plot_hi,decimals));

Lo_text = Text_new(Date,SessionStartTime(0,1),Plot_lo ,numtostr(Plot_lo,decimals));

end;

end;

Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
 
DougN's Avatar
 DougN 
Scottsdale, Arizona, USA and Puerto Penasco, Mx
 
Experience: Intermediate
Platform: Ninja 7, TOS
Trading: YM, ES, GC, CL
Posts: 42 since Nov 2013
Thanks Given: 35
Thanks Received: 33

This is my first year with Tradestation but I have successfully installed other indicators before trying these. As shown below all three of the indicators that I have attempted to install from Mikes will not verify for some reason. This includes what you posted above. In the screenshot below yours is the one labeled OpenRange2.

2014-01-31_1634 - donzidoug's library

Certainly there is something wrong on my end...just not sure what I'm screwing up.

Tried again with the code above that worked for you and heres the result...
https://screencast.com/t/jqohW3gmgjD

Follow me on Twitter Reply With Quote
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

DougN,

the code you posted is for a strategy and contains reserved words that Tradestation doesn't allow in indicators. From your screenshot it appears that you created an indicator and this won't verify and give you the errors you receive.
Try creating a new strategy and paste the code in there. This should work for you.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #10 (permalink)
 
DougN's Avatar
 DougN 
Scottsdale, Arizona, USA and Puerto Penasco, Mx
 
Experience: Intermediate
Platform: Ninja 7, TOS
Trading: YM, ES, GC, CL
Posts: 42 since Nov 2013
Thanks Given: 35
Thanks Received: 33


Sorry but the result was the same creating these as strategies. Obviously I am doing something wrong but just have no idea what it is. If someone else is using these perhaps they could share the actual Tradestation workspace? This could allow the chance to see their functioning indicators and compare them with mine that will not verify.

Follow me on Twitter Reply With Quote




Last Updated on May 4, 2017


© 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