I'm testing a Breakout system on 30 min. bars and trying to incorporate a Trailing $Stop. My problem is when the Stop is elected the program immediately reinitiates the trade at the Stop price or Open. Am I missing or not understanding something?? Allen Input: Sig(2), RangeBegin(0830), DayClose(1630), TR(500); Vars: Hi(0), Lo(99999), LS(0), SS(0); If time = RangeBegin then begin Hi = 0; Lo = 99999; end; If time = RangeBegin then begin Hi = High; Lo = Low; LS = Hi + Sig; SS = Lo - Sig; end; If time >= RangeBegin and time < DayClose then begin Buy at LS point Stop; Sell at SS point Stop; SetStopPosition; SetDollarTrailing(TR); end; If Time = DayClose and Marketposition <> 0 then begin ExitLong this bar on Close; ExitShort this bar on Close; end;
If someone could code this: Buy at highest high of last 6 bars. Sell at lowest low of last 6 bars. Exit long at lowest low of last 4 bars. Exit short at highest high of last 4 bars. I'd really appreciate it. thank you, alex
AllenW.. it looks like you probably need to use a Flag(s). maybe add: flag(0); to variable declarations at the beginning. then initiate it in the code: flag=0; then on the buy condition check that flag<1 and if it is, then set flag=1; then buy order. then on the short condition check that flag>-1 and if it is, then set flag=-1; then sell order. ---------- or something similar may work.
Here is your system. You can test on EOD data on one symbol or you can also test it on a portfolio on the same web site. To test it on ID data you would need the desktop software. http://www.wealth-lab.com/cgi-bin/WealthLab.DLL/editsystem?id=24550 Just key in a symbol. Created with drag and drop.
Thank you for the Flag suggestion--I'll try it this afternoon. Sorry if my coding doesn't flow-------just getting my feet wet with this programming stuff. and yes, I have already tried the EntriesToday function and it didn't correct the problem. Allen
Input: Entrybars(6), Exitbars(4); var: LE(0), LX(0), SE(0), SX(0); le = highest(high, entrybars); se = lowest(low, entrybars); lx = lowest(low, exitbars); sx = highest(high, exitbars); buy next bar at le stop; sell short next bar at se stop; sell next bar at lx stop; buy to cover next bar at sx stop; DS