[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Code Help!!



PureBytes Links

Trading Reference Links

Hi Ned / list

I find that the best/quikest way for me to debug any software is to print
the results step by step. The print function  prints to the debug window in
the 'powereditor' So something like the following , is what I find the
surest way to make sure everything is happening correctly. The new code is
below . If you cant find the error after that , i would suggest giving up
and coming back after a few days and you will find it straight away or go to
the beach(works for me)

Cheers
Cameron


Input: 	NumCont(1),
		SetupLength(6),
		PctRBull(75),
		PctRBear(25),
            print2debug (1);  {This is the new input so you can change it on
the fly , once debuging is over reset this to 0}

Vars: 	MP(0),
		EntryPr(0),
		StopPr(0),
		Lo(0),
		Hi(0),
		PctR(0),
		TriggerBar(0),
		Counter(0);

MP = MarketPosition;
PctR = PercentR(80);
Counter = 0;

{the next line is also added in this example to print the three variables
above}
if print2debug = 1 then print
(eldatetostring(date)+"Marketposition="+numtostr(mp,0)+"
Pctr="+numtostr(pctr,0)+" counter="+numtostr(counter,0));


{the next line is also added in this example to print the three variables 2
lines below inth the format of the if statement for ease of reading}
if print2debug = 1 then print
(eldatetostring(date)+"PctR[1]="+numtostr(PctR[1],0)+"
PctRBull="+numtostr(PctRBull,0)+" PctR="+numtostr(PctR,0)+"
PctRBull="+numtostr(PctRBull,0));

If PctR[1] < PctRBull 	and PctR > PctRBull Then begin
if print2debug = 1 then print (eldatetostring(date)+"PctR[1] < PctRBull 	and
PctR > PctRBull = true");

		TriggerBar = barnumber;
		Hi = High;
		Lo = Low;

		EntryPr = Hi + (.5*(Hi-Lo));
		StopPr = Lo - (.5*(Hi-Lo));
		{another debug line to print the variables above}
        if print2debug = 1 then print
(eldatetostring(date)+"Hi="+numtostr(Hi,0)+" Lo="+numtostr(Lo,0)+"
Triggerbar="+numtostr(barnumber,0)+" entrypr="+numtostr(entrypr,0)+"
stoppr="+numtostr(stoppr,0));

		{another debug line to print the variables below}
        if print2debug = 1 then print
(eldatetostring(date)+"pctr="+numtostr(pctr,0)+"
pctrbull="+numtostr(pctrbull,0)+" currentbar="+numtostr(currentbar,0)+"
triggerbar="+numtostr(triggerbar,0)+"
setuplength="+numtostr(setuplength,0));

		if pctr > pctrbull	and currentbar >= triggerbar and currentbar <=
triggerbar + setuplength then

		{another debug line to print the matching condition above}
		if print2debug = 1 then print (eldatetostring(date)+"buy time :O)
waycool");

		Buy ("L") (NumCont) Contracts EntryPr stop;
end;

If MP = 1 then ExitLong("LST") Numcont Contracts StopPr Stop;

-----Original Message-----
From: fxtrader [mailto:fxtrader@xxxxxxxxxx]
Sent: Thursday, January 01, 2004 7:36 PM
To: omega-list@xxxxxxxxxx
Subject: Code Help!!


Thanks for the continued suggestions from everyone.

I think the code to setup the entry and exits is correct now. The attached
gif shows the problem that I can't figure out. It will only go long on the
first bar after the entry / exit is established. The yellow arrow points to
where it should go long, but it won't. It has got to be something simple,
but I can't seem to find it.

Please take a look! Code is below.

Thanks
Ned

Input: 	NumCont(1),
		SetupLength(6),
		PctRBull(75),
		PctRBear(25);

Vars: 	MP(0),
		EntryPr(0),
		StopPr(0),
		Lo(0),
		Hi(0),
		PctR(0),
		TriggerBar(0),
		Counter(0);

MP = MarketPosition;
PctR = PercentR(80);
Counter = 0;

If PctR[1] < PctRBull
	and PctR > PctRBull Then begin

		TriggerBar = barnumber;
		Hi = High;
		Lo = Low;

		EntryPr = Hi + (.5*(Hi-Lo));
		StopPr = Lo - (.5*(Hi-Lo));

		if pctr > pctrbull
		and currentbar >= triggerbar
		and currentbar <= triggerbar + setuplength then
		Buy ("L") (NumCont) Contracts EntryPr stop;
end;

If MP = 1 then ExitLong("LST") Numcont Contracts StopPr Stop;


This communication may contain information that is proprietary, privileged,
confidential or legally exempt from disclosure. If you are not a named
addressee, you are notified that you are not authorized to read, print,
retain, copy or disseminate this communication without the consent of the
sender and that doing so may be unlawful. If you have received this
communication in error, please notify the sender via return e-mail and
delete it from your computer.


---
---