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.

philloo

Members
  • Content Count

    10
  • Joined

  • Last visited

Everything posted by philloo

  1. I forgot to put the variables on the other post. The code must be put after the target reach. No aaa, I cannot post all what I have. I was generous to give something in retrun. Because some people inspired me and I was thinking to regive back a little bit. After the line Buytocover or sell next bar, you have to put the code after If mp=-1 then begin buytocover orSell next bar end; Now you put the code there. VAriables: text_offset_buy (0.9985), text_offset_sell (1.0015), text_digits(4),Signal_long(0),Signal_close(0),Signal_short(0); if Var2=1 AND Var2[1] <> 1 THEN begin Signal_long = Text_New (Date, Time, Low * text_offset_buy, numtostr( entryprice, text_digits)); Text_SetColor(Signal_long,cyan); Text_SetSize(Signal_long,14); end; if Var2=0 AND Var2[1] = 1 THEN begin Signal_close = Text_New(Date, Time, high * text_offset_sell, numtostr( exitprice(1), text_digits)); Text_SetColor(Signal_close,yellow); Text_SetSize(Signal_close,14); end; if Var2=-1 AND Var2[1] <>-1 THEN begin Signal_short = Text_New(Date, Time, Low * text_offset_buy, numtostr( entryprice, text_digits)); Text_SetColor(Signal_short,red); Text_SetSize(Signal_short,14); end; if Var2=0 AND Var2[1] =- 1 THEN begin Signal_close = Text_New(Date, Time, high * text_offset_sell, numtostr( exitprice(1), text_digits)); Text_SetColor(Signal_close,yellow); Text_SetSize(Signal_close,14); end;
  2. Thank in advanced who will comment on my code. Here the code that will let you put the price on the chart. Warning the line Text_Setsize function doesn't work in tradestation. Too bad for tradestation. if Var2=1 AND Var2[1] <> 1 THEN begin Signal_long = Text_New (Date, Time, Low * text_offset_buy, numtostr( entryprice, text_digits)); Text_SetColor(Signal_long,cyan); Text_SetSize(Signal_long,14); end; if Var2=0 AND Var2[1] = 1 THEN begin Signal_close = Text_New(Date, Time, high * text_offset_sell, numtostr( exitprice(1), text_digits)); Text_SetColor(Signal_close,yellow); Text_SetSize(Signal_close,14); end; if Var2=-1 AND Var2[1] <>-1 THEN begin Signal_short = Text_New(Date, Time, Low * text_offset_buy, numtostr( entryprice, text_digits)); Text_SetColor(Signal_short,red); Text_SetSize(Signal_short,14); end; if Var2=0 AND Var2[1] =- 1 THEN begin Signal_close = Text_New(Date, Time, high * text_offset_sell, numtostr( exitprice(1), text_digits)); Text_SetColor(Signal_close,yellow); Text_SetSize(Signal_close,14); end;
  3. It's seem we don't have a lot of people that was intested to code multi system indicator. I have a pretty nice multisystem that I develop. I put for inputs: Start_time End_time close_time tickzise:put 0.5 for ES, 0.2 for TF,2 for Ym etc. I don't how I come to that conclusion but it's seem that my code miss some tick each trade. I really don't know why. I code this function with print log and I came to that conclusion. Try it, change the value and you will see that putting 2 tick in this inputs you would have pretty much what you will do in real world. Plus, 40 inputs that you can put. Warning it's doesn't replicate perflecly the universal equity curve. But very close to it. I didn't put (average,3) or limit order. Just close on this bar that it. No problem with intrabar generation in backtesting and real trade. I have clone the universal system perfectly to compare the result of my indicator and the system. No stop loss at all, no target like the add-on of Doc, clayburg. But better equity curve indicator. Much more acurate in term of real trade and equity curve. And for nothing 0$, FREE, NADA. We will see if Doc, take my code and sell after for 4000$ each peace. :crap: HaHa I will check this in couple of week. And If some of people on the forum want to put extra thing or fixe some bugs please please be free to do it. ANd thank for you time.:crap: to read me. philloo Power Indicator: inputs:Start_time(1000),End_time(1500),Close_time(1500),tick_size(0.5),B1_1(20),S1_1(14),B2_1(10),S2_1(10),B1_2(1),s1_2(1),b2_2(1),s2_2(1); inputs:B1_3(1),s1_3(1),b2_3(1),s2_3(1),B1_4(1),s1_4(1),b2_4(1),s2_4(1),B1_5(1),s1_5(1),b2_5(1),s2_5(1),B1_6(1),s1_6(1),b2_6(1),s2_6(1),B1_7(1),s1_7(1),b2_7(1),s2_7(1); inputs:B1_8(1),s1_8(1),b2_8(1),s2_8(1),B1_9(1),s1_9(1),b2_9(1),s2_9(1),B1_10(1),s1_10(1),b2_10(1),s2_10(1),B1_11(1),s1_11(1),b2_11(1),s2_11(1); inputs:B1_12(1),s1_12(1),b2_12(1),s2_12(1),B1_13(1),s1_13(1),b2_13(1),s2_13(1),B1_14(1),s1_14(1),b2_14(1),s2_14(1),B1_15(1),s1_15(1),b2_15(1),s2_15(1); inputs:B1_16(1),s1_16(1),b2_16(1),s2_16(1),B1_17(1),s1_17(1),b2_17(1),s2_17(1),B1_18(1),s1_18(1),b2_18(1),s2_18(1),B1_19(1),s1_19(1),b2_19(1),s2_19(1); inputs:B1_20(1),s1_20(1),b2_20(1),s2_20(1),B1_21(1),s1_21(1),b2_21(1),s2_21(1),B1_22(1),s1_22(1),b2_22(1),s2_22(1),B1_23(1),s1_23(1),b2_23(1),s2_23(1); inputs:B1_24(1),s1_24(1),b2_24(1),s2_24(1),B1_25(1),s1_25(1),b2_25(1),s2_25(1),B1_26(1),s1_26(1),b2_26(1),s2_26(1),B1_27(1),s1_27(1),b2_27(1),s2_27(1); inputs:B1_28(1),s1_28(1),b2_28(1),s2_28(1),B1_29(1),s1_29(1),b2_29(1),s2_29(1),B1_30(1),s1_30(1),b2_30(1),s2_30(1),B1_31(1),s1_31(1),b2_31(1),s2_31(1); inputs:B1_32(1),s1_32(1),b2_32(1),s2_32(1),B1_33(1),s1_33(1),b2_33(1),s2_33(1),B1_34(1),s1_34(1),b2_34(1),s2_34(1),B1_35(1),s1_35(1),b2_35(1),s2_35(1); inputs:B1_36(1),s1_36(1),b2_36(1),s2_36(1),B1_37(1),s1_37(1),b2_37(1),s2_37(1),B1_38(1),s1_38(1),b2_38(1),s2_38(1),B1_39(1),s1_39(1),b2_39(1),s2_39(1); inputs:B1_40(1),s1_40(1),b2_40(1),s2_40(1); array: BSys[8](0),BSysT[8](0),BSys1[8](0),BSysT1[8](0),BSys2[8](0),BSysT2[8](0),BSys3[8](0),BSysT3[8](0),BSys4[8](0),BSysT4[8](0); BSys[1]= multisystem(start_time,end_time,close_time,tick_size,B1_1,s1_1,b2_1,s2_1); BSys[2]= multisystem(start_time,end_time,close_time,tick_size,B1_2,s1_2,b2_2,s2_2); BSys[3]= multisystem(start_time,end_time,close_time,tick_size,B1_3,s1_3,b2_3,s2_3); BSys[4]= multisystem(start_time,end_time,close_time,tick_size,B1_4,s1_4,b2_4,s2_4); BSys[5]= multisystem(start_time,end_time,close_time,tick_size,B1_5,s1_5,b2_5,s2_5); BSys[6]= multisystem(start_time,end_time,close_time,tick_size,B1_6,s1_6,b2_6,s2_6); BSys[7]= multisystem(start_time,end_time,close_time,tick_size,B1_7,s1_7,b2_7,s2_7); BSys[8]= multisystem(start_time,end_time,close_time,tick_size,B1_8,s1_8,b2_8,s2_8); BSys1[1]= multisystem(start_time,end_time,close_time,tick_size,B1_9,s1_9,b2_9,s2_9); BSys1[2]= multisystem(start_time,end_time,close_time,tick_size,B1_10,s1_10,b2_10,s2_10); BSys1[3]= multisystem(start_time,end_time,close_time,tick_size,B1_11,s1_11,b2_11,s2_11); BSys1[4]= multisystem(start_time,end_time,close_time,tick_size,B1_12,s1_12,b2_12,s2_12); BSys1[5]= multisystem(start_time,end_time,close_time,tick_size,B1_13,s1_13,b2_13,s2_13); BSys1[6]= multisystem(start_time,end_time,close_time,tick_size,B1_14,s1_14,b2_14,s2_14); BSys1[7]= multisystem(start_time,end_time,close_time,tick_size,B1_15,s1_15,b2_15,s2_15); BSys1[8]= multisystem(start_time,end_time,close_time,tick_size,B1_16,s1_16,b2_16,s2_16); BSys2[1]= multisystem(start_time,end_time,close_time,tick_size,B1_17,s1_17,b2_17,s2_17); BSys2[2]= multisystem(start_time,end_time,close_time,tick_size,B1_18,s1_18,b2_18,s2_18); BSys2[3]= multisystem(start_time,end_time,close_time,tick_size,B1_19,s1_19,b2_19,s2_19); BSys2[4]= multisystem(start_time,end_time,close_time,tick_size,B1_20,s1_20,b2_20,s2_20); BSys2[5]= multisystem(start_time,end_time,close_time,tick_size,B1_21,s1_21,b2_21,s2_21); BSys2[6]= multisystem(start_time,end_time,close_time,tick_size,B1_22,s1_22,b2_22,s2_22); BSys2[7]= multisystem(start_time,end_time,close_time,tick_size,B1_23,s1_23,b2_23,s2_23); BSys2[8]= multisystem(start_time,end_time,close_time,tick_size,B1_24,s1_24,b2_24,s2_24); BSys3[1]= multisystem(start_time,end_time,close_time,tick_size,B1_25,s1_25,b2_25,s2_25); BSys3[2]= multisystem(start_time,end_time,close_time,tick_size,B1_26,s1_26,b2_26,s2_26); BSys3[3]= multisystem(start_time,end_time,close_time,tick_size,B1_27,s1_27,b2_27,s2_27); BSys3[4]= multisystem(start_time,end_time,close_time,tick_size,B1_28,s1_28,b2_28,s2_28); BSys3[5]= multisystem(start_time,end_time,close_time,tick_size,B1_29,s1_29,b2_29,s2_29); BSys3[6]= multisystem(start_time,end_time,close_time,tick_size,B1_30,s1_30,b2_30,s2_30); BSys3[7]= multisystem(start_time,end_time,close_time,tick_size,B1_31,s1_31,b2_31,s2_31); BSys3[8]= multisystem(start_time,end_time,close_time,tick_size,B1_32,s1_32,b2_32,s2_32); BSys4[1]= multisystem(start_time,end_time,close_time,tick_size,B1_33,s1_33,b2_33,s2_33); BSys4[2]= multisystem(start_time,end_time,close_time,tick_size,B1_34,s1_34,b2_34,s2_34); BSys4[3]= multisystem(start_time,end_time,close_time,tick_size,B1_35,s1_35,b2_35,s2_35); BSys4[4]= multisystem(start_time,end_time,close_time,tick_size,B1_36,s1_36,b2_36,s2_36); BSys4[5]= multisystem(start_time,end_time,close_time,tick_size,B1_37,s1_37,b2_37,s2_37); BSys4[6]= multisystem(start_time,end_time,close_time,tick_size,B1_38,s1_38,b2_38,s2_38); BSys4[7]= multisystem(start_time,end_time,close_time,tick_size,B1_39,s1_39,b2_39,s2_39); BSys4[8]= multisystem(start_time,end_time,close_time,tick_size,B1_40,s1_40,b2_40,s2_40); If BSys[1] <> BSys[1][1] then BSysT[1] = BSys[1]; If BSys[2] <> BSys[2][1] then BSysT[2] = BSys[2]; If BSys[3] <> BSys[3][1] then BSysT[3] = BSys[3]; If BSys[4] <> BSys[4][1] then BSysT[4] = BSys[4]; If BSys[5] <> BSys[5][1] then BSyst[5] = BSys[5]; If BSys[6] <> BSys[6][1] then BSysT[6] = BSys[6]; If BSys[7] <> BSys[7][1] then BSysT[7] = BSys[7]; If BSys[8] <> BSys[8][1] then BSysT[8] = BSys[8]; If BSys1[1] <> BSys1[1][1] then BSysT1[1] = BSys1[1]; If BSys1[2] <> BSys1[2][1] then BSysT1[2] = BSys1[2]; If BSys1[3] <> BSys1[3][1] then BSysT1[3] = BSys1[3]; If BSys1[4] <> BSys1[4][1] then BSysT1[4] = BSys1[4]; If BSys1[5] <> BSys1[5][1] then BSysT1[5] = BSys1[5]; If BSys1[6] <> BSys1[6][1] then BSysT1[6] = BSys1[6]; If BSys1[7] <> BSys1[7][1] then BSysT1[7] = BSys1[7]; If BSys1[8] <> BSys1[8][1] then BSysT1[8] = BSys1[8]; If BSys2[1] <> BSys2[1][1] then BSysT2[1] = BSys2[1]; If BSys2[2] <> BSys2[2][1] then BSysT2[2] = BSys2[2]; If BSys2[3] <> BSys2[3][1] then BSysT2[3] = BSys2[3]; If BSys2[4] <> BSys2[4][1] then BSysT2[4] = BSys2[4]; If BSys2[5] <> BSys2[5][1] then BSysT2[5] = BSys2[5]; If BSys2[6] <> BSys2[6][1] then BSysT2[6] = BSys2[6]; If BSys2[7] <> BSys2[7][1] then BSysT2[7] = BSys2[7]; If BSys2[8] <> BSys2[8][1] then BSysT2[8] = BSys2[8]; If BSys3[1] <> BSys3[1][1] then BSysT3[1] = BSys3[1]; If BSys3[2] <> BSys3[2][1] then BSysT3[2] = BSys3[2]; If BSys3[3] <> BSys3[3][1] then BSysT3[3] = BSys3[3]; If BSys3[4] <> BSys3[4][1] then BSysT3[4] = BSys3[4]; If BSys3[5] <> BSys3[5][1] then BSyst3[5] = BSys3[5]; If BSys3[6] <> BSys3[6][1] then BSysT3[6] = BSys3[6]; If BSys3[7] <> BSys3[7][1] then BSysT3[7] = BSys3[7]; If BSys3[8] <> BSys3[8][1] then BSysT3[8] = BSys3[8]; If BSys4[1] <> BSys4[1][1] then BSysT4[1] = BSys4[1]; If BSys4[2] <> BSys4[2][1] then BSysT4[2] = BSys4[2]; If BSys4[3] <> BSys4[3][1] then BSysT4[3] = BSys4[3]; If BSys4[4] <> BSys4[4][1] then BSysT4[4] = BSys4[4]; If BSys4[5] <> BSys4[5][1] then BSyst4[5] = BSys4[5]; If BSys4[6] <> BSys4[6][1] then BSysT4[6] = BSys4[6]; If BSys4[7] <> BSys4[7][1] then BSysT4[7] = BSys4[7]; If BSys4[8] <> BSys4[8][1] then BSysT4[8] = BSys4[8]; Plot1(BSysT[1],"BSys1"); Plot2(BSysT[2],"BSys2"); Plot3(BSysT[3],"BSys3"); Plot4(BSysT[4],"BSys4"); Plot5(BSysT[5],"BSys5"); Plot6(BSysT[6],"BSys6"); Plot7(BSysT[7],"BSys7"); Plot8(BSysT[8],"BSys8"); Plot9(BSysT1[1],"BSys9"); Plot10(BSysT1[2],"BSys10"); Plot11(BSysT1[3],"BSys11"); Plot12(BSysT1[4],"BSys12"); Plot13(BSysT1[5],"BSys13"); Plot14(BSysT1[6],"BSys14"); Plot15(BSysT1[7],"BSys15"); Plot16(BSysT1[8],"BSys16"); Plot17(BSysT2[1],"BSys17"); Plot18(BSysT2[2],"BSys18"); Plot19(BSysT2[3],"BSys19"); Plot20(BSysT2[4],"BSys20"); Plot21(BSysT2[5],"BSys21"); Plot22(BSysT2[6],"BSys22"); Plot23(BSysT2[7],"BSys23"); Plot24(BSysT2[8],"BSys24"); Plot25(BSysT3[1],"BSys25"); Plot26(BSysT3[2],"BSys26"); Plot27(BSysT3[3],"BSys27"); Plot28(BSysT3[4],"BSys28"); Plot29(BSysT3[5],"BSys29"); Plot30(BSysT3[6],"BSys30"); Plot31(BSysT3[7],"BSys31"); Plot32(BSysT3[8],"BSys32"); Plot33(BSysT4[1],"BSys33"); Plot34(BSysT4[2],"BSys34"); Plot35(BSysT4[3],"BSys35"); Plot36(BSysT4[4],"BSys36"); Plot37(BSysT4[5],"BSys37"); Plot38(BSysT4[6],"BSys38"); Plot39(BSysT4[7],"BSys39"); Plot40(BSysT4[8],"BSys40"); function:multisystem Inputs: Start_time(numeric),End_time(Numeric),Close_time(numeric),Tick_size(numeric),B1(numericsimple),s1(numericsimple),b2(numericsimple),S2(numericsimple); variables: var1(false),ttl(false),tts(false),bpt1(0),bpt2(0); variables: profitl(0),profittotal(0),profits(0); if TIME >= Start_time AND TIME <= end_time then var1 = TRUE ; if TIME < Start_time OR TIME > end_time then var1 = FALSE ; if TIME >= close_time then var1 = FALSE ; if DATE <> DATE[1] then begin value1=0; ttl=false; tts=false; bpt1=0; bpt2=0; profitl=0; profits=0; profittotal=0; end; condition1= (Momentum (CLOSE, B1) > 0 AND RSI (CLOSE, b2) CROSS UNDER 60) ; condition2= (Momentum (CLOSE, s1) < 0 AND RSI (CLOSE, S2) CROSS OVER 40) ; If condition1=true then begin If var1=true then begin ttl=true; tts=false; end; end; If condition2=true then begin If var1=true then begin tts=true; ttl=false; end; end; If ttl=true and ttl[1]=false then begin bpt1=close-profits[1]-tick_size; end; If tts=true and tts[1] =false then begin bpt2=close+profitl[1]+tick_size; end; If tts=true then begin profits=bpt2-close; profitl=0; end; If ttl=true then begin profitl=close-bpt1; profits=0; end; If var1=true then begin profittotal=profits+profitl; end; value1=profittotal; multisystem=value1; multisystem.pla
  4. Hi I would like to know if some person can program this add-on. It seem that in the past Doc have done the work. Go to this page hxxp://www.clayburg.com/omw_abstract.html It give a idea of what the paralell function work. I look at the webinar that was giving yesterday. And it's seem that doc program only the entry in the fuction and the start time end time and close time. The rest I think it's just a bluff. If you look at the code it's seem not to complicate for what he is selling his stuff. Sometime, I think that they are ripping off person with the price. thank
  5. Here the file maby you have not correctly paste the code. With the file it should work. I use the esignal 10.3 version phil TTM-Trend.rar
  6. Foe me it's working /******************************************************************** Title: Trend Indicator for eSignal 7.x By: Chris D. Kryza (Divergence Software, Inc.) Email: c.kryza@gte.net, ckryza@sr-analyst.com Web: http://www.sr-analyst.com Incept: 11/04/2004 Version: 1.0.0 ===================================================================== Fix History: 11/04/2004 - Initial Release 1.0.0 ===================================================================== Project Description: Tradestation conversion. Dislaimer: For educational purposes only! Obviously, no guarantees whatsoever and use at your own risk. **********************************************************************/ //External Variables var grID = 0; var nBarCounter = 0; var aOpen = null; var aClose = null; var aColor = null; var nColor = null; var nColor_1 = null; var nPeriod = null; var aFPArray = new Array(); var bInitialized = false; //== PreMain function required by eSignal to set things up function preMain() { var x; setPriceStudy(true); setStudyTitle("TTM-Trend"); setShowTitleParameters( false ); setColorPriceBars( true ); setDefaultPriceBarColor( Color.black ); //unrem this if you don't want the labels in cursor window setShowCursorLabel(false); setProperty( "HideEncryptedLock", "yes" ); grID = 0; //initialize formula parameters x=0; aFPArray[x] = new FunctionParameter( "fPeriod", FunctionParameter.NUMBER); with( aFPArray[x] ) { setName( "Comp Bars" ); setLowerLimit( 1 ); setUpperLimit( 125 ); setDefault( 5 ); } x++; aFPArray[x] = new FunctionParameter( "fUpColor", FunctionParameter.COLOR); with( aFPArray[x] ) { setName( "Up Color" ); setDefault( Color.blue ); } x++; aFPArray[x] = new FunctionParameter( "fDnColor", FunctionParameter.COLOR); with( aFPArray[x] ) { setName( "Dn Color" ); setDefault( Color.red ); } } //== Main processing function function main( fPeriod, fUpColor, fDnColor ) { var x; var nOpen, nClose, nHigh, nLow; //script is initializing if ( getBarState() == BARSTATE_ALLBARS ) { return null; } if ( bInitialized == false ) { nPeriod = Math.round( fPeriod ); aColor = new Array( nPeriod+1 ); aClose = new Array( nPeriod+1 ); aOpen = new Array( nPeriod+1 ); aClose[0] = ( open(0)+high(0)+close(0)+low(0) ) / 4; aOpen[0] = open(0); nBarCounter = 0; bInitialized = true; } //called on each new bar if ( getBarState() == BARSTATE_NEWBAR ) { aOpen.pop(); aOpen.unshift(0); aClose.pop(); aClose.unshift(0); aColor.pop(); aColor.unshift(0); nColor_1 = nColor; nBarCounter++; } nOpen = (aOpen[1]+aClose[1])/2; aOpen[0] = nOpen; nClose = ( open(0)+high(0)+low(0)+close(0) ) / 4; aClose[0] = nClose; nHigh = Math.max( high(0), nOpen, nClose ); nLow = Math.min( low(0), nOpen, nClose ); if ( nClose > nOpen ) { nColor = fUpColor; } else { nColor = fDnColor; } if ( nBarCounter<=nPeriod+2 ) return; x=1; while ( x<=nPeriod ) { if ( nOpen <= Math.max( aOpen[x], aClose[x] ) && nOpen >= Math.min( aOpen[x], aClose[x] ) && nClose <= Math.max( aOpen[x], aClose[x] ) && nClose >= Math.min( aOpen[x], aClose[x] ) ) { nColor = aColor[x]; } x++; } aColor[0] = nColor; setPriceBarColor( nColor ); return( null ); }
  7. Well,you can chose the daily , weekly, and mountly pivots in the pivot type variables
  8. I don't mention that the code are for the daliy pivots.
  9. These code are for esignal pivots. If someone can convert in tradestation it's arrange all the problem that indicator have. philloo Fix History: 02/02/2005 - Initial Release 1.0.0 ===================================================================== Project Description: Dislaimer: For educational purposes only! Obviously, no guarantees whatsoever and use at your own risk. **********************************************************************/ // globals var vOutputArray = null; var vResultArray = null; var vLastSeenDay = null; //pivot line labels ( Daily, Weekly and Monthly) var vTitleArray = new Array("R3", "M6", "R2", "M5", "R1", "M4", "PP", "M3", "S1", "M2", "S2", "M1", "S3"); var vLabelArray = new Array("Daily R3","Midpoint","Daily R2","Midpoint","Daily R1","Midpoint","Daily PP","Midpoint","Daily S1","Midpoint","Daily S2","Midpoint","Daily S3"); var vLabelArrayW = new Array("Weekly R3","WMidpoint","Weekly R2","WMidpoint","Weekly R1","WMidpoint","Weekly PP","WMidpoint","Weekly S1","WMidpoint","Weekly S2","WMidpoint","Weekly S3"); var vLabelArrayM = new Array("Monthly R3","MMidpoint","Monthly R2","MMidpoint","Monthly R1","MMidpoint","Monthly PP","MMidpoint","Monthly S1","MMidpoint","Monthly S2","MMidpoint","Monthly S3"); //pivot line Colors in same order as labels above (e.g., R2=darkgreen, M4=blue, etc.) var vColorArray = new Array( Color.yellow, Color.white, Color.yellow, Color.white, Color.yellow, Color.white, Color.yellow, Color.white, Color.yellow, Color.white, Color.yellow, Color.white, Color.yellow ); //pivot line types var vTypeArray = new Array( "DASH", "DASHDOT", "DASH", "DASHDOT", "DASH", "DASHDOT", "SOLID", "DASHDOT", "DASH", "DASHDOT", "DASH", "DASHDOT", "DASH" ); //pivot line thicknesses var vThickArray = new Array(1,1,1,1,1,1,3,1,1,1,1,1,1); var vButLabels = new Array("", "Proj", "Gap1", "Gap2", "Reg", "(-)" ); var aFPArray = new Array(); var vInterval = null; var vSymbol = null; var nOffset = 2; //# of bars shifted to the right (from most current bar ) that you want to print the text var nColor = Color.navy; //Color for the text labels var sFont = "Arial"; //Font to use for the text var nFontSize = 10; //Font size for the text. var nPct = 100; //limit percentage var bCursorLabels = false; //show all of the cursor labels in the data window?? var nMaxDays = 20; //# of days to display var _nProject = null; var _nLabels = null; var _nGap = null; var _nFlatLines = true; var _nHLC = false; var _nLimitPct = null; var grID = 20; var nCurHigh = 0; var nCurLow = 0; var nCurOpen = 0; var nCurClose = 0; var nTMP = 0; //today's in-progress Mid Point var vToday = 0; var vNow = null; var vCalcInterval = "D"; var vTempDay = null; var tdayO = 0; //today's open var ydayO = 0; //yesterday's open var ydayH = 0; //yesterday's high var ydayL = 0; //yesterday's low var ydayC = 0; //yesterday's close var P = 0; //pivot var MP = 0; //Midpoint var W = 0; //Waist var R1 = 0; //R1 var S1 = 0; //S1 var R2 = 0; //R2 var S2 = 0; //S2 var R3 = 0; //R3 var S3 = 0; //S3 var done = false; var bInitialized = false; function preMain() { var x; setPriceStudy(true); setStudyTitle("TTM-Pivots (Daily)"); setShowTitleParameters(false); for (x=0; x<vLabelArray.length; x++) { setCursorLabelName(vLabelArray[x], x); setDefaultBarStyle(eval( "PS_"+vTypeArray[x] ), x); setDefaultBarFgColor(vColorArray[x], x); setDefaultBarThickness(vThickArray[x], x); } setShowCursorLabel(bCursorLabels); vLastSeenDay = null; vOutputArray = null; vResultArray = new Array(); //initialize formula parameters x=0; aFPArray[x] = new FunctionParameter( "frOpen", FunctionParameter.NUMBER); with( aFPArray[x] ) { setName( "Override Open" ); setLowerLimit(0); setDefault(0); } x++; aFPArray[x] = new FunctionParameter( "frHigh", FunctionParameter.NUMBER); with( aFPArray[x] ) { setName( "Override High" ); setLowerLimit(0); setDefault(0); } x++; aFPArray[x] = new FunctionParameter( "frLow", FunctionParameter.NUMBER); with( aFPArray[x] ) { setName( "Override Low" ); setLowerLimit(0); setDefault(0); } x++; aFPArray[x] = new FunctionParameter( "frClose", FunctionParameter.NUMBER); with( aFPArray[x] ) { setName( "Override Close" ); setLowerLimit(0); setDefault(0); } x++; aFPArray[x] = new FunctionParameter( "frMid", FunctionParameter.STRING); with( aFPArray[x] ) { setName( "Display MidPoints?" ); addOption( "T" ); addOption( "F" ); setDefault( "T" ); } x++; aFPArray[x] = new FunctionParameter( "frGap", FunctionParameter.STRING); with( aFPArray[x] ) { setName( "Apply Gap?" ); addOption( "T" ); addOption( "F" ); setDefault( "F" ); } x++; aFPArray[x] = new FunctionParameter( "frLabels", FunctionParameter.STRING); with( aFPArray[x] ) { setName( "Show Cursor Labels?" ); addOption("T"); addOption("F"); setDefault("T"); } x++; aFPArray[x] = new FunctionParameter( "frLabColor", FunctionParameter.COLOR); with( aFPArray[x] ) { setName( "Cursor Label Color" ); setDefault( Color.yellow ); } x++; aFPArray[x] = new FunctionParameter( "frDays", FunctionParameter.NUMBER); with( aFPArray[x] ) { setName( "Days to Display" ); setLowerLimit(1); setUpperLimit(50); setDefault(1); } x++; aFPArray[x] = new FunctionParameter( "frInterval", FunctionParameter.STRING); with( aFPArray[x] ) { setName( "Pivot Type" ); addOption("Daily"); addOption("Weekly"); addOption("Monthly"); setDefault("Daily"); } x++; y=x; for( z=0; z<vTitleArray.length; z++ ) { aFPArray[y] = new FunctionParameter( "frColor"+(z+1), FunctionParameter.COLOR); with( aFPArray[y] ) { setName( vTitleArray[z] + " Color" ); setDefault( vColorArray[z] ); } y++; aFPArray[y] = new FunctionParameter( "frThick"+(z+1), FunctionParameter.NUMBER); with( aFPArray[y] ) { setName( vTitleArray[z] + " Thickness" ); setDefault( vThickArray[z] ); } y++; aFPArray[y] = new FunctionParameter( "frStyle"+(z+1), FunctionParameter.STRING); with( aFPArray[y] ) { setName( vTitleArray[z] + " Style" ); addOption( "SOLID" ); addOption( "DASH" ); addOption( "DASHDOT" ); addOption( "DASHDOTDOT" ); setDefault( vTypeArray[z] ); } y++; } } function main( frOpen, frHigh, frLow, frClose, frMid, frGap, frLabels, frLabColor, frDays, frInterval, frColor1, frThick1, frStyle1, frColor2, frThick2, frStyle2, frColor3, frThick3, frStyle3, frColor4, frThick4, frStyle4, frColor5, frThick5, frStyle5, frColor6, frThick6, frStyle6, frColor7, frThick7, frStyle7, frColor8, frThick8, frStyle8, frColor9, frThick9, frStyle9, frColor10, frThick10, frStyle10, frColor11, frThick11, frStyle11, frColor12, frThick12, frStyle12, frColor13, frThick13, frStyle13 ) { // initialize upon first loading formula if(getBarState() == BARSTATE_ALLBARS) { //get today's date stamp vNow = new Date(); //get our bar interval vInterval = getInterval(); //get our symbol vSymbol = getSymbol().toUpperCase(); // for RTH, eg, to convert, ES Z2 to ES Z2=2 var rootSymbol = vSymbol.substring(0,3); if (rootSymbol == "ES " || rootSymbol == "NQ ") { if ( vSymbol.indexOf("=2") == -1 ) { vSymbol += "=2"; } } return null; } // return null if not an intraday chart if(vInterval == null || vInterval == "D" || vInterval == "W" || vInterval == "M" || vInterval == "T") return null; if ( bInitialized == false ) { _nProject = 0; _nLabels = frLabels == "T" ? 1 : 0; _nGap = frGap=="T" ? 1 : 0; _nFlatLines = true; _nHLC = false; _nLimitPct = 100.0; nColor = frLabColor; nMaxDays = Math.round( frDays ); vCalcInterval = frInterval[0]; for ( x=0; x<vLabelArray.length; x++ ) { vColorArray[x] = eval( "frColor"+(x+1) ); vThickArray[x] = eval( "frThick"+(x+1) ); vTypeArray[x] = eval( "frStyle"+(x+1) ); } for ( x=0; x<vLabelArray.length; x++ ) { setDefaultBarStyle(eval( "PS_"+vTypeArray[x] ), x); setDefaultBarFgColor(vColorArray[x], x); setDefaultBarThickness(vThickArray[x], x); } //set plot type to flat lines if user selected this option if (_nFlatLines==true) { for (x=0; x<vLabelArray.length; x++) { setPlotType(PLOTTYPE_FLATLINES, x); } } vSymbol += ","+vCalcInterval; //get the date stamp of the most recent bar vTempDay = new Date( getValueAbsolute( "time", 0 ) ); //now move back by the number of days specified by the user, skipping weekends for ( x=1; x<nMaxDays; x++ ) { vTempDay.setDate( vTempDay.getDate()-1 ); if (vTempDay.getDay() == 6) { vTempDay.setDate( vTempDay.getDate()-1 ); } if (vTempDay.getDay() == 0) { vTempDay.setDate( vTempDay.getDate()-2 ); } } //set the date/time stamp to the very beginning of the day vTempDay.setHours( 0, 0, 0 ); bInitialized = true ; } // if first bar in new day, get and save yesterday's data var vThisDay = null; if ((vLastSeenDay != (vThisDay = getDay(0)) )) { vToday = new Date( getValue( "time", 0 ) ); if ( vToday<vTempDay ) return; var vTime = getValue( "rawtime", 0 ); if(vTime != null) { if (_nProject != 0) { //We don't project if interval is not daily //if (vCalcInterval != "D") return; if (vCalcInterval!="D") { vTime = getValue("time", 0 ); vIndex = getWM( vTime, vCalcInterval); } //otherwise, get offset to correct daily bar else { var vIndex = getFirstBarIndexOfDay(vTime,vSymbol); } //we want to use today's data to project tomorrows //pivot points so we have to draw the lines manually //var vIndex = getFirstBarIndexOfDay(vTime,vSymbol); if(vIndex != null) { ydayO = frOpen>0 ? frOpen : getValueAbsolute("Open", vIndex, vSymbol); ydayH = frHigh>0 ? frHigh : getValueAbsolute("High", vIndex, vSymbol); ydayL = frLow>0 ? frLow : getValueAbsolute("Low", vIndex, vSymbol); ydayC = frClose>0 ? frClose : getValueAbsolute("Close", vIndex, vSymbol); //calcuate Pivot P = (ydayH + ydayL + ydayC) / 3; //calculate yesterday's Midpoint MP = (ydayH + ydayL)/2; //calculate yesterday's Waist W = (ydayO + ydayC)/2; //calculate the R/S variables R1 = 2 * P - ydayL; S1 = 2 * P - ydayH; R2 = (P - S1) + R1; S2 = P - (R1 - S1); R3 = (P + R2) - S1; S3 = (P - R2) + S1; M6 = (R2+R3)/2; M5 = (R2+R1)/2; M4 = (R1+P)/2; M3 = (S1+P)/2; M2 = (S2+S1)/2; M1 = (S2+S3)/2; clearLines(); clearText(); if ( frMid=="T" ) vOutputArray = new Array (R3,M6,R2,M5,R1,M4,P,M3,S1,M2,S2,M1,S3) else vOutputArray = new Array (R3,null,R2,null,R1,null,P,null,S1,null,S2,null,S3); drawLines( vOutputArray ); vLastSeenDay = vThisDay; return null; } return null; } else { //Get today's open in case we need it for gaps vToday = getFirstBarIndexOfDay( vTime, vSymbol); if (vToday != null) { tdayO = getValueAbsolute("Open", vToday, vSymbol ); } //we are using yesterday's data to build today's pivots so //just return the values as an array to eSignal if (vCalcInterval=="D") { var vYDay = getPreviousTradingDay(vTime,vSymbol); } else { vTime = getValue( "time", 0 ); var vYDay = vTime; } if(vYDay != null) { //if not on daily bars, find offset to correct weekly or monthly bar if (vCalcInterval!="D") { vIndex = getWM( vTime, vCalcInterval); } //otherwise, get offset to correct daily bar else { var vIndex = getFirstBarIndexOfDay(vYDay,vSymbol); } if(vIndex != null) { ydayO = frOpen>0 ? frOpen : getValueAbsolute("Open", vIndex, vSymbol); ydayH = frHigh>0 ? frHigh : getValueAbsolute("High", vIndex, vSymbol); ydayL = frLow>0 ? frLow : getValueAbsolute("Low", vIndex, vSymbol); ydayC = frClose>0 ? frClose : getValueAbsolute("Close", vIndex, vSymbol); //calcuate Pivot P = (ydayH + ydayL + ydayC) / 3; //calculate yesterday's Midpoint MP = (ydayH + ydayL)/2; //calculate yesterday's Waist W = (ydayO + ydayC)/2; //calculate the R/S variables R1 = 2 * P - ydayL; S1 = 2 * P - ydayH; R2 = (P - S1) + R1; S2 = P - (R1 - S1); R3 = (P + R2) - S1; S3 = (P - R2) + S1; M6 = (R2+R3)/2; M5 = (R2+R1)/2; M4 = (R1+P)/2; M3 = (S1+P)/2; M2 = (S2+S1)/2; M1 = (S2+S3)/2; //display full or half gap... only if daily bars being used for pivot if ((_nGap>0) && (vCalcInterval=="D")) { if (_nGap==1){ vGap = (tdayO-ydayC); setStudyTitle("TTM-Pivots (Daily w/Gap)"); } P += vGap; R1 += vGap; S1 += vGap; R2 += vGap; S2 += vGap; R3 += vGap; S3 += vGap; M6 += vGap; M5 += vGap; M4 += vGap; M3 += vGap; M2 += vGap; M1 += vGap; } if (vCalcInterval=="W") { setStudyTitle("TTM-Pivots (Weekly)"); } else if (vCalcInterval=="M") { setStudyTitle("TTM-Pivots (Monthly)"); } if ( frMid=="T" ) vOutputArray = new Array (R3,M6,R2,M5,R1,M4,P,M3,S1,M2,S2,M1,S3) else vOutputArray = new Array (R3,null,R2,null,R1,null,P,null,S1,null,S2,null,S3); vResultArray = reduceLines( vOutputArray, _nLimitPct, close() ); if (_nLabels==1) drawLabels( vResultArray ); vLastSeenDay = vThisDay; return vResultArray; } } return null; } } } // else just return the saved data else { if (_nProject==0) { vResultArray = reduceLines( vOutputArray, _nLimitPct, close() ); if (_nLabels==1) drawLabels( vResultArray ); return vResultArray; } } } //== Convert array elements to null if they are more than x% away from //== the current price (reduces the nnumber of lines drawn on the screen) function reduceLines( aArray, nCt, nPrice ) { var x; var xPct; var xTmp; var aReturn; if (aArray==null) return; xPct = nCt/100; for (x=0; x<aArray.length; x++) { if (aArray[x] != null) { xTmp = Math.abs((aArray[x] - nPrice) / nPrice); if (xTmp > xPct) { aArray[x] = null; } } } aReturn = new Array(); for (x=0; x<aArray.length; x++) { aReturn[x] = aArray[x]; } return( aReturn ); } //== Find the correct weekly or monthly bar based upon //== the date passed to this function function getWM( xTime, xInterval ) { var x; var c = xTime.getTime(); var d1; var d2; //Weekly and Monthly bars are date stamped with the last bar of week or month and //time stamped at 00:00 hours which would be the morning of that day. To facilitate //a comparison check, I add 1-day minus 1 millisecond to the value. x = 0; while( true ) { d1 = getValueAbsolute("Time", -x, getSymbol()+","+xInterval ).getTime()+86399999; d2 = getValueAbsolute("Time", -(x+1), getSymbol()+","+xInterval ).getTime()+86399999; if ((d2==null) || (d1==null)) return( null ); if ((c>d2) && (c<=d1)) { //we want the prior week or month so add 1 to the index return( -(x+1) ); } x++; } return( null ); } //== gID function assigns unique identifier to graphic/text routines function gID() { grID++; return( grID ); } //== draw text labels for the s/r levels function drawLabels( dataArray ) { var x; var sTmp; var sPrice; var xFlags; if ( dataArray==null ) return; //this prevents the labels from printing a gazillion times //as the chart is being built. Speeds up processing if (getCurrentBarIndex() != -1) return; //cycle through the output array and add the corresponding prefix //from the static label array for (x=0; x<dataArray.length; x++) { if (vCalcInterval=="D") sTmp = vLabelArray[x]+"="; if (vCalcInterval=="W") sTmp = vLabelArrayW[x]+"="; if (vCalcInterval=="M") sTmp = vLabelArrayM[x]+"="; if ( dataArray[x] != null ) { if (getBuildNumber() >= 564) { sPrice = formatPriceNumber( dataArray[x] ); xFlags = Text.VCENTER | Text.BOLD | Text.ONTOP; } else { sPrice = rnd( dataArray[x], 2 ); xFlags = Text.BOLD | Text.BOTTOM | Text.ONTOP; } drawTextAbsolute(nOffset, dataArray[x], sTmp+sPrice, nColor, null, xFlags , sFont, nFontSize, gID()); } } return; } //== rnd will round to N digits. function rnd(value, N) { var n; var mult=1; for(n=0;n<N;n++) mult*=10; value*=mult; return Math.round( value,N)/mult; }
  10. I would like to know if someone can convert in TS8 code. Your reward will be good for you and the group. I check and it's maching perfectly the indicator of ttm trend. By the way it's the real code from tradethemarkets. thx philloo /******************************************************************** Title: Trend Indicator for eSignal 7.x By: Chris D. Kryza (Divergence Software, Inc.) Email: c.kryza@gte.net, ckryza@sr-analyst.com Web: http://www.sr-analyst.com Incept: 11/04/2004 Version: 1.0.0 ===================================================================== Fix History: 11/04/2004 - Initial Release 1.0.0 ===================================================================== Project Description: Tradestation conversion. Dislaimer: For educational purposes only! Obviously, no guarantees whatsoever and use at your own risk. **********************************************************************/ //External Variables var grID = 0; var nBarCounter = 0; var aOpen = null; var aClose = null; var aColor = null; var nColor = null; var nColor_1 = null; var nPeriod = null; var aFPArray = new Array(); var bInitialized = false; //== PreMain function required by eSignal to set things up function preMain() { var x; setPriceStudy(true); setStudyTitle("TTM-Trend"); setShowTitleParameters( false ); setColorPriceBars( true ); setDefaultPriceBarColor( Color.black ); //unrem this if you don't want the labels in cursor window setShowCursorLabel(false); grID = 0; //initialize formula parameters x=0; aFPArray[x] = new FunctionParameter( "fPeriod", FunctionParameter.NUMBER); with( aFPArray[x] ) { setName( "Comp Bars" ); setLowerLimit( 1 ); setUpperLimit( 125 ); setDefault( 6 ); } x++; aFPArray[x] = new FunctionParameter( "fUpColor", FunctionParameter.COLOR); with( aFPArray[x] ) { setName( "Up Color" ); setDefault( Color.blue ); } x++; aFPArray[x] = new FunctionParameter( "fDnColor", FunctionParameter.COLOR); with( aFPArray[x] ) { setName( "Dn Color" ); setDefault( Color.red ); } } //== Main processing function function main( fPeriod, fUpColor, fDnColor ) { var x; var nOpen, nClose, nHigh, nLow; //script is initializing if ( getBarState() == BARSTATE_ALLBARS ) { return null; } if ( bInitialized == false ) { nPeriod = Math.round( fPeriod ); aColor = new Array( nPeriod+1 ); aClose = new Array( nPeriod+1 ); aOpen = new Array( nPeriod+1 ); aClose[0] = ( open(0)+high(0)+close(0)+low(0) ) / 4; aOpen[0] = open(0); nBarCounter = 0; bInitialized = true; } //called on each new bar if ( getBarState() == BARSTATE_NEWBAR ) { aOpen.pop(); aOpen.unshift(0); aClose.pop(); aClose.unshift(0); aColor.pop(); aColor.unshift(0); nColor_1 = nColor; nBarCounter++; } nOpen = (aOpen[1]+aClose[1])/2; aOpen[0] = nOpen; nClose = ( open(0)+high(0)+low(0)+close(0) ) / 4; aClose[0] = nClose; nHigh = Math.max( high(0), nOpen, nClose ); nLow = Math.min( low(0), nOpen, nClose ); if ( nClose > nOpen ) { nColor = fUpColor; } else { nColor = fDnColor; } if ( nBarCounter<=nPeriod+2 ) return; x=1; while ( x<=nPeriod ) { if ( nOpen <= Math.max( aOpen[x], aClose[x] ) && nOpen >= Math.min( aOpen[x], aClose[x] ) && nClose <= Math.max( aOpen[x], aClose[x] ) && nClose >= Math.min( aOpen[x], aClose[x] ) ) { nColor = aColor[x]; } x++; } aColor[0] = nColor; setPriceBarColor( nColor ); return( null ); }
×
×
  • Create New...

Important Information

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