Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 01-22-2011, 02:05 PM   #17

Join Date: Feb 2008
Location: charleston
Posts: 63
Ignore this user

Thanks: 7
Thanked 21 Times in 16 Posts

Re: Reset EL SetBreakeven

I have a preference for booleans, just how my mind works, but doesn't have to be
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;
statsign is offline  
Reply With Quote
The Following User Says Thank You to statsign For This Useful Post:
deadloss (01-22-2011)
Old 01-22-2011, 03:38 PM   #18

Join Date: Jan 2011
Posts: 8
Ignore this user

Thanks: 3
Thanked 0 Times in 0 Posts

Re: Reset EL SetBreakeven

Hi statsign,
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;

{-------------------------------------------------------------------------------------------------------------------}
deadloss is offline  
Reply With Quote
Old 01-22-2011, 05:58 PM   #19

Join Date: Jan 2011
Posts: 8
Ignore this user

Thanks: 3
Thanked 0 Times in 0 Posts

Re: Reset EL SetBreakeven

Thanks statsign, my posts don't seem to be getting through at present but I have been trying your approach with unpredictable results so far. I dare say I will stumble upon a solution eventually.
deadloss
deadloss is offline  
Reply With Quote
Old 01-26-2011, 05:06 AM   #20

Join Date: Jan 2011
Posts: 8
Ignore this user

Thanks: 3
Thanked 0 Times in 0 Posts

Re: Reset EL SetBreakeven

Post Script...................
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
deadloss is offline  
Reply With Quote

Reply

Tags
breakeven, easylanguage, stoploss, strategy engine

Thread Tools
Display Modes Help Others By Rating This Thread
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

All times are GMT -4. The time now is 03:21 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.