Logical error in the strategy based on open types - EasyLanguage Programming | futures io social day trading
futures io futures trading


Logical error in the strategy based on open types
Updated: Views / Replies:1,229 / 7
Created: by Alexlaxmikant Attachments:4

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Logical error in the strategy based on open types

  #1 (permalink)
Trading Apprentice
India
 
Futures Experience: Intermediate
Platform: Multi charts
Broker/Data: Esignal, interactive brokers, religare
Favorite Futures: Nifty
 
Posts: 18 since May 2010
Thanks: 39 given, 8 received

Logical error in the strategy based on open types

Hi,
I am facing some logical error in below code
 
Code
inputs:timeopen(0945);
vars:  od(0);
od = (h-l)*4/5 ;
condition1 = (h-l) >= ((o - l) + od) ;
condition2 = close>open and (h-l)> average((h-l),10);
condition3 = low> low[1] + ((h[1]-l[1])/2) and c >c[1];
if time < timeopen then 
begin
if condition1 and condition2 and condition3 then buy 
this bar at close;
end;
if time<time[1] then begin
value1 = barssinceentry(1);
if value1 >=4 and value1<8 and high> highest(h,3)[1] then buy 
("fe") 2 shares next bar at market; 
end;
setexitonclose;
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..

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Uploaded with ImageShack.us..

Reply With Quote
The following user says Thank You to Alexlaxmikant for this post:
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
 Vendor: tradingcode.net 
The Netherlands
 
Futures Experience: None
Platform: MultiCharts, TradingView
Favorite Futures: ...
 
Jura's Avatar
 
Posts: 774 since Apr 2010
Thanks: 2,347 given, 661 received


Hi Alex,

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.
 
Code
inputs:
    timeopen(0945);

vars:  
    od(0), highestHigh(0);

od = (h-l) * 4/5;

condition1 = (High - Low) >= ((Open - Low) + od) ;
condition2 = Close > Open and (High - Low)> Average((High - Low),10);
condition3 = low > ( low[1] + ((High[1] - Low[1]) / 2) ) and Close > Close[1];

// Opening the 'open drive' position
if time < timeopen then begin
    if condition1 and condition2 and condition3 then 
        buy ("od") this bar at close;                    // PS: Buying at the close can in a backtest, but not in real-time/demo trading
end;

{
    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. 
}
highestHigh = Highest(High, 5)[1];

if (Time > (timeOpen + 100))        // Open a position if it's later than 1045
        and (condition1 = true) and (condition2 = true) and (condition3 = true) then
    
        Buy ("fe#2") 2 shares next bar at highestHigh limit;

if time < time[1] then begin                    // Isn't this statement always true?

    value1 = barssinceentry(1);
    if value1 >=4 and value1<8 and high> highest(h,3)[1] then 
        buy ("fe") 2 shares next bar at market; 

end;

setexitonclose;
Also, with multiple entries, be sure to check this checkbox:

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Example of above code (I don't know if this is what you intended it to do?):

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
The following 2 users say Thank You to Jura for this post:
 
  #4 (permalink)
Trading Apprentice
India
 
Futures Experience: Intermediate
Platform: Multi charts
Broker/Data: Esignal, interactive brokers, religare
Favorite Futures: Nifty
 
Posts: 18 since May 2010
Thanks: 39 given, 8 received

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.

 
Code
inputs:timeopen(0945);
vars: od(0);
od = (h-l)*4/5 ;
condition1 = (h-l) >= ((o - l) + od) and
 time<= timeopen;
condition2 = close>open and (h-l)> average((h-l),10);
condition3 = low> low[1] + ((h[1]-l[1])/2) and c >c[1];
if condition1 and condition2 and condition3 then
value1 = text_new ( date, time, open, "OD");
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

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Uploaded with ImageShack.us

Attached Files
Register to download File Type: rar temp data bmt.rar (506.4 KB, 6 views)
Reply With Quote
The following user says Thank You to Alexlaxmikant for this post:
 
  #5 (permalink)
 Vendor: tradingcode.net 
The Netherlands
 
Futures Experience: None
Platform: MultiCharts, TradingView
Favorite Futures: ...
 
Jura's Avatar
 
Posts: 774 since Apr 2010
Thanks: 2,347 given, 661 received


Alexlaxmikant View Post
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.

 
Code
inputs:timeopen(0945);
vars: od(0);
od = (h-l)*4/5 ;
condition1 = (h-l) >= ((o - l) + od) and
 time<= timeopen;
condition2 = close>open and (h-l)> average((h-l),10);
condition3 = low> low[1] + ((h[1]-l[1])/2) and c >c[1];
if condition1 and condition2 and condition3 then
value1 = text_new ( date, time, open, "OD");
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

Hi Alex,

If I attach that indicator to my chart and then the strategy from the earlier post, I get this:

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


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?

Reply With Quote
 
  #6 (permalink)
Trading Apprentice
India
 
Futures Experience: Intermediate
Platform: Multi charts
Broker/Data: Esignal, interactive brokers, religare
Favorite Futures: Nifty
 
Posts: 18 since May 2010
Thanks: 39 given, 8 received

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.

Reply With Quote
 
  #7 (permalink)
Trading Apprentice
India
 
Futures Experience: Intermediate
Platform: Multi charts
Broker/Data: Esignal, interactive brokers, religare
Favorite Futures: Nifty
 
Posts: 18 since May 2010
Thanks: 39 given, 8 received

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] )

 
Code
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
 
Code
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.

Reply With Quote
 
  #8 (permalink)
Trading Apprentice
India
 
Futures Experience: Intermediate
Platform: Multi charts
Broker/Data: Esignal, interactive brokers, religare
Favorite Futures: Nifty
 
Posts: 18 since May 2010
Thanks: 39 given, 8 received

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

Reply With Quote

Reply



futures io > > > > > Logical error in the strategy based on open types

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exit open positions based on time guppy EasyLanguage Programming 5 April 27th, 2017 02:53 PM
Anybody tried Logical Forex? shodson Trading Reviews and Vendors 1 July 13th, 2013 07:43 PM
Strategy based off 2 instruments? tellytub NinjaTrader Programming 1 March 8th, 2010 02:51 PM
Logic Error in Strategy HJay NinjaTrader Programming 14 November 1st, 2009 07:05 PM
Combining strategy optimization types caprica NinjaTrader Programming 0 July 27th, 2009 05:52 AM


All times are GMT -4. The time now is 12:50 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-14 in 0.12 seconds with 20 queries on phoenix via your IP 54.221.93.187