Easylanguage problem - MultiCharts | futures io social day trading

Easylanguage problem
 Updated: January 27th, 2012 (08:14 AM) Views / Replies: 2,620 / 10 Created: January 26th, 2012 (04:53 AM) by mengelbrecht Attachments: 2

 Welcome to futures io.

2

# Easylanguage problem

 January 26th, 2012, 04:53 AM #1 (permalink) Elite Member copenhagen, denmark   Trading Experience: Intermediate Platform: multicharts, Ninja Broker/Data: IB & Kinetick Favorite Futures: ES     Posts: 47 since Aug 2010 Thanks: 16 given, 22 received Easylanguage problem Hi I have an EL problem that I hope someone can help me solve. I am testing a strategy that trades of a line break chart and I want to go long or short if 1 of 2 conditions are met . The second part .. the else part is working fine it is the first part of the equation that I cant get to work ?? Rule for a long position 1. IF High 2 bars back  Low 1 bar back is bigger than 10 ticks then buy  etc else. This is what I have Input: Bars_back (2), Entry_distance(10) Vars: Entry_min(0) Variable Condition: Entry_min = Entry_distance*ticksize Code: if (high[barsback] -low[1])*ticksize > entry_min then  what is wrong with this code ?? rgds Mengelbrecht

 January 26th, 2012, 08:17 AM #2 (permalink) Elite Member Montreal, Canada   Trading Experience: Intermediate Platform: Multicharts Broker/Data: Interactive Broker Favorite Futures: Forex   Posts: 262 since Sep 2010 Thanks: 437 given, 86 received Hello Mengelbrecht Don't have a direct solution for you, but maybe you could join Multicharts forum to ask. Free for owner of licence. Their is a very good support and help from these guy's. Good luck

The Netherlands

Favorite Futures: ...

Posts: 774 since Apr 2010

mengelbrecht
 Hi I have an EL problem that I hope someone can help me solve. I am testing a strategy that trades of a line break chart and I want to go long or short if 1 of 2 conditions are met . The second part .. the else part is working fine it is the first part of the equation that I cant get to work ?? Rule for a long position 1. IF High 2 bars back  Low 1 bar back is bigger than 10 ticks then buy  etc else. This is what I have Input: Bars_back (2), Entry_distance(10) Vars: Entry_min(0) Variable Condition: Entry_min = Entry_distance*ticksize Code: if (high[barsback] -low[1])*ticksize > entry_min then  what is wrong with this code ?? rgds Mengelbrecht

You'll need to provide more concrete information before we can really be of help here. For example, the "1 of 2 conditions" are not in the code, and the 'ticksize' variable is also undefined. Also a screenshot and the use of the [ code ] ... [ / code ] wrappers around your code would make your post easier to understand.

Elite Member
near Paris, France

Platform: -
Favorite Futures: -

Posts: 1,071 since Aug 2011

Hi,

After addition of some ; and definition of ticksize, the following code compiles correctly on my computer.

Code
 ```Input: Bars_back ( 2 ), Entry_distance ( 0); Vars: ticksize ( MinMove / PriceScale ), Entry_min ( 0 ); Entry_min = Entry_distance*ticksize; if (high[Bars_back] -low[1])*ticksize > Entry_min then MessageLog("test");```
Nicolas

 The following user says Thank You to Nicolas11 for this post:

 January 27th, 2012, 05:31 AM #5 (permalink) Elite Member copenhagen, denmark   Trading Experience: Intermediate Platform: multicharts, Ninja Broker/Data: IB & Kinetick Favorite Futures: ES     Posts: 47 since Aug 2010 Thanks: 16 given, 22 received It compiles correctly , but it doens't solve my problem - I provide more information shortly. :-) Thx to everyone so far rgds mengelbrecht

 January 27th, 2012, 05:35 AM #6 (permalink) Elite Member near Paris, France   Trading Experience: Beginner Platform: - Favorite Futures: -     Posts: 1,071 since Aug 2011 Thanks: 2,232 given, 1,731 received For our help to be more efficient, could you kindly explain precisely in your next post what your "problem" is. I mean: what are your expecting from the code? and what is the actual result of the code (which does not satisfy you)?

Elite Member
copenhagen, denmark

Platform: multicharts, Ninja
Broker/Data: IB & Kinetick
Favorite Futures: ES

Posts: 47 since Aug 2010

Hi everyone attached you'll find the EL code. The code highligted in red is causing me a problem. This system basicly takes all the trades based on the "else" conditions, so I have come to the conclution that something is wrong with the first part os the entry conditions - the 64000 \$ questions is what is wrong ??

I have attached a chart that hopefully explains what I am trying to achieve.

In words I want my entry condition to look like this
Example for a short condition
1: IF the distance between high[1] and low[2] is greater than Entry_dist then sellshort at low[2] - lmt_entry stop else
sellshort at low of current bar - lmt entry stop;
Hope it makes sense

rgds
mengelbrecht

Code
 ```Price( Close ), Barsback (2), Cts(70000), CTS_tgt1(70000), TGT1(80), Stop1 (40), Starttrade(830), Endtrade(1600), dailyprofit(1200), dailyloss(400), LMT_entry (1), Entry_dist (5); Variables: var0( 0 ), var1(0), ticksize (0), targit1(0), targit2(0), Stoploss1 (0), stoploss2(0), todaynet(0), yesterdaynet(0), priordate (date), Limit_entry (0),o1 (0), c1(0), o2(0), c2 (0), o3(0), c3(0), o4(0), c4(0), entry_min(0); o1 = Open of data1; c1 = Close of data1; o2 = Open[1] of data1; c2 = Close[1] of data1; o3 = Open[2] of data1; c3 = Close[2] of data1; o4 = open[3] of data1; c4 = Close[3] of data1; //Varible conditions ticksize= MinMove/PriceScale; Limit_entry = lmt_entry*ticksize; targit1= tgt1*ticksize; stoploss1 = stop1*ticksize; entry_min = Entry_dist*ticksize; // Bar definitions Condition1 = c1 > o1; // Current bar is up Condition2 = c2 > o2; // one bar ago is up Condition3 = c3 > o3; // two bars ago is up Condition4 = c4 > o4; // three bars ago is up Condition5 = c1 < o1; // Current bar is down Condition6 = c2 < o2; // one bar ago is down Condition7 = c3 < o3; // two bars ago is Down Condition8 = c4 < o4; // Three bars ago is Down once begin priordate = Date - 1; end; if date > priordate then begin priordate = date; yesterdaynet = NetProfit; end; todaynet = NetProfit + openpositionprofit - commission - yesterdaynet; // General condition condition99 = (-dailyloss < todaynet and todaynet < dailyprofit) and (Time > starttrade and time < endtrade); /// Entry long If condition99 then begin if (high[barsback] -low[1])*ticksize > entry_min and condition5 then buy ("buy1") cts contracts next bar at (low[barsback] + Limit_entry) stop else if (high[barsback] -low[1])*ticksize < entry_min and condition1 and condition6 then buy ("buy2") cts contracts next bar at (high + Limit_entry) stop; end; /// Entry Short If condition99 then begin if (high[1]-low[barsback] )*ticksize > entry_min and condition1 then sellshort ("sell1") cts contracts next bar at (high[barsback] - Limit_entry) stop else if (high[1]-low[barsback] )*ticksize < entry_min and condition5 and condition2 then sellshort ("sell2") cts contracts next bar at (low - Limit_entry) stop; end; //Moneymanagement if marketposition = 1 then begin If currentcontracts = Cts then sell ("LONG_TGT1") CTS_tgt1 contracts next bar at (openentryprice + targit1) limit; end; if marketposition = -1 then begin If currentcontracts = Cts then buytocover ("Short_TGT1") CTS_tgt1 contracts next bar at (openentryprice - targit1) limit; end; //exit on close If marketposition = 1 then begin if currentcontracts = CTS and time > endtrade then sell ("LX_Close1") cts contracts next bar at market; if currentcontracts = (CTS-CTS_tgt1) and time > endtrade then sell ("LX_Close2") (CTS-CTS_tgt1)contracts next bar at market; end; If marketposition = -1 then begin if currentcontracts = CTS and time > endtrade then buytocover ("SX_Close1") cts contracts next bar at market; if currentcontracts = (CTS-CTS_tgt1) and time > endtrade then buytocover ("SX_Close2") (CTS-CTS_tgt1)contracts next bar at market; end; // Exit on Todaynet If marketposition = 1 then begin if currentcontracts = CTS and (todaynet > dailyprofit or todaynet < -dailyloss ) then sell ("Pos_LX_close1") cts contracts this bar at close; if currentcontracts = (CTS-CTS_tgt1) and (todaynet > dailyprofit or todaynet < -dailyloss ) then sell ("Pos_LX_close2") (CTS-CTS_tgt1) contracts this bar at close; end; If marketposition = -1 then begin if currentcontracts = CTS and (todaynet > dailyprofit or todaynet < -dailyloss ) then buytocover ("Pos_SX_close1") cts contracts this bar at close; if currentcontracts = (CTS-CTS_tgt1) and (todaynet > dailyprofit or todaynet < -dailyloss ) then buytocover ("Pos_SX_close2") (CTS-CTS_tgt1) contracts this bar at close; end; // StopLoss If MarketPosition = 1 Then begin If CurrentContracts = Cts then sell ("Long_stoploss1") cts contracts next bar at (openentryprice - Stoploss1) stop ; If CurrentContracts = (CTS-CTS_tgt1) then sell ("Long_stoploss2") (CTS-CTS_tgt1) contracts next bar at (openentryprice - Stoploss1) stop ; end; If MarketPosition = -1 Then begin If CurrentContracts = Cts then buytocover ("short_stoploss1") cts contracts next bar at (openentryprice + Stoploss1) stop ; If CurrentContracts = (CTS-CTS_tgt1)then buytocover ("short_stoploss2") (CTS-CTS_tgt1) contracts next bar at (openentryprice + Stoploss1) stop ; end;```

Attached Thumbnails

Elite Member
near Paris, France

Platform: -
Favorite Futures: -

Posts: 1,071 since Aug 2011

 This post has been selected as an answer to the original posters question

I fear that there is a problem in units.

"entry_min = Entry_dist*ticksize;"
means that:
• Entry_dist shall be expressed in ticks: is it the case?
• ticksize shall be in \$ per tick, which is the case
• entry_min is in \$ (not in ticks): is it what you want?
"(high[1]-low[barsback] )*ticksize" is wrong, since \$ is multiplied by \$.
If you want \$, just write "high[1]-low[barsback]".
If you want ticks, you have to divide by ticksize: "(high[1]-low[barsback] ) / ticksize"

Nicolas

 The following user says Thank You to Nicolas11 for this post:

Elite Member
copenhagen, denmark

Platform: multicharts, Ninja
Broker/Data: IB & Kinetick
Favorite Futures: ES

Posts: 47 since Aug 2010

Hi Nicholas
a HUUUGE thank you for your input
- I have changed the code see below - changed from multiply to devide :-).
All trades is now done based on the first rule - no validation seems to take place - see attached screenshot. The arrow point to an entry that should been based on the second (else) rule.

Code
 ```/// Entry long If condition99 then begin if (high[barsback] -low[1])/ticksize > entry_min and condition5 then buy ("buy1") cts contracts next bar at (low[barsback] + Limit_entry) stop else if (high[barsback] -low[1])/ticksize < entry_min and condition1 and condition6 then buy ("buy2") cts contracts next bar at (high + Limit_entry) stop; end; /// Entry Short If condition99 then begin if (high[1]-low[barsback] )/ticksize > entry_min and condition1 then sellshort ("sell1") cts contracts next bar at (high[barsback] - Limit_entry) stop else if (high[1]-low[barsback] )/ticksize < entry_min and condition5 and condition2 then sellshort ("sell2") cts contracts next bar at (low - Limit_entry) stop; end;```

Attached Thumbnails

 January 27th, 2012, 07:42 AM #10 (permalink) Elite Member near Paris, France   Trading Experience: Beginner Platform: - Favorite Futures: -     Posts: 1,071 since Aug 2011 Thanks: 2,232 given, 1,731 received You're welcome. But take care, there might still be an issue: (high[barsback] -low[1])/ticksize > entry_min Left size of the inequality is in ticks Right size of the inequality is in \$ (if entry_min is still defined by "Entry_min = Entry_distance*ticksize;") This is not consistent. Nicolas
 The following 2 users say Thank You to Nicolas11 for this post:

 futures io > Easylanguage problem

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

February

Feb 19

Feb 21

Mar 5

Mar 12

Mar 19

## Day Trading Oil Futures: Reducing Risk & Increasing Profits w/DTN IQFeed

Mar 26

 Similar Threads Thread Thread Starter Forum Replies Last Post ericbrown EasyLanguage Programming 3 January 31st, 2013 05:33 PM energetic EasyLanguage Programming 3 August 22nd, 2011 03:07 PM Ozons EasyLanguage Programming 3 February 13th, 2011 01:28 AM Cogito ergo sum EasyLanguage Programming 10 August 2nd, 2010 03:12 PM

 Tags buy, buytocover, c2, code, commission, cts, data, dow, easylanguage, el, es, information, line break, line break chart, marketposition, multicharts, short, stoploss, strategy, support