{define global variables} var Position: integer; EntryPrice: real; ExitPrice: real; ExitStop: real; ScalpSize: real; StopSize: real; HH: real; LL: real; BuySignal: boolean; SellSignal: boolean; TrendUp: boolean; TrendDn: boolean; {define procedures and functions} procedure Initialize; var Commission: real; BuyArrow: integer; SellArrow: integer; OutArrow: integer; ShowBoxes: boolean; begin Commission:=10; {deduct $10 round trip for each trade} BuyArrow:=8; {show Up arrow and the word 'Long'} SellArrow:=13; {show Down arrow and the word 'Short'} OutArrow:=7; {show Right arrow and the word 'Out'} ShowBoxes:=true; {mark trade with a square box on the bar} ResetTrades(Commission,BuyArrow,SellArrow,OutArrow,ShowBoxes); Position:=0; {0 = out, -1 = short, 1 = long} ScalpSize:=250; {scalp objective, IQFeed users enter 1.00} StopSize:=250; {protective stop, IQFeed users enter 2.50} BuySignal:=false; {flag to indicate Buy setup} SellSignal:=false; {flag to indicate Sell setup} end; procedure TestExit(w: integer); var bExit: boolean; begin bExit:=false; if Position=1 then begin {currently long} if Low(w)<=ExitStop then begin {test for stopped out} if Open(w)ExitPrice then begin {test for scalp objective} if Open(w)>ExitPrice then ExitPrice:=Open(w); {check for gap across goal} bExit:=true; {set exit flag} end; end else if Position=-1 then begin {currently short} if High(w)>=ExitStop then begin {test for stopped out} if Open(w)>ExitStop then ExitPrice:=Open(w) {check for gap across stop} else ExitPrice:=ExitStop; bExit:=true; {set exit flag} end else if Low(w)HH then HH:=High(w); {find swing high} BuySignal:=(High(w)LL); {signal is 1st bar above swing low} end; end; end; procedure Calculate; var w: integer; study: integer; stop: integer; begin FindWindow(eChart); {locate the window with the chart} Remove(eAll); {clear off studies and markers} study:=AddStudy(ePar); {put on Parabolic stop for trend} for w:=1 to BarEnd do begin {calculate across all chart bars} stop:=GetStudy(study,3,w); {read the Parabolic position flag} if stop>0 then begin {determine trend} TrendUp:=(stop=1); TrendDn:=(stop=2); HH:=High(w); {start new swing high search} LL:=Low(w); {start new swing low search} end; TestExit(w); {did this bar trigger an exit} TestTrade(w); {did this bar trigger a trade} end; end; procedure Report; begin Trade(eOut); {close-out the last open trade} TradeReport(True); {print the results in the output window} end; {main program} begin Initialize; Calculate; Report; end;