Multi timeframe – MTF indicators for ProRealTime
Forums › ProRealTime English forum › ProBuilder support › Multi timeframe – MTF indicators for ProRealTime
- This topic has 145 replies, 48 voices, and was last updated 1 month ago by druby.
Tagged: mtf, mtf indicators
-
-
07/08/2024 at 9:51 AM #23492407/08/2024 at 10:31 AM #234929
Place your code related to the 60-minutes timeframe under this statement:
1TIMEFRAME(1 hour, updateonclose) //use update on close or not?and the rest, about the 1-minute conditions below this:
1TIMEFRAME(default)Default is the current timeframe of the chart.
07/08/2024 at 2:22 PM #234950HI, dos not work . My code (not even finished at that stage) is looking like . The idea is to check few indicators during a 1 hour timeframe ad if one of the indicator is correctly responding, then to generate immedately an order during the 1 minute timeframe… It means i need to get the expected signal during the 60 minutes timeframe and immediately react under the 1 mn timeframe. It also means i cannot wait the 1 hour TF is closed and restart ….thats probably the issue. I also tested the condition all conditions = order or 1 of the conditions )= order. without success.
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d’une position avant l’heure spécifiée
noEntryBeforeTime = 003000
timeEnterBefore = time >= noEntryBeforeTime
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d’une position après l’heure spécifiée
noEntryAfterTime = 215500
timeEnterAfter = time < noEntryAfterTime
// Conditions pour ouvrir une position acheteuse
timeframe (60 minutes)
indicator1 = xxxx[x]
c1 = (indicator1 > x)
indicator2 = xxxxxx[x]
indicator3 = xxxxx[x](open)
c2 = (indicator2 CROSSES OVER indicator3)
indicator4 = xxxxx[x](totalPrice)
indicator5 = xxxxxxx[x](totalPrice)
c3 = (indicator4 CROSSES OVER indicator5)
indicator6 = xxxxxx[x](totalPrice)
indicator7 = xxxxx[x](totalPrice)
c4 = (indicator6 CROSSES OVER indicator7)
indicator8 = xxxxxxxxx[x,y](close)
indicator9 = xxxxxxx[x](xxxxxxxxxx[x,y](close))
c5 = (indicator8 CROSSES OVER indicator9)
indicator10 = xxxxxxxx[x](xxxxxxxxxxxxxxxx[x,y](close))
c6 = (indicator10[1] CROSSES OVER indicator10)
c7 = (indicator2[1] CROSSES OVER indicator3)
timeframe(1 minute,default)
IF (c1 AND c2 AND c3 AND c4 AND c5 AND c6 And 7) AND not daysForbiddenEntry THEN
BUY 1 SHARES AT MARKET
ENDIF
07/08/2024 at 3:34 PM #234956Hmmm
Lolzzzz
Anyway, your want an indicator on the 1hr timeframe to trigger a buy or sell on the 1 minute timeframe…
It wont happen, becuase you may have to wait a minute for the close of the 1 minute… so here’s an example code, but for an immediate reaction run on the 1 second timeframe not 1 minute…Let me give you a code for running a code on 1 second chart only using the values or results from 5 or 10 minutes chart.
So once you have the variable triggered in the HTF the in the below case it retains the value of the close, otherwise it updates all the time and messes up the trail… sotimeframe (1hour, updateonclose)
If not onmarket then
mytrigger=0
endif
if movingaverageA crossesovermoving averageB then
Mytrigger=1
else
mytrigger=0
endif
timeframe (1 second)
If not onmarket and mytrigger=1 then
sell myamount contracts at market
endif// If you use the 1 minute chart, you may have to await the end of bar, so for immediate execution use the 1 second timeframe for execution of trades and HTFs for conditions determination
Timeframe (10 minute, updateonclose) //this will ensure only the close value is taken and it doesnt constantly update on the deafault timeframe//
Timeframe (10 minute, updateonclose)
if close[0] then
close10min=close[0]
endifTimeframe (5 minute, updateonclose)
if close[0] then
close5min=close[0]
endiftimeframe (default)//you can put this as 5 minutes, or whatever but the code runs on the 1 second chart and runs the dax trail perfectly well
if daxtrail5mins=1 then
once m=0
IF Not OnMarket THEN
trailpausecount=0
TrailStart = 8 //10 Start trailing profits from this point
BasePerCent = 0.100 //10.0% Profit to keep
StepSize = 3 //6 Pips chunks to increase Percentage
PerCentInc = 0.100 //10.0% PerCent increment after each StepSize chunk
RoundTO = -0.5 //-0.5 rounds to Lower integer, +0.4 rounds to Higher integer
PriceDistance = 7 * pipsize//8.9 minimun distance from current price
y1 = 0
y2 = 0
ProfitPerCent = BasePerCent
endif
If onmarket and m=0 then
m=1
ENDIF
If not onmarket and m=1 THEN
QUIT
endif
If trailtimeframe=5 then
close5=close5min
elsif trailtimeframe=10 THEN
close5=close10min
endif
If onmarket and close5 then
IF LongOnMarket AND close5 > (TradePrice + (y1 * pipsize)) THEN //LONG
x1 = (close5 – tradeprice) / pipsize //convert price to pips
IF x1 >= TrailStart THEN //go ahead only if N+ pips
Diff1 = abs(TrailStart – x1)
Chunks1 = max(0,round((Diff1 / StepSize) + RoundTO))
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc))
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))
y1 = max(x1 * ProfitPerCent, y1) //y = % of max profit
ENDIF
ELSIF ShortOnMarket AND close5 < (TradePrice - (y2 * pipsize)) THEN//SHORT x2 = (tradeprice - close5) / pipsize //convert price to pips IF x2 >= TrailStart THEN //go ahead only if N+ pips
Diff2 = abs(TrailStart – x2)
Chunks2 = max(0,round((Diff2 / StepSize) + RoundTO))
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc))
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))
y2 = max(x2 * ProfitPerCent, y2) //y = % of max profit
ENDIF
ENDIF
IF y1 THEN //Place pending STOP order when y>0
SellPrice = Tradeprice + (y1 * pipsize) //convert pips to price
IF abs(close5 – SellPrice) > PriceDistance THEN
IF close5 >= SellPrice THEN
SELL AT SellPrice STOP
ELSE
SELL AT SellPrice LIMIT
ENDIF
ELSE
SELL AT Market
ENDIF
If not onmarket and m=1 THEN
QUIT
endif
ENDIF
IF y2 THEN //Place pending STOP order when y>0
ExitPrice = Tradeprice – (y2 * pipsize) //convert pips to price
IF abs(close5 – ExitPrice) > PriceDistance THEN
IF close5 <= ExitPrice THEN EXITSHORT AT ExitPrice STOP ELSE EXITSHORT AT ExitPrice LIMIT ENDIF ELSE EXITSHORT AT Market ENDIF If not onmarket and m=1 THEN quit endif ENDIF endif endif
07/08/2024 at 3:42 PM #234957U know I didnt have insrt PRT code in my before window, so sorry abo that, thought something had changed, but now its there again…. Hmmm
Heres the codes again
multi timeframe events causing trigger in LTF12345678910111213timeframe (1hour, updateonclose)If not onmarket thenmytrigger=0endifif movingaverageA crossesovermoving averageB thenMytrigger=1elsemytrigger=0endiftimeframe (1 second)If not onmarket and mytrigger=1 thensell myamount contracts at marketendifquit as its ran on a manual entry program on 1 seconds12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182if close[0] thenclose10min=close[0]endifTimeframe (5 minute, updateonclose)if close[0] thenclose5min=close[0]endiftimeframe (default)//you can put this as 5 minutes, or whatever but the code runs on the 1 second chart and runs the dax trail perfectly wellif daxtrail5mins=1 thenonce m=0IF Not OnMarket THENtrailpausecount=0TrailStart = 8 //10 Start trailing profits from this pointBasePerCent = 0.100 //10.0% Profit to keepStepSize = 3 //6 Pips chunks to increase PercentagePerCentInc = 0.100 //10.0% PerCent increment after each StepSize chunkRoundTO = -0.5 //-0.5 rounds to Lower integer, +0.4 rounds to Higher integerPriceDistance = 7 * pipsize//8.9 minimun distance from current pricey1 = 0y2 = 0ProfitPerCent = BasePerCentendifIf onmarket and m=0 thenm=1ENDIFIf not onmarket and m=1 THENQUITendifIf trailtimeframe=5 thenclose5=close5minelsif trailtimeframe=10 THENclose5=close10minendifIf onmarket and close5 thenIF LongOnMarket AND close5 > (TradePrice + (y1 * pipsize)) THEN //LONGx1 = (close5 – tradeprice) / pipsize //convert price to pipsIF x1 >= TrailStart THEN //go ahead only if N+ pipsDiff1 = abs(TrailStart – x1)Chunks1 = max(0,round((Diff1 / StepSize) + RoundTO))ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc))ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))y1 = max(x1 * ProfitPerCent, y1) //y = % of max profitENDIFELSIF ShortOnMarket AND close5 < (TradePrice - (y2 * pipsize)) THEN//SHORT x2 = (tradeprice - close5) / pipsize //convert price to pips IF x2 >= TrailStart THEN //go ahead only if N+ pipsDiff2 = abs(TrailStart – x2)Chunks2 = max(0,round((Diff2 / StepSize) + RoundTO))ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc))ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))y2 = max(x2 * ProfitPerCent, y2) //y = % of max profitENDIFENDIFIF y1 THEN //Place pending STOP order when y>0SellPrice = Tradeprice + (y1 * pipsize) //convert pips to priceIF abs(close5 – SellPrice) > PriceDistance THENIF close5 >= SellPrice THENSELL AT SellPrice STOPELSESELL AT SellPrice LIMITENDIFELSESELL AT MarketENDIFIf not onmarket and m=1 THENQUITendifENDIFIF y2 THEN //Place pending STOP order when y>0ExitPrice = Tradeprice – (y2 * pipsize) //convert pips to priceIF abs(close5 – ExitPrice) > PriceDistance THENIF close5 <= ExitPrice THEN EXITSHORT AT ExitPrice STOPELSEEXITSHORT AT ExitPrice LIMITENDIFELSEEXITSHORT AT MarketENDIFIf not onmarket and m=1 THENquitendifENDIFendifendif08/22/2024 at 9:59 PM #236623I would like to make an indicator with different timeframes. To give an example: If I wanted to observe if the RSI is oversold in a time frame of 1 second, let me know with a signal in a time frame of 5 minutes, which is where I usually work. My goal is to be able to save time and not have to change time frames.
This you think can be achieved. I’ve been thinking about it for a while but I can’t do it.Thank you.
08/23/2024 at 9:11 AM #236629The support for multiple time frames implies that on a 1-second TF you can check conditions on a 5-minute TF, not the other way round.
The TF on your chart must always be the smallest one. Of course you can have both the 1-second and 5-minute TF on your chart, but the indicator needs to be added to the 1-second TF.
1 user thanked author for this post.
08/23/2024 at 9:22 PM #23666510/14/2024 at 1:17 PM #23897510/16/2024 at 11:49 AM #239054is it possible to get hold of a value returned by a personal indicator placed on a 3600 tick chart inside a 3 minute chart? This would be the difference between finding intraday trades 5 days a week and not finding one trade, on time, in a week.
10/16/2024 at 3:15 PM #239079If your thinking of back-testing and automatic trading I think the answer is no.
But if just as an indicator and manual trading, then very loosely Maybe.
Arrays update on each tick, in a indicator, so you could count/accumulate the data.
Storing it, and aligning to what was on the tick chart would be tricky but I think doable.
However , when a chart is built, it appears to use OHLC bar data until current bar where ticks available.
Therefore you couldn’t gain access or look back for the ticks before current bar when chart opened.
So either you would have to wait to accumulated enough tick data and/or open chart substantially earlier than you need.
The automatic closing of PRT would lose the tick data gathered on close/reboot.
Also, if the chart window was re-calculated and updated, for any reason while open, the data would get lost.
So though it maybe possible, it would be a nightmare to use.
The simple reason would be, you can not store user data in the program which would be available the next time its run/opened.
Now it maybe easier to build the 3min time frame on the 3600 tick chart.
All 3min indicators would have to be converted.
One limiting factor would be the number of bar needed in the chart to calculate the 3min indicators.
Its hard to say yes with out knowing the full details of what your doing.
Which ever way, it’s an out of the box, programming challenge.
https://www.prorealcode.com/topic/show-5-minute-candlestick-in-1-minute-chart/
-
AuthorPosts