Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 10-20-2011, 02:26 PM   #9

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Re: EasyLanguage Help Needed

Actually, the "EntryPrice" reserved word does not need the "NUM" input to be designated, BUT I think that the MarketPosition reserved word DOES need the "NUM" input to be designated:

MarketPosition(1)
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
Old 10-21-2011, 06:16 PM   #10

Join Date: Feb 2009
Location: Los Angeles
Posts: 33
Ignore this user

Thanks: 1
Thanked 3 Times in 3 Posts

Re: EasyLanguage Help Needed

Possibly the condition entryprice+X points stop is not met because the market falls after your first buy and the order never executes. Is that maybe?
equtrader is offline  
Reply With Quote
Old 10-25-2011, 10:59 AM   #11

Join Date: Oct 2011
Posts: 7
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: EasyLanguage Help Needed

Quote:
Originally Posted by equtrader »
Possibly the condition entryprice+X points stop is not met because the market falls after your first buy and the order never executes. Is that maybe?
Hi equatrader and thank you to try to help me
Unfortunately this isn’t the problem because it doesn’t opens other positions even if the price go my way and reach the entry price+X points leve and goes even much further...

Quote:
Originally Posted by Tradewinds »
This is from the Easy Language help:
Are you entering a number for how many entry orders back the entry was? You need to use the syntax:

EntryPrice(1)
Tradewinds, this is enlightening!
I just wanted to buy X points over the last entry so “entry price(1)” would be perfect!
So I changed the code this way:

Code:
If marketposition = 0 and ConditionLong Then Buy next bar At High + 1 point stop;
If marketposition > 0 then buy next bar at Entryprice(1) + X points stop;

Unfortunately the problem still persisted and the TS opened just the first position.

Then I tried to experiment another way:
I changed the pyramid filter from a constant number of points (X) to a fraction of the ATR:
Code:
var1 = AvgTrueRange( ATRLength ) * NumATRs;

If marketposition = 0 and ConditionLong Then Buy next bar At High + 1 point stop;
If marketposition > 0 then buy next bar at Entryprice(1) + var1 stop;
And, surprisingly to me, it worked!

But not the way I was looking for, because it opens positions even if the price goes down till the exit condition is met.

I want it to pyramid adding positions only if the price goes in the right direction…precisely every X ATR (or X points) from the last entry price...
LiukK is offline  
Reply With Quote
Old 11-02-2011, 07:39 PM   #12

Join Date: May 2010
Posts: 180
Ignore this user

Thanks: 0
Thanked 47 Times in 38 Posts

Re: EasyLanguage Help Needed

Code:
var: x(0), mp(0), cs(0), np(0), step(2);

mp=marketposition;
cs=currentshares;
np=entryprice+cs*step;

if mp=0 and d=1111102 then buy next bar market;
if mp>0 then buy next bar np stop;

if cs<>cs[1] then begin
    x=text_new(d,t,np,"next="+numtostr(np,2));  text_setstyle(x,1,2);
end;
onesmith is offline  
Reply With Quote
Old 12-03-2011, 07:52 AM   #13

Join Date: Oct 2011
Posts: 7
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: EasyLanguage Help Needed

Quote:
Originally Posted by onesmith »
Code:
var: x(0), mp(0), cs(0), np(0), step(2);

mp=marketposition;
cs=currentshares;
np=entryprice+cs*step;

if mp=0 and d=1111102 then buy next bar market;
if mp>0 then buy next bar np stop;

if cs<>cs[1] then begin
    x=text_new(d,t,np,"next="+numtostr(np,2));  text_setstyle(x,1,2);
end;

Hi onesmith, and thank you for the reply!
As I said in the first post I’m still a newbie in programming and, honestly, I’m not yet so skilled to understand totally the code you posted.

Anyway I tried it but again it wasn’t doing what I’m looking for

I write here the full code of this (“simple once coded”) trading system:

Code:
Inputs: Price(Close), LenA(10), LenB(100), ATRLength(20), NumATRs(1) ;

var:  mp(0), var0(0), var1(0), var2(0);

mp=marketposition*currentshares;
var0 = Average(Price, LenA);
var1 = Average(Price, LenB);
var2 = AvgTrueRange( ATRLength ) * NumATRs;


Condition1 = var0>var1;
Condition2 = var0<var1;


If mp = 0 and Condition1 Then Buy next bar At High + var2 stop;

If mp > mp[1] then buy next bar at entryprice + var2 stop;

If mp > 0 and Condition2 Then sell next bar at market;
Basically I want the TS to open positions perpetually at step of an ATR fraction till the condition to close them is met... like the TS of the Richard Dennis's turtles but with a limitless number of positions.

How people can code this?
LiukK is offline  
Reply With Quote
Old 12-03-2011, 10:29 AM   #14

Join Date: May 2010
Posts: 180
Ignore this user

Thanks: 0
Thanked 47 Times in 38 Posts

Re: EasyLanguage Help Needed

// CrossPrice is set to H of bar when FastAvg crosses above SlowAvg.
// PreviousPrice stores most recent EntryPrice.

// if mp=0 then NextPrice is CrossPrice+atr.
// if mp=1 then NextPrice is PreviousPrice+atr.

Code:
var:  fast(0), slow(0), atr(0), cs(0), crossPrice(0), previousPrice(0), nextPrice(0);

fast=average(c,10);
slow=average(c,100);
atr=AvgTrueRange(20);
cs=currentshares;

if fast>slow then begin
    if fast crosses above slow then begin
        crossPrice=H;    nextPrice=crossPrice+atr;
    end;
    if cs>0 then begin
        if cs>cs[1] then previousPrice=maxlist(open,nextPrice);
        nextPrice=previousPrice+atr;
    end else nextPrice=crossPrice+atr;
    if crossPrice>0 then buy next bar nextPrice stop;
end else sell next bar market;
onesmith is offline  
Reply With Quote
The Following User Says Thank You to onesmith For This Useful Post:
LiukK (12-03-2011)
Old 12-03-2011, 01:21 PM   #15

Join Date: Oct 2011
Posts: 7
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: EasyLanguage Help Needed

Quote:
Originally Posted by onesmith »
// CrossPrice is set to H of bar when FastAvg crosses above SlowAvg.
// PreviousPrice stores most recent EntryPrice.

// if mp=0 then NextPrice is CrossPrice+atr.
// if mp=1 then NextPrice is PreviousPrice+atr.

Code:
var:  fast(0), slow(0), atr(0), cs(0), crossPrice(0), previousPrice(0), nextPrice(0);

fast=average(c,10);
slow=average(c,100);
atr=AvgTrueRange(20);
cs=currentshares;

if fast>slow then begin
    if fast crosses above slow then begin
        crossPrice=H;    nextPrice=crossPrice+atr;
    end;
    if cs>0 then begin
        if cs>cs[1] then previousPrice=maxlist(open,nextPrice);
        nextPrice=previousPrice+atr;
    end else nextPrice=crossPrice+atr;
    if crossPrice>0 then buy next bar nextPrice stop;
end else sell next bar market;
Onesmith...you're great, I really don't know how to thank you enough...
the TS works perfectly now
there are so many things I still don't know and your help have been really invaluable
LiukK is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
What else is Needed to Get It Right? bharatk8 Tools of the Trade 0 04-10-2011 06:55 PM
EL Help Needed swakpixel Coding Forum 6 05-01-2010 06:28 AM
Jurik Easylanguage Functions Needed simterann22 Coding Forum 2 08-20-2009 12:01 PM
just what i needed xztheericzx Beginners Forum 0 11-04-2007 05:21 AM

All times are GMT -4. The time now is 11:03 AM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.