Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I got a TS RC Beginner strategy and want to do the back test in MC but it just won't compile in MC.
Do I need to make some code conversion?
If yes where can I find like conversion table?
The TS code are as follows, thanks
Inputs:
PriceES(Close of Data1),
PriceNDQ(Close of Data2);
Vars: StopLoss(12), Stop_Width(0), Stop_Price(0);
Vars: StartTimeMins(0), EndTimeMins(0), LastTradeMins(0), Tmins(0);
if CurrentBar=1 then
begin
StartTimeMins = TimeToMinutes(Sess1StartTime)+40; //09:10
LastTradeMins = TimeToMinutes(Sess1EndTime)-25; //14:50
EndTimeMins = TimeToMinutes(Sess1EndTime)-15; //15:00
end;
Tmins = TimeToMinutes (Time);
Vars: ESYDC(0), NDQYDC(0), Started(FALSE);
Vars: ESLevel(0), NDQLevel(0);
if Date<>Date[1] then
begin
ESYDC = PriceES[1];
NDQYDC = PriceNDQ[1];
Started = TRUE;
end;
if Started then
begin
ESLevel = Close-ESYDC;
NDQLevel = PriceNDQ-NDQYDC;
end;
Vars: Priority(false), NDQ(0), NoTrade(false);
Vars: Trade1(false), Trade3(false), Trade4(false), Trade5(false);
Vars: Trade6(false), Trade8(false), Trade9(false), Trade10(false);
if Date<>Date[1] then
begin
Priority = false;
NoTrade = false;
Trade1 = false;
Trade3 = false;
Trade4 = false;
Trade5 = false;
Trade6 = false;
Trade8 = false;
Trade9 = false;
Trade10 = false;
end;
if Tmins = StartTimeMins then
begin
{condition 1}
if ESLevel >= 0 and ESLevel < 10 and NDQLevel >= 0 and NDQLevel
< 10 and NDQLevel >= ESLevel then Trade1 = true
{condition 2}
else if ESLevel >= 0 and ESLevel < 10 and NDQLevel >= 0 and
NDQLevel < 10 and ESLevel > NDQLevel then NoTrade = true
{condition 3}
else if ESLevel < 0 and ESLevel > -10 and NDQLevel < 0 and
NDQLevel > -10 and NDQLevel <= ESLevel then Trade3 = true
{condition 4}
else if ESLevel < 0 and ESLevel > -10 and NDQLevel < 0 and
NDQLevel > -10 and ESLevel < NDQLevel then
begin
Sell Short(“Short 4”)this bar on close;
Priority = true;
Stop_Width = StopLoss;
end
{condition 5}
else if ESLevel >= 0 and ESLevel < 10 and NDQLevel < 0 and
NDQLevel > -10 then Trade5 = true
{condition 6}
else if ESLevel < 0 and ESLevel > -10 and NDQLevel >= 0 and
NDQLevel < 10 then Trade6 = true
{condition 7}
else if ESLevel < 0 and ESLevel > -10 and NDQLevel <= -10 then
NoTrade = true
{condition 8}
else if ESLevel >= 0 and ESLevel < 10 and NDQLevel >= 10 then
begin
NDQ = NDQLevel;
Trade8 = true;
End
{condition 9}
else if ESLevel <= -10 and NDQLevel <= -10 then
begin
NDQ = NDQLevel;
Trade9 = true;
End
{condition 10}
else if ESLevel >= 10 and NDQLevel >= 10 then
begin
NDQ = NDQLevel;
Trade10 = true;
end;
end;
if Tmins >= StartTimeMins and Tmins <= LastTradeMins and
Priority = false then
begin
{condition 1}
if NDQLevel <= -13 and Trade1 then
begin
Sell Short(“Short 1”)this bar on close;
Trade1 = false;
Priority = true;
Stop_Width = StopLoss;
end;
{condition 2 = No Trade}
{condition 3}
if NDQLevel <= -13 and Trade3 then
begin
Sell Short(“Short 3”)this bar on close;
Trade3 = false;
Priority = true;
Stop_Width = StopLoss;
end;
{condition 5}
if ESLevel >= 2 and NDQLevel >= 13 and Trade5 then
begin
Buy(“Long 5”)this bar on close;
Trade5 = false;
Priority = true;
Stop_Width = StopLoss;
end;
{condition 6}
if ESLevel <= -2 and NDQLevel <= -13 and Trade6 then
begin
Sell Short(“Short 6”)this bar on close;
Trade6 = false;
Priority = true;
Stop_Width = StopLoss;
end;
{condition 7 = No Trade}
{condition 8}
if NDQLevel-NDQ >= 10 and Trade8 then
begin
Buy(“Long 8”)this bar on close;
Trade8 = false;
Priority = true;
Stop_Width = StopLoss;
end;
{condition 9}
if NDQ-NDQLevel >= 10 and Trade9 then
begin
Sell Short(“Short 9”)this bar on close;
Trade9 = false;
Priority = true;
Stop_Width = StopLoss;
end;
{condition 10}
if NDQLevel-NDQ >= 10 and Trade10 then
begin
Buy(“Long 10”)this bar on close;
Trade10 = false;
Priority = true;
Stop_Width = StopLoss;
end;
end;
if MarketPosition = 1 then
begin
Stop_Price = EntryPrice - Stop_Width;
Sell (“L-Exit”) next bar Stop_Price Stop;
end;
if MarketPosition = -1 then
begin
Stop_Price = EntryPrice + Stop_Width; buy to cover (“S-Exit”) next bar Stop_Price
Stop;
end;
if Tmins >= EndTimeMins then
begin
Sell(“Long Close”) this bar on close;
Buy to Cover(“Short Close”) this bar on close;
end;
Can you help answer these questions from other members on NexusFi?
SPtarder, you file work, I can compile it now, thanks.
Bimi, what do you mean by 'learn to use code tag'?
When I compile the file an error message shown:
------ Compiled with error(s): ------
incorrect input type
errLine 2, errColumn 8, errLineEnd 2, errColumnEnd 22
causal study: (Function)
and it seems point to the first sentence "PriceES(Close of Data1)," so I tried to change it but to no avail.
Sorry I'm a newbie at the very beginning to try to use it (without programing background). Thanks both of you.