NexusFi: Find Your Edge


Home Menu

 





Filter trades by using +DMI, help needed


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one abcplot with 2 posts (0 thanks)
    2. looks_two RM99 with 2 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 SPTrading with 1 posts (0 thanks)
    1. trending_up 4,248 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

Filter trades by using +DMI, help needed

(login for full post details)
  #1 (permalink)
abcplot
vienna
 
Posts: 14 since May 2011
Thanks Given: 6
Thanks Received: 3

Hello,


First off all here is a screenshot from my actual setup, below indicator is DMI. What I am trying to achieve is that trades triggered from the strategy should be avoided if +DMI is not equal or bigger than 45. As you can see on below example +DMI is actual at 34,05






I tried to change the code the following way(shown in red), but still trades gets triggered which are below 45 (+DMI).







Would be great if somebody could tell me what actually I am doing wrong here.....


Thanks a lot guys

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ISO Equity Curve Indicator
NinjaTrader
Request for MACD with option to use different MAs for fa …
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Trader Dale [email protected] or Scammer Dale
Trading Reviews and Vendors
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Tao te Trade: way of the WLD
36 thanks
Deaddogs Stock Trading
27 thanks
GFIs1 1 DAX trade per day journal
25 thanks
Supertradersams Thread Journal on NQ/MNQ
24 thanks
Just another trading journal: PA, Wyckoff & Trends
12 thanks

(login for full post details)
  #3 (permalink)
 RM99 
Austin, TX
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 839 since Mar 2011
Thanks Given: 124
Thanks Received: 704


Couple of possibilities....

1) I can't see if you're using IOG or not, but if so, then intrabar, the value for your variable may indeed be above a certain threshold, but then settle to a lower point later in the bar and appear to have been less when reviewing later on (which only reveals the variable's final closing value, not the entire range of values it covered during the time period).

2) Prior to your if then begin string......you have a constraint (if currentshares = LTT then begin...)

What is the default value if your constraint is false?

I personally declare variables at the front of the program, I can't see the rest of your code to see if there's a reason you include it inside your if then string.

3) You need to label your entries and exits, if you have other entrie sources in your code, this will help identify which entry criteria is triggering the entry.

Reply With Quote
The following user says Thank You to RM99 for this post:
(login for full post details)
  #4 (permalink)
abcplot
vienna
 
Posts: 14 since May 2011
Thanks Given: 6
Thanks Received: 3

Hello,


First of all, thanks to your reply! In order to give you an overview what I am trying to accomplish, following information:

Im am trying to modify the original Turtle system, based on a 20/55 Donchian breakout to perform as below:
  • Use only 90 days as a breakout signal in each direction (long/short)
  • Additional DMIplus (long) or DMIminus (short) needs to be equal or higher than 45 (at first entry and afterwards for each pyramiding entry), if this condition is not given, skip those trades
  • Used Data is EOD only, no intraday action, if bar is the highest whitin 90 days, then enter at tomorrows open
Below a screenshot as it looks right now. The yellow and red dotted lines are from a additional indicator in order to check the entries/exits calculated by the strategy, this one has no influence on the strategy, just in use for verfication

inputs:
Breakoutlength: 90 --> yellow dotted line
Stoplength: 10 --> red dotted line (ATR exit)
N: 2 --> 2 times the true range
ATRlenght: 20







Below is the current status of the performed modifications of the original 20/55 Turtle system:


Hoping you can take a look at it in order to let me know what actually needs to be changed to achieve above defined requirements.




 
Code
vars: N(0),StopLoss(1),DV(0),BB(0),AccountBalance(0),DollarRisk
(0),LTT(0), 
Tracker(0),LastTrade(0),HBP(0),LBP(0); input: InitialBalance
(50000),Length(20); 
if marketposition = 0 then begin 
BB = 0; 
N = xAverage( TrueRange, Length ); 
DV = N * 100; {Bigpointvalue set to 100}
AccountBalance = InitialBalance; 
DollarRisk = AccountBalance * .03; {3 Percent/ Trade}
LTT = IntPortion(DollarRisk/DV); 
StopLoss = 2 * DV * LTT; 
if LastTrade = -1 then begin
buy LTT shares next bar highest(h,90) or higher; 
buy LTT shares next bar highest(h,90) + (0.5*N) or higher; 
buy LTT shares next bar highest(h,90) + (1.0*N) or higher; 
buy LTT shares next bar highest(h,90) + (1.5*N) or higher; 
sellshort LTT shares next bar lowest(l,90) or lower; 
sellshort LTT shares next bar lowest(l,90) - (0.5*N) or lower; 
sellshort LTT shares next bar lowest(l,90) - (1.0*N) or lower; 
sellshort LTT shares next bar lowest(l,90) - (1.5*N) or lower; 
end; 
if LastTrade = 1 then begin 
buy LTT shares next bar highest(h,90) or higher; 
buy LTT shares next bar highest(h,90) + (0.5*N) or higher; 
buy LTT shares next bar highest(h,90) + (1.0*N) or higher; 
buy LTT shares next bar highest(h,90) + (1.5*N) or higher; 
sellshort LTT shares next bar lowest(l,90) or lower; 
sellshort LTT shares next bar lowest(l,90) - (0.5*N) or lower; 
sellshort LTT shares next bar lowest(l,90) - (1.0*N) or lower; 
sellshort LTT shares next bar lowest(l,90) - (1.5*N) or lower; 
end; 
end; 
// PREVIOUS TRADE TRACKER 
if HBP = 0 and h > highest(h,89)[1] then begin 
Tracker = 1; HBP = h; LBP = 0; 
end; 
if LBP = 0 and l < lowest(l,89)[1] then begin 
Tracker = -1; LBP = l; HBP = 0; 
end; 
if Tracker = 1 then begin 
if l < HBP - (2*N) then LastTrade = -1; 
if h > HBP + (4*N) then LastTrade = 1; 
end; 
if Tracker = -1 then begin 
if h > LBP + (2*N) then LastTrade = -1; 
if l < LBP - (4*N) then LastTrade = 1; 
end; 
 
// LONG 90 
if LastTrade = 1 and marketposition = 1 then begin 
BB = BB + 1; 
if currentshares = LTT then begin
 
 Value99=DMIPlus(14);
 if value99>=45 then;
 
buy LTT shares next bar highest(h,90)[BB] + (0.5*N) or higher;
buy LTT shares next bar highest(h,90)[BB] + (1.0*N) or higher;
buy LTT shares next bar highest(h,90)[BB]+ (1.5*N) or higher; 
end; 
if currentshares = LTT * 2 then begin 
buy LTT shares next bar highest(h,90)[BB] + (1.0*N) or higher; 
buy LTT shares next bar highest(h,90)[BB] + (1.5*N) or higher; 
end; 
if currentshares = LTT * 3 then 
buy LTT shares next bar highest(h,90)[BB] + (1.5*N) or higher; 
end; 
sell ("out-S") next bar lowest(l,10) or lower; 
 
// SHORT 90
if LastTrade = 1 and marketposition = -1 then begin 
BB = BB + 1; 
if currentshares = LTT then begin
 
 Value79=DMIminus(14);
 if value79>=45 then;
 
sellshort LTT shares next bar lowest(l,90)[BB] - (0.5*N) or lower; 
sellshort LTT shares next bar lowest(l,90)[BB] - (1.0*N) or lower; 
sellshort LTT shares next bar lowest(l,90)[BB] - (1.5*N) or lower; 
end; 
if currentshares = LTT * 2 then begin 
sellshort LTT shares next bar lowest(l,90)[BB] - (1.0*N) or lower; 
sellshort LTT shares next bar lowest(l,90)[BB] - (1.5*N) or lower; 
end; 
if currentshares = LTT * 3 then 
sellshort LTT shares next bar lowest(l,90)[BB] - (1.5*N) or lower; 
end; 
buytocover ("out-B") next bar highest(h,10) or higher; 
// STOPS 
if currentshares = (2 * LTT) then StopLoss = DV * 3.5 * LTT; 
if currentshares = (3 * LTT) then StopLoss = DV * 4.5 * LTT; 
if currentshares = (4 * LTT) then StopLoss = DV * 5.0 * LTT; 
setstoploss (StopLoss); 
// COMMENTARY 
commentary ("LTT: ",LTT,Newline); 
commentary ("CurrentShares: ",CurrentShares,Newline); 
commentary ("StopLoss: ",StopLoss,Newline); 
commentary ("AccountBalance:",AccountBalance,NewLine); 
commentary ("LastTrade: ",LastTrade,NewLine);

Reply With Quote
(login for full post details)
  #5 (permalink)
 SPTrading 
London, England
 
Experience: Intermediate
Platform: MC, TS, NT
Broker: TradeStation
Trading: ES
Posts: 41 since Oct 2009
Thanks Given: 12
Thanks Received: 21

The if statements apply only to the next line unless there is a "begin...end", so it seems you need to review the strategy carefully to ensure the logic is correct. For example regarding you DMI value it look slike it should say:

if value99>=45 then
-----begin
-----------buy LTT shares next bar highest(h,90)[BB] + (0.5*N) or higher;
-----------buy LTT shares next bar highest(h,90)[BB] + (1.0*N) or higher;
-----------buy LTT shares next bar highest(h,90)[BB]+ (1.5*N) or higher;
-----end;

The best way to 'see' the structure would be to properly indent all begin end blocks, for example:

if A = B then
--------begin
--------------if C=D then
----------------------begin
--------------------------------statement1;
--------------------------------statement2;
----------------------end;
--------end;

Another comment is that the SetStopLoss whould never be within an If statement. This may result in there being no stoploss, not because of the strategy logic but just an "anomally" with easylanguage.

Paul

Reply With Quote
(login for full post details)
  #6 (permalink)
 RM99 
Austin, TX
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 839 since Mar 2011
Thanks Given: 124
Thanks Received: 704

Agreed.

Coding is a skill and so is debugging.

Part of debugging is coding with a certain organization. That's why it helps to ensure that you follow the textbook grouping and sequence of coding.

TS has templates that will help you stay organized. Generally you start with inputs, then variables, then you declare your variables, then you work the body of your program, entries, then money management and exits.

Something as simple as placing variable declaration in the wrong location can screw things up.

Reply With Quote





Last Updated on May 19, 2011


© 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