Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

v101

PeriodHighLow Tradestation indicator Help

Recommended Posts

Hello;

I am a newbie at Tradestation development. I am trying to develop a simple indicator so I can input overnight start times and overnight end times and have Tradestation plot the high and low from this time period. 

 

I have tried a few different ways, having some success, but not doing exactly what I want. 

 

Here is the first code I tried to develop:

Inputs:    Starttime (1630),
        EndTime ( 0930);
        
        
Vars:    PeriodHigh(0),
        LastPeriodHigh (0),
        PeriodLow(999999),
        LastPeriodLow (999999);
        
If T > Starttime and T < EndTime then
Begin
    If H > PeriodHigh then PeriodHigh = H;
    If L < PeriodLow then PeriodLow = L;
    End;
    

Plot1( PeriodHigh );
Plot2( PeriodLow );
 

This seems to work, but doesn't catch the Low's for some unknown reason see the screen shot. PLOT1 appears to have caught the HIGH, but PLOT2 isn't correctly plotting the time period LOW. 

So I modified some other code I have and tried indicator version2 a bit different, but here is what I tried doing:

 

inputs:
    int ONightStart( 1630 ),    //The start time of user defined session
    int ONightEnd( 0930 ),        //The end time of a user defined session
    OverNightSession(1),        // Plot overnight session HIGH / LOW
    OffSetF(.0005), 
    LookBack(25);

vars:
    Var0( 0),
    bool ONightSession( False ), // True when in Overnight Session
    bool InSession( False );    // True when in session

begin
    ;
    ;
    Var0 =  CLOSE  * OffSetF;
    If T > ONightStart and T < ONightEnd then ONightSession = True;
    Begin
    
        If OverNightSession = 1 and ONightSession = True then  begin
            If HIGHD( 0) <= HIGHEST( HIGH  + Var0, LookBack) and HIGHD( 0) >= LOWEST( LOW  - Var0, LookBack) then  PLOT2 (HIGHD( 0), "OvernightHigh");
            If LOWD( 0) <= HIGHEST( HIGH  + Var0, LookBack) and LOWD( 0) >= LOWEST( LOW  - Var0, LookBack) then  PLOT3 (LOWD( 0), "OvernightLow");
            end;

 

However when I try to apply this, I get nothing on the screen. Is this because I am trying to use the HIGHD keyword? is the reason it plots nothing because the session time, doesn't have the HIGHD data?

 

Any help is appreciated. 

 

 

 

 

Screen Shot 2019-11-25 at 8.23.14 AM.png

Share this post


Link to post
Share on other sites

Hi,

StartTime(1630) // 430 PM

EndTIme(930) // 930 AM

If T > ONightStart and T < ONightEnd then ONightSession = True; 

Time cannot be greater than 430 PM less than 930 AM(since we haven't mentioned any Date).

Try this:-

If T > ONightStart OR T < ONightEnd then ONightSession = True; 

 

Goodluck.

Mani.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.