Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Logic is, first three conditions defines open type ( in this code it is open drive) in first half an hour after session open.
so far so good, no problem,
Now problem arises with second part of the logic, I want to buy highest high of last 5 bars ( tf is 15 min ) after 1 hr of the session start when above three conditions ( condition1, condition2 and condition3) are true.
Ex. Market opene at 9 am by 9.30 we get signal as open drive. We wait for an hour then afterwords wait for the opportunity to buy when high is greater than highest high of last 5 bars {( h >(h,5)[1]} but MC cant let it happen
because among previous three conditions there is one parameter which says time <0930 ( i.e. time is less than 9.30 am ) so all the code stop working after 9.30am
I have tried barssince entry, barcount = barcount+1 etc but it's somehow not working, I can compile the code but it doesnt reflect on chart as per logic.
posting the chart for reference..
I've slightly changed your code and added some comments inside it (see those comments for what might still be wrong with the code). I've added a check that the time should be more than one hour after the open, and then, if condition1-3 are true, a limit order is submitted for the highest price of the last 5 bars, excluding the current bar.
Do note that the 'Highest(High, 5)[1]' part means that every bar the limit price can change (since the highest high is recalculated on each bar), which can mean that you have trouble getting the limit order filled.
Also, with multiple entries, be sure to check this checkbox:
Example of above code (I don't know if this is what you intended it to do?):
Thanks Jura for the time and effort. I applied the indicator edited by you but it's still giving the poblem. I am feeling that might be my MC is corrupted, to verify could you please try it on your end, I have attached the data.
First please apply this indicator on the data that i have attached, it will show OD(open drive) as text on the chart.
Now apply your indicator, whenever there is OD printed only on at that day our strategy suppose to execute.
Here how it look in my window
If I attach that indicator to my chart and then the strategy from the earlier post, I get this:
That looks good right? (where the 'OD' text appeared I've drawn a lightblue arrow to spot it easier) Or do you don't want the "fe#2" orders been shown?
Hi Jura,
Thank you so much for your time and quick replies, seems like we will get the solution. Here in your chart buy signal appears on the same bar where OD( Open Drive) appears. Once we get the confirmation of Open Drive then after we suppose to enter the market when high is higher than highest(h,4)[1] ( MC calculate from left so shouldn't be any problem) I can understand that fe#2 is there for teh same purpose but it triggers even though there is no open drive at the start of session.
P.S. to complete the strategy stop loss would be l<lowest(l,5); When I saw it visually felt promising stuff so thats why putting so much effort. Once this done then there are codes ready for other open types and based on OD module could code easily for other open types.
I was trying to debug the code one structure at a time, and seems like problem lies in time< time[1] ( or date<> date[1] ) line. Here is an experiment..
Run this code without time<time[1] ( or date<> date[1] )
vars: highesthi(0);
if time>0900 and time<1500 {and date<>date[1]}
then begin
highesthi = highest(high[1],5);
if high>highesthi then buy next bar at market;
end;
setexitonclose;
you will get accurate signals
now add time>time[1] or date<>date[1] linr
vars: highesthi(0);
if time>0900 and time<1500 and date<>date[1]
then begin
highesthi = highest(high[1],5);
if high>highesthi then buy next bar at market;
end;
setexitonclose;
now see the chart, it give erratic signals.
I can't understand why this is happening.
Update
Issue resolved. As Jura posted it correctly by avoiding date<>date[1] filter.
This happens because the command date<>date[1] is only useful for first bar of the day, from second bar of the day this filter has no meaning at all as it only stores information for the first bar of the day.
Better way to code intraday strategy is using only time filter
Inputs: MarketOpen(0915),MarketClose(1530);
if time > MarketOpen and time < MarketClose then begin