Convert Prorealtime code to metatrader

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

Convert Prorealtime code to metatrader

Postby Jack6324 » Mon Jun 07, 2021 11:59 pm

Hi,

I need some help to convert my prorealtime code to metatrader 4 please :

Code: Select all
DEFPARAM CumulateOrders = false
DEFPARAM Preloadbars = 50000
once overnightposition  = 1//0
once weekendposition    = 1//0
once psInit = 1 // positionfixe
once psOnMarket = 0.2 //or 0.4, 0.6,... 1
once TPShort = 2.0
once TPLong = 2.0
once SLShort = 0.6
once SLLong = 2.6
MM = 2 //0 = Fixe position 1 = MM optimisé 2 =  MM Simple
if MM = 1 then
positionsize=psInit
ENDIF
if MM = 1 then
ONCE startpositionsize = 1
ONCE factor = 30
ONCE margin = (close*.05)
ONCE margin2 = (close*.05)
ONCE tier1 = 55
ONCE maxpositionsize = 5
ONCE minpositionsize = 0.2
positionsize=psOnMarket
IF Not OnMarket THEN
positionsize = startpositionsize + Strategyprofit/(factor*margin)
IF startpositionsize + Strategyprofit/(factor*margin) > tier1 then
positionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1
ENDIF
if startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THEN
positionsize = minpositionsize
ENDIF
IF (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 > maxpositionsize then
positionsize = maxpositionsize
ENDIF
ENDIF
ENDIF
if MM = 2 then
if OnMarket then
positionsize=psOnMarket
endif
IF Not OnMarket THEN
positionsize = psinit
ENDIF
ENDIF

//--------------------------------------------------------------------------------------------------------------------------------------------------

//TRADING HOURS
Ctime = time >= 151500 and time < 210000



//--------------------------------------------------------------------------------------------------------------------------------------------------

//STRATEGY
//VECTOR = ANGLE

i1 = HistoricVolatility[10](close)
c1 = (i1 >= 0.06)

ONCE PeriodeA = 4
ONCE nbChandelierA= 30
MMA = Exponentialaverage[PeriodeA](close)
ADJASUROPPO = (MMA-MMA[nbchandelierA]) / nbChandelierA
ANGLE = (ATAN(ADJASUROPPO)) //FONCTION ARC TANGENTE
CB1 = ANGLE >= 34
CS1 = ANGLE <= - 48


//VECTOR = PENTE AND MOVING AVERAGE
ONCE PeriodeB = 30
ONCE nbChandelierB= 35
lag = 0
MMB = Exponentialaverage[PeriodeB](close)
pente = (MMB-MMB[nbchandelierB]) / nbchandelierB
trigger = Exponentialaverage[PeriodeB+lag](pente)
CB2 = (pente > trigger) AND (pente < 0)
CS2 = (pente CROSSES UNDER trigger) AND (pente > - 0.5)

mx = average[67,0](close)
CB3 = mx > mx[1]
mx2 = average[21,0](close)
CS3 = mx2 < mx2[1]


// ichimoku
Tenkan = (highest[9](high)+lowest[9](low))/2
Kijun = (highest[26](high)+lowest[26](low))/2
SSpanA = (tenkan[26]+kijun[26])/2
SSpanB = (highest[52](high[26])+lowest[52](low[26]))/2
////chikou=close



If SSpanA>SSpanB then
if open<SSpanA and open>SSpanB or close<SSpanA and close>SSpanB then
CondIchi = 0
Else
CondIchi = 1
endif
endif

If SSpanB>SSpanA then
if open>SSpanA and open<SSpanB or close>SSpanA and close<SSpanB then
CondIchi = 0
Else
CondIchi = 1
endif
endif

//--------------------------------------------------------------------------------------------------------------------------------------------------

//TRADING ENTRY
CONDBUY = CB1 and CB2 and CB3 and CTime and c1 and CondIchi
CONDSELL = CS1 and CS2 and CS3 and Ctime and c1 and CondIchi

VarDistIchiBuy = 6
VarDistIchiSell = 21


If CONDBUY then
DistIchiSSA = Open - SSpanA
DistIchiSSB = Open - SSpanB
CondDistIchi = DistIchiSSA >= VarDistIchiBuy AND DistIchiSSB >= VarDistIchiBuy
Endif

If CONDSELL then
DistIchiSSA = SSpanA - Open
DistIchiSSB = SSpanB - Open
CondDistIchi = DistIchiSSA >= VarDistIchiSell AND DistIchiSSB >= VarDistIchiSell
Endif

CONDBUY = CONDBUY and CondDistIchi
CONDSELL = CONDSELL and CondDistIchi


//--------------------------------------------------------------------------------------------------------------------------------------------------

//MONEY MANAGEMENT

//POSITION LONGUE
IF CONDBUY THEN
buy positionsize contract at market
SET STOP %LOSS 2.6
ENDIF

//POSITION COURTE
IF CONDSELL THEN
Sellshort positionsize contract at market
SET STOP %LOSS 0.6
ENDIF

//--------------------------------------------------------------------------------------------------------------------------------------------------
breakevenPercent = 0.13
PointsToKeep = 15
startBreakeven = tradeprice(1)*(breakevenpercent/100)
once breakeven = 1
if breakeven>0 then
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven THEN
breakevenLevel = tradeprice(1)+PointsToKeep
ENDIF
IF breakevenLevel>0 THEN
SELL AT breakevenLevel STOP
ENDIF
IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven THEN
breakevenLevel = tradeprice(1)-PointsToKeep
ENDIF
IF breakevenLevel>0 THEN
EXITSHORT AT breakevenLevel STOP
ENDIF
endif
once trailingstoptype = 1
once tsincrements = 0.19
once tsminatrdist = 5
once tsatrperiod    = 14
once tsminstop      = 12
once tssensitivity  = 1
if trailingstoptype then
if barindex=tradeindex then
trailingstoplong  = 6
trailingstopshort = 3
else
if longonmarket then
if tsnewsl>0 then
if trailingstoplong>tsminatrdist then
if tsnewsl>tsnewsl[1] then
trailingstoplong=trailingstoplong
else
trailingstoplong=trailingstoplong-tsincrements
endif
else
trailingstoplong=tsminatrdist
endif
endif
endif
if shortonmarket then
if tsnewsl>0 then
if trailingstopshort>tsminatrdist then
if tsnewsl<tsnewsl[1] then
trailingstopshort=trailingstopshort
else
trailingstopshort=trailingstopshort-tsincrements
endif
else
trailingstopshort=tsminatrdist
endif
endif
endif
endif
tsatr=averagetruerange[tsatrperiod]((close/10))/1000
tgl=round(tsatr*trailingstoplong)
tgs=round(tsatr*trailingstopshort)
if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
tsmaxprice=0
tsminprice=close
tsnewsl=0
endif
if tssensitivity then
tssensitivitylong=high
tssensitivityshort=low
else
tssensitivitylong=close
tssensitivityshort=close
endif
if longonmarket then
tsmaxprice=max(tsmaxprice,tssensitivitylong)
if tsmaxprice-tradeprice(1)>=tgl*pointsize then
if tsmaxprice-tradeprice(1)>=tsminstop then
tsnewsl=tsmaxprice-tgl*pointsize
else
tsnewsl=tsmaxprice-tsminstop*pointsize
endif
endif
endif
if shortonmarket then
tsminprice=min(tsminprice,tssensitivityshort)
if tradeprice(1)-tsminprice>=tgs*pointsize then
if tradeprice(1)-tsminprice>=tsminstop then
tsnewsl=tsminprice+tgs*pointsize
else
tsnewsl=tsminprice+tsminstop*pointsize
endif
endif
endif
if longonmarket then
if tsnewsl>0 then
sell at tsnewsl stop
endif
if tsnewsl>0 then
if low crosses under tsnewsl then
sell at market
endif
endif
endif
if shortonmarket then
if tsnewsl>0 then
exitshort at tsnewsl stop
endif
if tsnewsl>0 then
if high crosses over tsnewsl then
exitshort at market
endif
endif
endif
endif


Thanks for your help.

Best regards,
Last edited by Jack6324 on Tue Jun 08, 2021 12:38 pm, edited 1 time in total.
Jack6324
 
Posts: 2
Joined: Mon Jun 07, 2021 11:54 pm

Re: Convert Prorealtime code to metatrader

Postby Apprentice » Tue Jun 08, 2021 6:25 am

Your request is added to the development list.
Development reference 558.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36476
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Convert Prorealtime code to metatrader

Postby Apprentice » Thu Jun 10, 2021 9:39 am

Your request is added to the development list.
Development reference 565.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36476
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Convert Prorealtime code to metatrader

Postby Jack6324 » Sat Jun 12, 2021 9:34 am

Hello,

Any progress on the conversion?

Thanks
Jack6324
 
Posts: 2
Joined: Mon Jun 07, 2021 11:54 pm


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: Majestic-12 [Bot] and 34 guests