| Coding Forum Collaborate, receive help, or discuss coding related issues. |
![]() | | Tweet | |
| | #17 | ||
![]() | Re: Reset EL SetBreakeven long example Code: input: targetv(2);
if marketposition = 1 then begin
mytarget = entryprice + targetv;
if C = (entryprice + targetv * .5) then mybreakeven = 1;
if C = mytarget then sell next bar market;
if mybreakeven = 1 and C = entryprice then sell next bar market;
end;
if marketposition = 0 then mybreakeven = 0; | ||
| |
|
| The Following User Says Thank You to statsign For This Useful Post: | ||
deadloss (01-22-2011) | ||
| | #18 | ||
![]() | Re: Reset EL SetBreakeven I posted this earlyer but it seems to have been withheld for asides regarding square pegs. Anyway I am placing trades manually so the code is for back testing and optimisation so your code is very usefull as an illustration for future use but think I am on the right track now as preliminary testing is looking good, though I may have to add a Bigpointvalue or something to stop it selling slightly below breakeven but it is basicly doing what it should with the added bonus that the exit is now tied to the entry. The leap of understanding was in making the single rise in price above my trigger value activate an exit command that acts all subsiqent bars untill one of them breaches the breakeven price. I had not previosly reolised that this was possible. {xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx ProfitSaverLX xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xx} Inputs:ProfitSaver(.5), Costs(1);{ProfitSaver: 0.50 = 50% Percent of Tgt-1 to lower stop to breakeven. Costs: Amount to cover charges/slippage} {Inputs:Tgt1(2.5);Remove when intergrated} Variables:PS_LTrigger(Fal se); Condition14 = High > ( EntryPrice(0) * (1 + ( ProfitSaver * Tgt1 * 0.01)));{Current High is above trigger level for stop loss} If MarketPosition > 0 and Condition14 = True Then PS_LTrigger = True Else If MarketPosition <= 0 Then PS_LTrigger = False; If PS_LTrigger = True Then ExitLong("T1+2 PSXT") all contracts from Entry("Tgt1+2 EB") at (EntryPrice + Costs) or Lower; {-------------------------------------------------------------------------------------------------------------------} | ||
| |
|
| | #19 | ||
![]() | Re: Reset EL SetBreakeven deadloss | ||
| |
|
| | #20 | ||
![]() | Re: Reset EL SetBreakeven I suddenly realised that in concentrating on this small area of code I was missing the big picture. The real problem is in the structure of the system, a full re-write will not be needed thank god, just a bit of structural rearrangement and then the addition of breakeven exit..................... . should be easy enough? Thanks for being a wall to bounce off, the end. deadloss | ||
| |
|
![]() |
| Tags |
| breakeven, easylanguage, stoploss, strategy engine |
| Thread Tools | |
| Display Modes | Help Others By Rating This Thread |
| |
| ∧ Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reset or Clear Each New Bar | PeterBrazel | Coding Forum | 10 | 10-28-2009 11:19 AM |