NexusFi: Find Your Edge


Home Menu

 





Turtle TS-code help needed from programmers


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,672 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

Turtle TS-code help needed from programmers

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

Hello,


I am relatively new to Tradestation and would need some help from expierenced TS programmers in understanding below attached Turtle strategy.

I am hoping that there are some members which can help me to fully understand below code.

Below is the first part of mentioned Turtle strategy attached, including my comments as I think the instrcutions will be executed, on some statements I simply have no clue what they are really doing, hopefully some members can explain them in detail.

Currently I donīt think it makes sense to post the entire strategy, so I will go ahead and post below the first part


In BLUE are my comments, as I said, would be great if somebody can tell me if my analysis of below code is correct and on sections where I simply donīt know whats going on if possible please provide some further assistance.

Thanks a lot to everbody!


Below are the first 30% of given TS code:




[LegacyColorValue = true];
{ Turtle mode #2 Ver.0.1.0 03.02.2005}

Input: DistH(4),DistL(4),Account(10000),MaxPercRisk(1),MaxOpenEntry(4);

Var:TradeAccount(-1),PosSize(0),TrailBars(10),CurrentPosition(0),cCurrentEntries(0),
cAvgEntryPrice(0),cEntryPrice(0),cCurrentContracts(0);

Var:BuyStop(-1),BuyLimit(-1),LExitStop(-1),SellStop(-1),SellLimit(-1),SExitStop(-1);

Var:NextHigh(-1),NextLow(-1),BarUntil(-1);

Var:BreakType(0),BreakStop(-1),BreakBars(0),BreakIsLoss(false),Break20Found(false),Break20SkipCnt(0);


if Barnumber=1 then begin {Start with 1 bar on chart}
VALUE29=-1; {Numeric value set to -1, for later usage, currently donīt know the meaning of -1}
VALUE38=-1; {Numeric value set to -1, for later usage, currently donīt know the meaning of -1}
end;

cCurrentEntries=CurrentEntries;
{"CurrentEntries" -->numbers of entries currentlyopen, assigned to"cCurrentEntires"}



cAvgEntryPrice=AvgEntryPrice;
{AvgEntryPrice --> Average price of all currently open entries --> assigned to "cAvgEntryPrice"}

cCurrentContracts=CurrentContracts;
{CurrentContracts --> Number of contracts currently open --> assigned to "cCurrentContracts"}


if (cCurrentEntries>cCurrentEntries[1]) then begin
{(cCurrentEntries>cCurrentEntries[1]) --> if "cCurrentEntries" is bigger that the one from yesterday, but so far there are no trades made, value for both is still 0, condition not met, jump to next "if" --> if (cCurrentEntries=0 and cCurrentEntries[1]<>0) then begin}


cEntryPrice=(CurrentContracts*AvgEntryPrice-cCurrentContracts[1]*cAvgEntryPrice[1]) / (CurrentContracts-cCurrentContracts[1]);
{Calculation for var "cEntryprice" --> (Number of currently held contracts * average price of all currently open entries) - ( values from yesterday) / (currently held contract - the ones from yesterday)}

--> same thing: currently no trades in progress, all vars still set to 0
--> What does "cEntryPrice" basically say? actually donīt understand the meaning of this calculation.



if MarketPosition=1 then begin
{ if long than continue --> condition not met, no trades in progress}

LExitStop=TicksRound(cEntryPrice-2*XAverage(TrueRange,20));
{ I guess thatīs the "2N" initial stop calculation according to Turtle rules}

NextHigh=cEntryPrice+0.5*XAverage(TrueRange,20);
{no idea...., whats the meaning of this "NextHigh"?}

NextHigh=TicksRound(NextHigh+TicksMTS(NextHigh));
{no idea...., whats the meaning of this "NextHigh"?}

BuyStop=-1;
{predefined vars, as above. Whatīs the reason to have them all on -1?)

BuyLimit=-1;
{predefined vars, as above)

BarUntil=-1;
{predefined vars, as above)

VALUE29=-1;
{predefined vars, as above)
end


else begin
SExitStop=TicksRound(cEntryPrice+2*XAverage(TrueRange,20)); {same as above, just SExit)
NextLow=cEntryPrice-0.5*XAverage(TrueRange,20); {no idea...., whats the meaning of this?}
NextLow=TicksRound(NextLow-TicksMTS(NextLow)); {no idea...., whats the meaning of this?}
SellStop=-1;
{predefined vars, as above. Whatīs the reason to have them all on -1?)
SellLimit=-1; {predefined vars, as above)
BarUntil=-1; {predefined vars, as above)
VALUE38=-1; {predefined vars, as above)
end;

{ Date & Time line for multiple entries Buy / Sell }
value99=date; {predefined numeric values --> date}
value98=time; {predefined numeric value --> time}
end;


if (cCurrentEntries=0 and cCurrentEntries[1]<>0) then begin
{cCurrentEntries is 0, but cCurrentEnties from yesterday is equal to 0 --> condition not met to proceed, so far no trades made}
NextHigh=-1;
NextLow=-1;
LExitStop=-1;
SExitStop=-1;
BuyStop=-1;
BuyLimit=-1;
SellStop=-1;
SellLimit=-1;
BarUntil=-1;


if VALUE29>=0 then {so far value29 is still set to 0, cannot proceed}

TL_Delete(VALUE29); {delete trendline}

VALUE29=-1;
{in case value29 changed --> now re-setting "value29" to -1}
if VALUE38>=0 then {so far value38 is still set to 0, cannot proceed}
TL_Delete(VALUE38); {delete trendline}
VALUE38=-1; {in case value38 changed --> now re-setting "value38" to -1}
end;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Futures Close-Out Policy
Commodities
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Request for MACD with option to use different MAs for fa …
NinjaTrader
Looking for an MQL4 MetaTrader programmer/coder
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
33 thanks
Daytrading ES & NQ
32 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Retail Trading As An Industry
25 thanks
Battlestations: Show us your trading desks!
24 thanks






Last Updated on May 11, 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