Scripting Entry and Exit Rules

hello - I have developed a trading plan and need to back test various entry and exit rules. For Example, Entry on Dow Theory one cent above the break of the previous peak and exit on an Gann Swing once more one cent below the previous trough. How do I begin to script these rules? Any help would be appreciated.

I can try and help; first, I thought to identify the condition, Dow Theory Scan ‘is true’. To do this, I first copied the Dow Theory Scan script, then I reformulated it so that I could yield a true or false result. That looked like this:

GS1 = GANNSWING(USEINSIDE=False);
c1 = SWINGEND(GS1) > SWINGSTART(GS1, OFFSET=1);
c2 = SWINGEND(GS1,OFFSET=2) > SWINGSTART(GS1,OFFSET=3);
c3 = SWINGSTART(GS1) >= SWINGSTART(GS1,OFFSET=2);
c4 = c1 and c2 and c3;

to find the relevant high, I used the HIGHESTHIGH() function, with a lookback period of 6
v1 = HIGHESTHIGH(BARS=6);

I then defined the condition of the close crossing above the highest high–v1
c5 = CLOSE() CrossesAbove v1;

then, to assert both that the Dow Theory Scan is true and the break above the highest high, this is the final statement:
c4 and c5

That gave me the following results when applied to the Show Bar tool: (see attached image)

Hello - thank you for responding.
I tried that formula but got no results on back testing.
I did however get result on the standard inbuilt function for Dow Theory Scan - Long, however the buy is at the next open. It worked very well overall.
I tested both scenarios on Apple for a 5 year period.

Code entered below in the Entry Criteria

GS1 = GANNSWING(USEINSIDE=FALSE);
c1 = SWINGEND(GS1) > SWINGSTART(GS1, OFFSET=1);
c2 = SWINGEND(GS1,OFFSET=2) > SWINGSTART(GS1, OFFSET=3);
c3 = SWINGSTART(GS1) >= SWINGSTART(GS1, OFFSET=2);
c4 = c1 and c2 and c3;

v1 = HIGHESTHIGH(BARS=6);

c5 = CLOSE() CrossesAbove v1;
v4 and c5

No results.