Abordamos o tema de automatização de estratégias em NTSL, MQL5 e NinjaScript!
Será que alguém consegue converter os códigos abaixo para o Profit?
{******************************************************************** TPO Pro indicator Original TPO Pro5 by ???? 5c 5b 203.21 Added VAH VAL Lines & PriceAxis Markers, Flipped Histogram 30303 Seperating Plot Colors, Widths , History from Current Plots Removed Code for Letters, was unnecessary duplicated 30304 Major Overhaul , changed names, cleaned code, more readable 30309 Removed Today's VA Lines replotting next to new lines 30414 Input Names changed, Todays VA Lines plot once 31002 same as 40101 Added a lot. wishlist: plot multiple days histo.... extend VAH &VAL Lines ********************************************************************} [LegacyColorValue = false]; input: _HISTOGRAM_PLOT_SETTINGS_(0), PlotTPOHistogramABcText (false), HistogramTextColor (magenta), HistogramLetter_Symbol (""), HistoSymbol_if_ABCTxt_False ({MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}{MustHave "Quotes" InputAbove}0), _VA_RANGE_TEXT_LABELS_(0), ShowTodaysVARange_TextString (false), TodaysVARange_TextStringColor (white), ShowPriorVARangeTextLables (false), ColorPastVARangeTextLabels (darkmagenta), _VARANGE_VERTICAL_LINESnDOT_(0), POCdot_Color (white), POCdot_ThicknessWidth (5), VArangeVerticalLine_Color (magenta), VArangeVerticalLine_Width (5), //cPastVAVerticalRangeLine (magenta), //ColorPastVerticalPOCDots (white), //wPastVA_VerticalRangeLine (5), //wPastVAMidPointDots (5), _TODAYS_VAH_VAL_LINES_(0), WidthTodaysVA_HighLowLines (2), TodaysVAHigh_LineColor (blue), TodaysVALow_LineColor (red), TodaysPOC_LineColor (yellow), _PRIORHISTORY_VAH_VAL_LINES_(0), ShowPriorHistoryVALines (false), cPastVAHigh_LineColor (red), cPastVALow_LineColor (blue), wPastVAHigh_VALow_LineThickness (1), _REPLOT_PRICE_BARS_SETTINGS_ (0), RePlotPriceBarsOverHistgram (true), ReplotPriceBars_LineWidth (2), ReplotPriceBarsWick_Color (black), PriceBarCloseDot_Color (darkgray), cBarUp (green), cBarDN (rgb(200,0,0)), _LAST_PRICE_FLOATING_LINE_(0), ShowCurrentLastPriceLine (true), LastPrice_LineColor (LightGray), _SETTINGS_(0), ValueAreaRange_Percent (.7), Stime (1615), compress (1), len (30), letter_1 (2), ValueAreaSize_n (4); vars: intrabarpersist Color(0), x(0),y(0),TPOtotal(0), //lett("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"}), CurTxt(""),CurLet(""),OldLet(""),letter1(0),lcount(1), dHi(0),dLo(0),HH(0),LL(0),BarHi(0),BarLo(0), Time0(0),DayNum(0),d0(0),dl(0),DayLow(0), VA(0),VaMid(0),VAP(0),VAH(0),OldVAH(0),VAL(0),OldVAL(0),Valsize(0), // {"vap"=ValueAreaPercent} PC(0),PC2(0),et(0),FP(0),skp(0),tot(0),tpstr("00"),xpts(0), vCurPOC(0),POC(0),OldPOC(0),CP(0),// {"CP "= CenterPoint Center of Distribution ?POC?} nuFlag(0),Flag2(0),NewDayFlag(0), cVrtRng(0), wVrtRng(0), TL_VrtPOC(0), TL_VrtRng(0), TL_hVrtRng(0), Labl(0),cRngLbl(0),chRngLbl (0), Price(0),cLstPrc(0),TL_LstPrc(0), cPOC(0),cVAH(0),cVAL(0),chVAH(0),chVAL(0),ctPOC(0), whVaHL(0),wVaHL(0),wPOC(0), phVaHL(false),pLstPrc(false),pHisLbl(false),ptLabl(false), TL_POC(0),TL_VAH(0),TL_VAL(0), ctHisto(0), pHistoTxt(true), HistoChar("8"), pCurLoc(0), D1p(0),D2p(0),T1p(0),T2p(0), PBWick(0),cPBWick(0),wPBWick(0),pPBWick(false), PBBody(0),cPBBody(0),wPBBody(0), mintick(0); array: aPRI[1000](0), aTPO[1000](0), aPriStr[1000](""); {? Primary String ?} if currentbar = 1 then begin letter1 = letter_1 ; ctHisto = HistogramTextColor ; //cPOC = ColorPastVerticalPOCDots ; cLstPrc = LastPrice_LineColor ; cVrtRng = VArangeVerticalLine_Color ; //cVrtRng = cPastVAVerticalRangeLine ; cPBWick = ReplotPriceBarsWick_Color ; cPBBody = PriceBarCloseDot_Color ; cRngLbl = TodaysVARange_TextStringColor ; chRngLbl= ColorPastVARangeTextLabels ; cPOC = POCdot_Color ; ctPOC = TodaysPOC_LineColor; cVAH = TodaysVAHigh_LineColor ; cVAL = TodaysVALow_LineColor ; chVAH = cPastVAHigh_LineColor ; chVAL = cPastVALow_LineColor ; wPOC = minlist (6, POCdot_ThicknessWidth ); wVrtRng = minlist (6, VArangeVerticalLine_Width ); //wVrtRng = minlist (6, wPastVA_VerticalRangeLine ); wVaHL = minlist (6, WidthTodaysVA_HighLowLines ); //wPOC = minlist (6, wPastVAMidPointDots ); whVaHL = minlist (6, wPastVAHigh_VALow_LineThickness ); wPBWick = minlist (6, ReplotPriceBars_LineWidth ); wPBBody = minlist (6, wPBWick + 1 ); //wVaHL = minlist (6, WidthTodaysVA_HighLowLines ); //wTodayVAL= minlist (6, wTodaysValueAreaLowLine ); pHistoTxt= PlotTPOHistogramABcText ; HistoChar= HistogramLetter_Symbol ; pPBWick = RePlotPriceBarsOverHistgram ; pLstPrc = ShowCurrentLastPriceLine ; ptLabl = ShowTodaysVARange_TextString; pHisLbl = ShowPriorVARangeTextLables ; phVaHL = ShowPriorHistoryVALines ; VAP = ValueAreaRange_Percent ; Valsize = ValueAreaSize_n ; {Line Thickness for VA horiz lines} mintick = 1 point * minmove * compress ; xpts = 500 * mintick ; end; {***** START PROGRAM IF TIME IS WITHIN DAY SESSION HOURS *****} if BarStatus(1) = 2 then begin nuFlag = 0 ; if Time0 <= sess1endtime and t > sess1endtime and sess2starttime <> 0 then nuFlag = 1 else if d <> d0 and sess2starttime = sess2endtime then nuFlag = 1 else if Time0 = sess1endtime then nuFlag = 1 ; if NuFlag = 1 then begin if currentbar > 1 then begin if cVrtRng <> 0 { if PlotHistogram = true } and Flag2 = 0 then begin VaMid = 0 ; TPOtotal = 0 ; POC = dLo ; CP = dLo + (( dHi - dLo )*.5);// {"CP "=CenterPoint center of dist.} for x = dLo to dHi begin if aPriStr[x] <> "" then begin //aPriStr[x] = nutpstr( aTPO[x], aPriStr[x], aPRI[x]); {places NumberCharacter in front of Histogram Text History Plots} TPOtotal = TPOtotal + aTPO[x]; {Total TPO Count} if aTPO[x] = VaMid and x <= CP then POC = x ; if aTPO[x] = VaMid and x > CP and ( x - CP ) < AbsValue( CP - POC ) then POC = x ; if aTPO[x] > VaMid then begin POC = x ; VaMid = aTPO[x] ; end; end; // {end of "if aPriStr[x] <> "" then begin"} end; {end of "for x = dLo to dHi begin "} VA = TPOtotal * vap ; x = VaMid ; VAH = POC ; VAL = POC ; x = 0 ; while x < VA begin value19 = aTPO[VAH+1] + aTPO[VAH+2]; value20 = aTPO[VAL-1] + aTPO[VAL-2]; if value19 >= value20 then begin if x + aTPO[ VAH +1] >= VA then begin x = x + aTPO[ VAH +1]; VAH = VAH + 1 ; end else begin x = x + value19; VAH = VAH + 2 ; end; end else begin if x + aTPO[ VAL -1] >= VA then begin x = x + aTPO[ VAL -1]; VAL = VAL - 1 ; end else begin x = x + value20; VAL = VAL - 2 ; end; end; end;// {end of ":if value19 >= value20"} end;// {end of " while x < VA begin"} //{***** PAST HISTORY VALUE AREA TEXT LABLES below pricebars *********} if VAH > dHi then VAH = dHi ; {"tHi"=Today'sHigh} if VAL < dLo then VAL = dLo ; VAH = FP + ((VAH-500) * mintick ); VAL = FP + ((VAL-500) * mintick ); vCurPOC = FP + (( POC -500 ) * mintick ); if pHisLbl then begin Labl = text_new( D2p , T2p , dl - mintick ,"VA:"+mp_str32(VAL) + " " + mp_str32(VAH)); text_setstyle( Labl , 0 , 2 ); text_setcolor( Labl , chRngLbl ); end; {***** SETS PAST HISTORY VA VERTICAL LINE ****************************************************} TL_hVrtRng = tl_new( D1p , T1p , VAH , D1p , T1p , VAL ); tl_setcolor( TL_hVrtRng , cVrtRng ); tl_setsize ( TL_hVrtRng , wVrtRng ); {***** SETS PAST HISTORY POC VERTICAL-LINE/DOT OF VALUE AREA ******************************************} TL_VrtPOC = tl_new( D1p , T1p , vCurPOC + mintick /15, D1p , T1p , vCurPOC - mintick /15 ); //tlVACpt = tl_new ( D1p , T1p , vCurPOC + mintick /15, D2p , T1p , vCurPOC - mintick /15 ); //Above tl_new Creates a POC Line spanning the entire day tl_setcolor( TL_VrtPOC , cPOC ); tl_setsize ( TL_VrtPOC , wPOC ); { {***** VA HISTOGRAM RED TEXT row **************************************************************} PC2 = 0 ; for y = dLo to dHi begin Price= FP + ((y-500) * mintick ) ; if Price <= pc then PC2 = y ; end; if PC2 = 0 then PC2 = BarLo ; CurTxt = aPriStr[pc2] ; if RightStr( CurTxt , 1) <> "<" then begin text_setstring( aPRI[pc2] , CurTxt + " <"); text_setcolor ( aPRI[pc2] , cClose ); end; } end; {end of "if currentbar > 1 then begin" line164} D1p = d - 1 ; {Used on TLs as Yesterday D1p,T1p=1stBar B4 New Session} T1p = SessionEndTime(1,1) ; {Used on TLs as begining Time} T2p = t ; {1st TimeStamp of New Day (for line locations)} D2p = d ; { Date/Day to Plot (for line locations)} Labl = 0 ; TL_hVrtRng = 0 ; {30304xx } {***** HISTOGRAM TEXT LETTERS *************************************************} for value1 = dLo to dHi begin aPriStr[value1] = "" ; aTPO[value1] = 0 ; end; //CurLet = curletstr( stime ,len, letter1 ); //Old CurLet = CurLet ; NewDayFlag = 0 ; DayLow = l ; FP = o ; dHi = 500 ; dLo = 500 ; //30425 //aTPO[500] = 1 ; //aPRI[500] = text_new(d, T2p ,o," >" + CurLet ); // aPriStr[500] = " >" + CurLet ; //text_setstyle( aPRI[500] , 1 , 2 ); //text_setcolor( aPRI[500] , darkgray); HH = o ; LL = o ; VaMid = 1 ; tot = 1 ; dl = l ; value22 = currentbar; if d = juliantodate(lastCalcJdate) then Flag2 = 1 ; end; {end of "if NuFlag = 1 then begin" line161} { CURRENT DAY HISTOGRAM PLOT SYMBOL/CHARACTER instead of ABCs chose one letter} if pHistoTxt then CurLet = curletstr( stime , len , letter1 ) else CurLet = HistoChar ; Time0 = t ; d0 = d ; pc = C ; BarHi = intportion(( xpts + H - FP + ( mintick /10))/ mintick ); BarLo = ceiling (( xpts + l - FP - ( mintick /10))/ mintick ); if BarHi > dHi then dHi = BarHi ; {tH = Today's High price} if BarLo < dLo then dLo = BarLo ; if low < dl then dl = l ; if datacompression = 0 and currentbar > value22 then begin //lcount = lcount + 1 ; {"lcount"=LetterCount a-z,A-Z} //if lcount = 53 then lcount = 1 ; {Reset to first of 52 letters} //CurLet = midstr( lett , lcount ,1); HH = o ; LL = o ; NewDayFlag = NewDayFlag + 1 ; end; value22 = CurrentBar ; if datacompression = 1 and OldLet <> CurLet then begin HH = o ; LL = o ; NewDayFlag = NewDayFlag + 1 ; end; {***** HISTOGRAM LETTERS *****************************************************} for y = BarLo to BarHi begin Price = FP + ((y-500) * mintick ); CurTxt = aPriStr[y] ; if CurTxt = "" then begin aTPO[y] = 1 ; aPRI[y] = text_new( D2p ,2300, Price ," " + CurLet ); // aPRI[y]= text_new(D2p,T2p,price," "+ CurLet ); aPriStr[y] = " " + CurLet ; // aPriStr[y]=" "+ CurLet ; {SETS HISTO PLOT Left1/VaMid0/Right2 of PriceBar} text_setstyle( aPRI[y],1,0); //text_setstyle( aPRI[y],0,0); text_setcolor( aPRI[y],ctHisto); end else begin if leftstr( CurTxt ,1) <> CurLet then begin //if RightStr( CurTxt,1) <> CurLet then begin text_setstring( aPRI[y] , CurTxt + CurLet ); //text_setstring( aPRI[y], CurTxt+ CurLet ); aPriStr[y] = CurTxt + CurLet ; aTPO[y] = aTPO[y] + 1 ; end; end; end; {end of "for y = BarLo to BarHi begin"} {***** HighestHigh LowestLow of the Day **************************************} if h > HH then HH = h ; if l < LL then LL = l ; {*************************************************************} if cVrtRng <> 0 {if No color speced then no Histogram calced or plotted} and lastbaronchart then begin VaMid = 0 ; value16 = 0 ; TPOtotal = 0 ; POC = dLo ; CP = dLo + ( dHi - dLo )/2; {center of dist.} //{***** TODAY'S HISTOGRAM PLOT ************************************************} for x = dLo to dHi begin if aPriStr[x] <> "" then begin //aPriStr[x] = nutpstr( aTPO[x] , aPriStr[x] , aPRI[x] ); {Numbered Outline of Today's Histogram } TPOtotal = TPOtotal + aTPO[x] ; {total tpo count} if aTPO[x] = VaMid and x <= CP then POC = x ; if aTPO[x] = VaMid and x > CP and (x- CP ) < absvalue(CP - POC ) then POC = x ; if aTPO[x] > VaMid then begin POC = x ; VaMid = aTPO[x]; end; end; {end of "if aPriStr[x] <> "" then begin"} end; {end of "for x = dLo to dHi begin"} VA = TPOtotal * vap ; if l < DayLow then begin {if Low < Dailylow} DayLow = l ; Price = FP +(( dLo -501) * mintick ); if Labl <> 0 then Text_SetLocation( Labl , D2p , T2p , Price ); end; //{***** VALUE AREA TEXT ploted above PriceBars CURRENT DAY *****************************} if ptLabl then begin if Labl = 0 then begin pCurLoc = GetAppInfo(aiHighestDispValue) - (10 * mintick) ; {New Location at Top of Chart} //Price = FP +(( dLo -501) * mintick ); {Prior30321, VA Txtlocation difficult to see } Labl = text_new( D2p , T2p , pCurLoc, "-" ); //Labl = text_new( D2p , T2p , Price, "-" ); text_setstyle( Labl , 2 , 3 ); text_setcolor( Labl , cRngLbl ); //text_setcolor(Labl,cRngLbl); {Current VA Values & TextPlots are Updated on Line459} end; end; if VA <> 0 then begin value61 = value18; x = VaMid ; VAH = POC ; VAL = POC ; while x < VA begin value19 = aTPO[ VAH +1] + aTPO[ VAH +2] ; value20 = aTPO[ VAL -1] + aTPO[ VAL -2] ; if value19 >= value20 then begin if x + aTPO[ VAH +1] >= VA then begin x = x + aTPO[ VAH +1] ; VAH = VAH + 1 ; end else begin x = x + value19 ; VAH = VAH + 2 ; end; end else begin if x + aTPO[ VAL -1] >= VA then begin x = x + aTPO[ VAL -1] ; VAL = VAL - 1 ; end else begin x = x + value20 ; VAL = VAL -2; end; end; end; {end of "while x < VA begin"} //{***** MOST CURRENT VALUE AREA & POC CENTER POINT *************************} if VAH > dHi then VAH = dHi ; if VAL < dLo then VAL = dLo ; OldPOC = POC ; OldVAH = VAH ; OldVAL = VAL ; VAH = FP + ((VAH-500) * mintick ); VAL = FP + ((VAL-500) * mintick ); if NewDayFlag = 1 then value63 = t ; if VAH > VAL and NewDayFlag > 1 then begin if TL_VrtRng = 0 then begin //{***** CURRENT DAY VALUE AREA VERTICAL LINE **************************************} TL_VrtRng = tl_new( D1p , T1p , VAH , D1p , T1p , VAL ); tl_setcolor ( TL_VrtRng , cVrtRng ); tl_setsize ( TL_VrtRng , wVrtRng ); //tl_setsize(VrtRng,wVrtRng); vCurPOC = FP +(( OldPOC - 500 ) * mintick ); //{*** CURRENT DAY POC,VAL & VAH (Vertical & Horizontal Lines) ********************} TL_VrtPOC = tl_new( D1p , T1p , vCurPOC + mintick /15, D1p , T1p , vCurPOC - mintick /15); tl_setcolor( TL_VrtPOC , cPOC ) ; //tl_setcolor(tlVACpt,cVrtRng); tl_setsize ( TL_VrtPOC , wPOC ) ; //tl_setsize(tlVACpt,value88); plot1( vCurPOC , "POCaxis", ctPOC ) ; plot2( VAH ,"VAHaxis", cVAH ); plot3( VAL ,"VALaxis", cVAL ); // {***** Horizontal Lines *****} TL_VAH = tl_new( D2p , T2p , VAH , D2p , t , VAH ); tl_setcolor( TL_VAH , cVAH ); tl_setsize ( TL_VAH , wVaHL ); TL_VAL = tl_new( D2p , T2p , VAL , D2p , t , VAL ); tl_setcolor( TL_VAL , cVAL ); tl_setsize ( TL_VAL , wVaHL ); TL_POC = tl_new( D2p , T2p , vCurPOC , D2p , t , vCurPOC ); tl_setcolor( TL_POC , ctPOC ); tl_setsize ( TL_POC , wVaHL ); end else begin if OldVAH <> VAH then begin tl_setbegin( TL_VrtRng , D1p , T1p , VAH ); //tl_setbegin( TL_VAH , D2p , T1p , VAH ); {Current ValueAreaHigh Line} //tl_setend ( TL_VAH , D2p , t , VAH ); end; if OldVAL <> VAL then begin tl_setend ( TL_VrtRng , D1p , T1p , VAL ); //tl_setbegin( TL_VAL , D2p , T1p , VAL ); //tl_setend ( TL_VAL , D2p , t , VAL ); end; end; end; {end of "if VAH > VAL and NewDayFlag > 1 then begin"} if NewDayFlag > 1 {and value61 <> value18 } then begin vCurPOC = FP + (( OldPOC - 500 ) * mintick ); tl_setbegin( TL_VrtPOC , D1p , T1p , vCurPOC + mintick / 15 ); tl_setend ( TL_VrtPOC , D1p , T1p , vCurPOC - mintick / 15 ); end; text_setstring( Labl ,"CurVA:"+mp_str32( VAL ) + " " + mp_str32( VAH )); end; {end of "if VA <> 0 then begin" line#300} end; {end of "if cVrtRng <> 0 and lastbaronchart " line#263} {**** PRIOR HISTORY VAH & VAL LINES ***********************************} If phVaHL then begin var: TL_hVAH (0), TL_hVAL (0); TL_hVAH = tl_new( D1p-1 , T1p , VAH , D2p , T2p , VAH ); TL_hVAL = tl_new( D1p-1 , T1p , VAL , D2p , T2p , VAL ); tl_setcolor( TL_hVAH , chVAH ); tl_setsize ( TL_hVAH , whVaHL ); tl_setcolor( TL_hVAL , chVAL ); tl_setsize ( TL_hVAL , whVaHL ); end; {***** MostRecent LastClosingPrice (floating Horizontal Line) ************************} //var: TL_LstPrc (0); if pLstPrc then begin if TL_LstPrc = 0 and currentbar = 3 then begin TL_LstPrc = tl_new( value50 , value51 ,c,d,t,c ); tl_setcolor ( TL_LstPrc , cLstPrc ); {Color of CurrentPrice floating Line} tl_setsize ( TL_LstPrc , 1 ); TL_SetExtLeft( TL_LstPrc , true ); end else if currentbar > 3 and LastBarOnChart then begin tl_setend ( TL_LstPrc ,d,t,c); tl_setbegin( TL_LstPrc , value52 , value53 ,c ); tl_setend ( TL_POC , d , t , vCurPOC ); tl_setbegin( TL_POC , d , 930, vCurPOC ); tl_setend ( TL_VAH , d , t , VAH ); tl_setbegin( TL_VAH , d , 930, VAH ); tl_setend ( TL_VAL , d , t , VAL ); tl_setbegin( TL_VAL , d , 930, VAL ); //if h > HH then tl_setend ( TL_hVAH , d , t , VAL ); end; value52 = value50 ; value53 = value51 ; value50 = d ; value51 = t ; end; end; //{end of "if BarStatus(1)=2 then begin"} {**** PRICEBAR REPLOT OVER TOP OF HISTOGRAM & LINES *****} if pPBWick then begin if C > C[1] and C[1] < C[2] then Color = green else if C < C[1] and C[1] > C[2] then Color = red else if C > O then Color = cBarUP else Color = cBarDN ; PBWick = tl_new( D, T , Low , D, T, High ); tl_setcolor( PBWick , cPBWick ); tl_setsize ( PBWick , wPBWick ); //tl_setsize ( PBWick , wPBWick ); PBBody = tl_new( D, T, Open , D, T, Close ); tl_setcolor( PBBody , Color ); tl_setsize ( PBBody , wPBBody ); //tl_setsize ( PBBody , wPBBody ); end; {end of "if pPBWick then begin"}
Boa noite @mahalo!
Cara, acho improvável alguém se dar ao trabalho de fazer uma tradução para NTSL do código acima de livre espontânea vontade e gratuitamente.
Acredito que você tem maior chance de sucesso contratando algum programador para este trabalho, pois é algo que vai exigir bastante tempo. (E nem entrei no mérito se é possível em NTSL)
Grande abs!
kkkkkk