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.

binthere

Members
  • Content Count

    23
  • Joined

  • Last visited

Posts posted by binthere


  1. hi TheRumpledOne

    i'm looking to be able to have this pivots up in radar screen but being a newbie in easy language is very difficult could you help me out?

    thank you very much, regards,

    binthere

     

    here's the code:

    [LegacyColorValue = true]; 
    
    {4/28/05. DeanVan @ TS} {Thanks to eKam for use of roundInst and other pivot types I got from ChiasmLevels}
    {based on intraday data (is sometimes a little different than daily data, so won't match exact)}
    {idea is that it will change each day @ "NewDayTM", to reflect the next days numbers.}
    {..check the open/close values to verify the day it's showing. It seems to work}
    {always posting 1 bar behind, since must be NO on "update value intra-bar"}
    
    input: PivotType(0),
    BarsBack(60),
    ShowClose(1),
    ShowOpen(1),
    ShowHalfPivots(1),
    ShowLevel(0),
    DaysBack(1),
    NewDayTM(1510),
    RoundLevels(false),
    DecPlaces(2),
    SupResType(0);
    
    var: theday(0);
    var: Maxcnt(11);
    array:
    TL[12](-1),Val[12](-1),
    Color[12](6),Label[12]("L"),FTextID[12](-1), TLabel[12](" ");
    
    var: cnt(0),sdate(0),stime(0),fPivot(0),twOpen(0),theRange(0);
    
    if lastbaronchart then begin
    
    if time >= NewDayTM then theday = 0  else theday = 1;
    theday = theday + DaysBack-1;
    if theday <= 0 then begin 
    theday = 0;
    twOpen = 0;
    end else twopen = theday-1;  {make sure this weeks open isn't <0}
    
    {store weekly Open and Close that we care about}
    Val[10] = CloseD(theday);
    if PivotType >0 and PivotType <4 then Val[11] = OpenD(twopen) else Val[11] = OpenD(theday);
    
    {calculate central pivot based on pivot type}{not sure how usefull some of these might be}
    if      PivotType = 1 then fPivot = (HighD(theday) + LowD(theday) + Val[11]) /3
    else if PivotType = 2 then fPivot = (HighD(theday) + LowD(theday) + Val[11] + Val[11]) /4
    else if PivotType = 3 then fPivot = (HighD(theday) + LowD(theday) + Val[10] + Val[11]) /4
    else if PivotType = 4 then fPivot = (HighD(theday) + LowD(theday) + Val[10] + Val[11]) /4
    else fPivot = (HighD(theday) + LowD(theday) + Val[10]) /3; {default standard Pivot}
    
    if SupResType = 1 then begin {seems like there is always a little different way to do these}
    theRange = (HighD(theday) - LowD(theday))/2;
    VAl[1] = fPivot;
    VAl[2] = fPivot + theRange; {R1}
    VAl[3] = fPivot - theRange; {S1}
    
    VAl[4] = VAl[2] + theRange; {R2}
    VAl[5] = VAl[3] - theRange; {S2}
    
    VAl[6] = VAl[4] + theRange; {R3}
    VAl[7] = VAl[5] - theRange; {S3}
    VAl[8] = VAl[6] + theRange; {R4}
    VAl[9] = VAl[7] - theRange; {S4}
    end
    else begin
    VAl[1] = fPivot;
    VAl[2] = fPivot + fPivot - LowD(theday); {R1}
    VAl[3] = fPivot + fPivot - HighD(theday); {S1}
    
    VAl[4] = fPivot + VAl[2] - VAl[3]; {R2}
    VAl[5] = fPivot - VAl[2] + VAl[3]; {S2}
    
    VAl[6] = fPivot + VAl[4] - VAl[3]; {R3}
    VAl[7] = fPivot - VAl[4] + VAl[3]; {S3}
    VAl[8] = fPivot + VAl[4] - VAl[5]; {R4}
    VAl[9] = fPivot - VAl[4] + VAl[5]; {S4}
    end;
    
    if RoundLevels then begin
    for cnt = 1 to 11 begin
    	val[cnt] = roundInst(val[cnt]);
    end;
    end;
    
    Color[1] = LightGray;
    Color[2] = Darkred;
    Color[3] = Darkgreen;
    Color[4] = Darkred;
    Color[5] = Darkgreen;
    
    Color[6] = Darkred;
    Color[7] = Darkgreen;
    Color[8] = Darkred;
    Color[9] = Darkgreen;
    Color[10] = Yellow;
    Color[11] = DarkBrown;
    
    TLabel[1] = "Pivot - ";
    TLabel[2] = "R1 - ";
    TLabel[3] = "S1 - ";
    TLabel[4] = "R2 - ";
    TLabel[5] = "S2 - ";
    TLabel[6] = "R3 - ";
    TLabel[7] = "S3 - ";
    TLabel[8] = "R4 - ";
    TLabel[9] = "S4 - ";
    TLabel[10] = "Close - ";
    TLabel[11] = "Open - ";
    
    
    sdate = Date[barsBack];
    stime = Time[barsBack];
    
    
    for cnt= 1 to Maxcnt begin
    if cnt < 10 or (ShowClose <> 0 and cnt = 10) or (ShowOpen <> 0 and cnt = 11) then begin
    	if TL[cnt] < 0 then begin {dosn't exist, create new TL}
    		TL[cnt] = TL_New (sdate, stime, Val[cnt],
    			date, time , Val[cnt]);
    		TL_SetColor (TL[cnt], Color[cnt]);
    		if cnt >= 10 then TL_SetStyle (TL[cnt], Tool_Dashed)
    			else TL_SetStyle (TL[cnt], Tool_Dashed);
    	end;
    	if TL_Exist(TL[cnt]) then begin {exist}
    		TL_SetEnd (TL[cnt], date, time , Val[cnt]);
    		TL_SetBegin (TL[cnt], sdate, stime, Val[cnt]); {reset TL}
    	end;
    
    	{do text stuff}
    	if FTextID[cnt] < 0 then begin  {is new}
    		FTextID[cnt] = Text_New(sdate, stime, Val[cnt], "zzz");
    		Text_SetStyle(FTextID[cnt], 1, 2);
    		Text_SetColor(FTextID[cnt], Color[cnt]);
    	end;
    	if FTextID[cnt] >= 0 then begin  {already exists}
    		Text_SetLocation(FTextID[cnt], sdate, stime, Val[cnt]);
    		Text_SetString(FTextID[cnt],TLabel[cnt] + NumToStr(Val[cnt], DecPlaces) + " " );
    	end;
    end; {count < 6, etc.}
    end; {cnt}
    
    Array: HalfTL[9](-1),HalfVal[9](0),HTextID[9](-1);
    
    if ShowHalfPivots <> 0 then begin
    HalfVal[1] = ((Val[4] - Val[2])/2) + Val[2];
    HalfVal[2] = ((Val[2] - Val[1])/2) + Val[1];
    HalfVal[3] = ((Val[1] - Val[3])/2) + Val[3];
    HalfVal[4] = ((Val[3] - Val[5])/2) + Val[5]; {s1-s2}
    HalfVal[5] = ((Val[4] - Val[6])/2) + Val[6];
    HalfVal[6] = ((Val[5] - Val[7])/2) + Val[7]; {s2-s3}
    HalfVal[7] = ((Val[6] - Val[8])/2) + Val[8];
    HalfVal[8] = ((Val[7] - Val[9])/2) + Val[9]; {s3-s4}
    
    if RoundLevels then begin
    	for cnt = 1 to 8 begin
    		HalfVal[cnt] = roundInst(HalfVal[cnt]);
    	end;
    end;
    
    for cnt= 1 to 8 begin
    	if HalfTL[cnt] < 0 then begin {dosn't exist, create new TL}
    		HalfTL[cnt] = TL_New (sdate, stime, HalfVal[cnt],
    			date, time , HalfVal[cnt]);
    		TL_SetColor (HalfTL[cnt], DarkGray);
    		TL_SetStyle (HalfTL[cnt], Tool_Dashed);
    	end;
    	if TL_Exist(HalfTL[cnt]) then begin {exist}
    		TL_SetEnd (HalfTL[cnt], date, time , HalfVal[cnt]);
    		TL_SetBegin (HalfTL[cnt], sdate, stime, HalfVal[cnt]); {reset TL}
    	end;
    
    	{do text stuff}
    	if HTextID[cnt] < 0 then begin  {is new}
    		HTextID[cnt] = Text_New(sdate, stime, HalfVal[cnt], "zzz");
    		Text_SetStyle(HTextID[cnt], 1, 2);
    		Text_SetColor(HTextID[cnt], DarkGray);
    	end;
    	if HTextID[cnt] >= 0 then begin  {already exists}
    		Text_SetLocation(HTextID[cnt], sdate, stime, HalfVal[cnt]);
    		Text_SetString(HTextID[cnt], NumToStr(HalfVal[cnt], DecPlaces) + " " );
    	end;
    end; {cnt}
    end; {ShowHalfPivots}
    
    end; {last bar}
    
    if ShowLevel > 0 and ShowLevel <= 4 then begin
    noplot(2);
    noplot(3);
    if ShowLevel = 1 then begin
    	Plot2[-1](Val[2] + .5,"h");
    	Plot3[-1](Val[3] - .5,"l");
    end
    else if ShowLevel = 2 then begin
    	Plot2[-1](Val[4] + .5,"h");
    	Plot3[-1](Val[5] - .5,"l");
    end
    else if ShowLevel = 3 then begin
    	Plot2[-1](Val[6] + .5,"h");
    	Plot3[-1](Val[7] - .5,"l");
    end
    else if ShowLevel = 4 then begin
    	Plot2[-1](Val[8] + .5,"h");
    	Plot3[-1](Val[9] - .5,"l");
    end;
    
    end;


  2. Randall, this is HUGE!!!!

    thanks for your help!, i've been strugling for over a week to get to the code i had posted earlier... and to get to the code you did it would have taken me a gazillion years in a very frustrating journey.

    i can't thank you enough for your help

    cheers,, keep it spinning!

    binthere


  3. Randall

    well this is the first time i actually code a strategy and have no prior developing experience, i've been strugling to make this hapen if you could help me out coding it would greatly appreciate it!!

    every word i've used in the above code has taken me for ever to understand it and try to implement it

    cheers!!, binthere


  4. thank's for the response, i'm trying to do this baby steps, first making the strategy stop trading when a specific number of winners or loosers is hit but it seems it's not working

    could someone look at the code and help me out to understand what i'm doing wrong?

    thanks, binthere

    Input:

    NumberWinningTrades( 111 ),

    NumberLosingTrades ( 111 );

     

    Vars:

    WinTrades( 0 ),

    LosTrades( 0 ),

    tradeOn (true);

     

    If time = 0 then

    Wintrades = NumLosTrades ;

    Lostrades = NumWinTrades ;

     

    IF ( Wintrades >= NumberWinningTrades) or (LosTrades >= NumberLoosingTrades) then

    tradeOn (false)

    else

    begin

     

    //strategy entries

     

    //strategy exits


  5. MMS

    your set up sound good!!, i'll end up doing something similar mantaining TS and moving the bulk of volume elsewhere, thank you for sharing!

    spoke today with the TS guys....

    in short if we want to use the TS platform the only BD to which they route trades is to rjobrien

     

     

    thanks, binthere


  6. hi guys

    does anyone know if there is a whay to use tradestation and the platform clear thru infinity futures or other broker?

    i'm getting excellent pricing for emini's with infinity but want to keep my tradestation platform and strategies

    any ideas?

    thank you, binthere


  7. Hi guys

     

    i found a code in a forum that plots vertical lines @ reversal periods (10, 10:30, 11, 1pm, 2:30 &3 also vertical red lines @ 3:45, 3:50, 3:55 &$ indicating that market is closing soon)

     

    well hope it helps, you can change the hours in which the lines ar eploted modifying the script in easy language

     

    regards, binther

     

     

     

    Inputs:  
    
       iTimeOffSet   ( 0000 ),    // HHMM offset hours from NY time  
       iStyleTimeLine   (  tool_dotted );  
    Vars:  
       TLSize    ( 0 ),  
       TL_Text_HVal   ( 0 ) ,   
       TL_Text_VVal   ( 2 ) ;  
    vars:   
       sFirstPass   ( true ),  
       sTimePlot   ( false ),  
       TL_TextTime   ( 0 ) ,  
       aLoop    ( 0 ),  
       count    ( 0 ),  
       tlCount    ( 0 ),  
       tlStart    ( 0 ), 
       MaxFutureDisplayTime( 0  ) ;  //  added this variable 
    array:   
       xKeyTimes[10]  ( 0 ),  
       tKeyTimes[10]  ( "" ),  
       cKeyTimesColor[10] ( lightgray ),  
       xTextKeyTimes[10] ( 0 );  
    
            // Inititialize - Could Use Once Begin for First Time Through  
    // if  sFirstPass = true then begin  
    //  sFirstPass = false;  
    if  CurrentBar = 1 then begin  
     xKeyTimes[000] = 0955 ;  
     xKeyTimes[001] = 1025 ;  
     xKeyTimes[002] = 1055 ;  
     xKeyTimes[003] = 1255 ;  
     xKeyTimes[004] = 1355 ;  
     xKeyTimes[005] = 1425 ;  
     xKeyTimes[006] = 1455 ;  
     xKeyTimes[007] = 1545 ;  
     xKeyTimes[008] = 1550 ;  
     xKeyTimes[009] = 1555 ;  
     tKeyTimes[000] = "" ;  
     tKeyTimes[001] = "" ;  
     tKeyTimes[002] = "" ;  
     tKeyTimes[003] = "" ;  
     tKeyTimes[004] = "" ;  
     tKeyTimes[005] = "" ;  
     tKeyTimes[006] = "" ;  
     tKeyTimes[007] = "" ;  
     tKeyTimes[008] = "" ;  
     tKeyTimes[009] = "" ;  
    
     cKeyTimesColor[000] = lightgray ;  
     cKeyTimesColor[001] = lightgray ;  
     cKeyTimesColor[002] = lightgray ;  
     cKeyTimesColor[003] = lightgray ;  
     cKeyTimesColor[004] = lightgray ;  
     cKeyTimesColor[005] = lightgray ;  
     cKeyTimesColor[006] = lightgray ;  
     cKeyTimesColor[007] = darkred  ;  
     cKeyTimesColor[008] = darkred ;  
     cKeyTimesColor[009] = darkred  ;  
    
     for count = 0 to 9 begin  
      xKeyTimes[count] = CalcTime( xKeyTimes[count], - iTimeOffSet ) ; // changed to use CalcTime for proper calculation  
      if tKeyTimes[count] = "" then   
       tKeyTimes[count] = numtostr(xKeyTimes[count] , 0 ) +  " Reversal" ;  
       end;  //  for count = ...  
      end; {if sFirstPass}  
    
       { PROCESSING }  
    
    TL_TextTime = CalcTime(Time, 3 * BarInterval); // use to right adjust text   
    
    //  Added this section of code to calculate the far right (future time) bar for display for real-time ticks. 
    //  If we are on historical bars then the value is simply the current Time. 
    if LastBarOnChart and GetAppInfo ( aiRealtimeCalc ) = 1 then 
     MaxFutureDisplayTime = CalcTime( LastCalcTime, GetAppInfo ( aiSpaceToRight ) * BarInterval )  
    else 
     MaxFutureDisplayTime = Time ; 
    
    value1 = HighD(0) - Close ;  
    value2 = Close - LowD(0) ;  
    
    if  value1 > value2 then   
     value3 = value1/2 + close  
    else   
     value3 = value2/2 + close ;  
    
    sTimePlot = false ;  
    
    for count = 0 to 9 begin  
    
        //  Added the condition to only plot on the closing bar tick, and to check if the xKeyTimes is bounded between 
        //  the prior bar MaxFutureDisplayTime and the current bar MaxFutureDisplayTime.  If so, then plot the vertical line. 
    
     if BarStatus(1) = 2 and xKeyTimes[count] > MaxFutureDisplayTime[1] and xKeyTimes[count] <= MaxFutureDisplayTime 
       and sTimePlot = false then begin  
      sTimePlot = true ;  
      tlStart = tl_new( date , xKeyTimes[count] ,  high + 0.0001, date , xKeyTimes[count],  low - 0.0001 );  
      tl_SetExtRight(tlStart,true);  
      tl_SetExtLeft(tlStart,true);  
      tl_SetColor(tlStart, cKeyTimesColor[count] );  
      tl_SetStyle(tlStart, iStyleTimeLine );  
    
          { Delete or Draw Text }   
    
      if  xTextKeyTimes[count] > 0 then   
       value9 = Text_Delete( xTextKeyTimes[count] ) ;  
    
      xTextKeyTimes[count]= Text_New(date, xKeyTimes[count], value3, tKeyTimes[count]) ;               
    
      Text_SetColor( xTextKeyTimes[count] , cKeyTimesColor[count]  ) ;   
      Text_SetStyle( xTextKeyTimes[count],  TL_Text_HVal , TL_Text_VVal  ) ;   
     //   HVal: 0=left, 1=right, 2=centered, / VVal: 0=Top, 1=Bottom, 2=Centered   
      Text_SetLocation(xTextKeyTimes[count] , date , TL_TextTime , value3 );  
    
       end; // if time < xKeyTimes[count]  
    end;  //  for count = ...


  8. hi guys, i'm a newbie with TS, and would like to be able to automatically have my charts with a vertical line marking reversal periods 10, 10:30, 11, 1pm, 2, 2:30 & 3pm

    does anyne know how can i ahve this done?

    thank you!!

    binthere


  9. Tam, thank you for the code, i just pasted it into a new indicateor in easy language and it doesnt plot in my chart (it does verify!!)

    using ts 8.8

    do you have any idea what i;m doing wrong??

    thank you man

    binthere


  10. zapisy, thank you for the eld!

    looks very good

    what i'm really looking for is a whay to place a small window in my charts that would express the up - down valume ratio

    please look at the screen shot i posted

    thanks again for your help!

    binthere


  11. hi guys, i'm a newbie in TS and cant find a way to have the $UVOLvs$DVOL ratio

    i sued to have it in mt thinkorswim charts and it was very usefull

    the code in thinkorswim is:

    # TS_AdvanceDeclineBox

    # thinkscripter@gmail.com

    # Last Update 03 JAN 2010

     

    def UV = close("$UVOL");

    def DV = close ("$DVOL");

    def ADL = UV - DV;

    def ADR = if UV > DV then UV / DV else -DV / UV;

    input mode = {default Ratio, Issues};

    def modeSwitch = if mode == mode.Ratio then 1 else 0;

     

    AddChartLabel(yes, concat(

    if modeSwitch then ADR else ADL, concat(" ",

    if modeSwitch then ":1 NYSE UV/DV" else " NYSE UV/DV")),

    if modeSwitch then if ADR > ADR[1] then color.green else color.red else if ADL > ADL[1] then color.green else color.red);

    plot null = double.nan;

     

    anyone out there coudl help me out???

    thanks!,

×
×
  • Create New...

Important Information

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