NexusFi: Find Your Edge


Home Menu

 





Easylanguage problem


Discussion in MultiCharts

Updated
      Top Posters
    1. looks_one mengelbrecht with 5 posts (0 thanks)
    2. looks_two Nicolas11 with 4 posts (4 thanks)
    3. looks_3 Jura with 1 posts (0 thanks)
    4. looks_4 arjfca with 1 posts (0 thanks)
    1. trending_up 4,701 views
    2. thumb_up 4 thanks given
    3. group 2 followers
    1. forum 10 posts
    2. attach_file 2 attachments




 
Search this Thread

Easylanguage problem

  #1 (permalink)
 
mengelbrecht's Avatar
 mengelbrecht 
copenhagen, denmark
 
Experience: Intermediate
Platform: multicharts, Ninja
Broker: IB & Kinetick
Trading: ES
Posts: 47 since Aug 2010
Thanks Given: 16
Thanks Received: 23

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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
  #2 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91

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

Reply With Quote
  #3 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690



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

Reply With Quote
  #4 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

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

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
 
mengelbrecht's Avatar
 mengelbrecht 
copenhagen, denmark
 
Experience: Intermediate
Platform: multicharts, Ninja
Broker: IB & Kinetick
Trading: ES
Posts: 47 since Aug 2010
Thanks Given: 16
Thanks Received: 23

It compiles correctly , but it doens't solve my problem - I provide more information shortly. :-)
Thx to everyone so far

rgds mengelbrecht

Started this thread Reply With Quote
  #6 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

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

Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
 
mengelbrecht's Avatar
 mengelbrecht 
copenhagen, denmark
 
Experience: Intermediate
Platform: multicharts, Ninja
Broker: IB & Kinetick
Trading: ES
Posts: 47 since Aug 2010
Thanks Given: 16
Thanks Received: 23

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
Click image for larger version

Name:	EL_problem1.jpg
Views:	124
Size:	150.2 KB
ID:	60761  
Started this thread Reply With Quote
  #8 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

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

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #9 (permalink)
 
mengelbrecht's Avatar
 mengelbrecht 
copenhagen, denmark
 
Experience: Intermediate
Platform: multicharts, Ninja
Broker: IB & Kinetick
Trading: ES
Posts: 47 since Aug 2010
Thanks Given: 16
Thanks Received: 23

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
Click image for larger version

Name:	EL_problem2.jpg
Views:	116
Size:	134.1 KB
ID:	60768  
Started this thread Reply With Quote
  #10 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769


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

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on January 27, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts