//-------------------------------------------------------------------------
// Main code : FX ENTRY SHORT V6
// Use Loop System to define hh And better Entry Point
//-------------------------------------------------------------------------
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
//starttime = 190000// Enter in manually before placing code
//endtime = 193000// Enter in manually before placing code
entry = 6540// Manually Entered as a set point after chart analysis
//noEntryBeforeTime = 191500
//TopofBC = entry +10
//conditional loop to determine hh
timeframe (1 minute, updateonclose)
//refbar = 0
if high > Entry Then
WHILE high > high[1] DO
//refbar = barindex
hh = high
//refbar = refbar + 1
Continue
Break
WEND
ENDIF
timeframe(default, updateonclose)
IF not daysForbiddenEntry and not onmarket THEN
sellshort 1 contract at hh stop
ENDIF
//and time > endtime AND time > noEntrybeforeTime
// Stops and targets
SET STOP pLOSS 30
SET TARGET pPROFIT tp
tp=100
Hi all
I’m running round in circles trying to get a code that will trigger an optimal entry after an initial set point. It needs to go something like this (For a Short Position in this case):
- High > = set point (Manually entered into code)
- Once condition at 1 triggered code compares current to previous high in a continuous loop until current high is < previous
- This current high is then the entry point as long as price is still > original set point
Hope this makes sense? I’ve pasted my initial attempt below, but am really struggling to get it to trigger correctly
Your help is much appreciated
Once condition at 1 triggered code compares current to previous high
So you are looking for a retest of a previous high and when you get a retest fail then there is a good chance that price may go down for a while and so a short is a good bet?
Problem is you would need to define HH and retest HH over a certain number of bars and that certain number of bars is not always the same over and over again?
I’d like to make it a bit simpler than that. All I’m looking to do is once my set point has been broken, I’d like to test the high vs previous high in a loop until the high is > than previous high then enter as long as still above my initial set point. hope this makes sense?
Regards
HH = High > High[1]
HSetPoint = High > Xprice
If HH and HSetPoint Then
Buy at Market
Endif
Above is how I am reading the conditions in your latest post … is that what you mean?
Hey I’m getting worried … it’s starting to seem easier to say stuff in code than in words!! 🙂
Apologies – I’ve been off the screen for a good while so missed your reply!
Thanks for replying and I get what you mean about replying in code, maybe we’re all in the Matrix after all!!
Firstly I do seem to run in to problems as it is very apparent the coding manual I downloaded from PRT Software does not have the complete set of codes and operators, hence I struggle to code what I want my strategies to do! is there a complete set of codes somewhere I am missing?
Back to my original issue.
I think your reply will work, but I still want to run a continuous loop until the condition is true i.e.
- Price is => my set point for the short to trigger the loop (ENTRY)
- A set of conditions i.e. high >high[1]
- Loops until high < high[1]
- Max high within the loop is recored
- Loop stops
- Code enters me into a Short (in this case)
A second condition also need to be added if price doesn’t reverse and keeps on powering up to and/or past x number of pips past my set point for entry. i.e.
I’m guessing an ELSE part of the IF loop:
- high>= ENTRY + 30 (i.e. 30 pips above original set point entry)
- THEN quit i.e. trade is invalid
So to summarise an original set point for entry is entered as a variable within the code, if price = or breaks above the entry level then a loop is initiated until the current high is lower than the previous bar. It loops until this condition is met and then enters as soon as it is.
If it keeps on creating higher highs and breaks above my original set entry point + say 30 pips (variable) the trade is invalid and quits.
Phew! I hope this explains what I am trying to do?
Regards
Steve
is there a complete set of codes somewhere I am missing?
You could try on the link below
https://www.prorealcode.com/prorealtime-documentation/
Phew! I hope this explains what I am trying to do?
It be best if @RobertoGozzi or @Vonasi might help you as it’s getting beyond being straight out of my head now! 🙂
As to the very first post the correct code should be (not tested):
//-------------------------------------------------------------------------
// Main code : FX ENTRY SHORT V6
// Use Loop System to define hh And better Entry Point
//-------------------------------------------------------------------------
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
//starttime = 190000// Enter in manually before placing code
//endtime = 193000// Enter in manually before placing code
entry = 6540// Manually Entered as a set point after chart analysis
//noEntryBeforeTime = 191500
//TopofBC = entry +10
//conditional loop to determine hh
timeframe (1 minute, updateonclose)
refbar = 0
if high > Entry Then
WHILE high[refbar] >= high[refbar +1] DO
hh = high
refbar = refbar + 1
WEND
ENDIF
timeframe(default, updateonclose)
IF not daysForbiddenEntry and not onmarket and high > entry THEN
sellshort 1 contract at hh stop
ENDIF
//and time > endtime AND time > noEntrybeforeTime
// Stops and targets
SET STOP pLOSS 30
SET TARGET pPROFIT tp
tp=100
Hi
I’ve attached the latest code incorporating your suggestion, but it doesn’t seem to go in below the set point and also increase the reference bar until entry? (it’s for a long entry BTW) again I cannot see wht=y the code will not do this? I’ve also attached a screen shot and for the purposes of the example used the FTSE on 20seconds from 17/06/2020 at 02:29 – set point for entry at 2234 with a stop of 10 PIPs.
Regards
// Main code : FX ENTRY LONG T7 - Using Loop condition to Enter
//-------------------------------------------------------------------------
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
if onmarket or strategyprofit<>strategyprofit[1] then
flag = 1
endif
if dayofweek <> dayofweek[1] then
flag = 0
endif
//breakevenstart=25
//pointstokeep=0
entry=6234// Set Point for code to start looking for lowest low
BCBot = Entry-sl// If low gets below this level then trade must be invalidated
// Stops and targets
SET STOP pLOSS sl
SET TARGET pPROFIT tp
sl = 10
tp=50
// Conditions to enter long position
notradetime1=213000
notradetime2=233000
notradetime=time>notradetime1 and time<notradetime2
Starttime = OpenTime
endtime=235900
//Set Up Reference Bar & Entry Conditions for a Buy Trade
timeframe (20 seconds, updateonclose)
if time > starttime and time <= endtime then
if opentime = starttime then
endif
ll = low
endif
if not longonmarket then
//find first new ref bar for long trade
refbar = 0
if (low <= Entry) AND NOT (low <= BCBot)THEN //first ref
WHILE low[refbar]<= low[refbar+1] DO
ll=low
refbar= refbar + 1
Continue
BREAK
WEND
ENDIF
endif
//determines the highest high & lowest low during the period
if time > starttime then
//hh = max(high,hh)
ll = min(low,ll)
endif
IF not daysForbiddenEntry and not flag and not onmarket and not notradetime THEN
Buy 2 contract at ll limit
ENDIF
That makes a big difference – thanks for that I really appreciate your help.
Stay safe