NexusFi: Find Your Edge


Home Menu

 





Custom breakeven/takeprofit/trailingstop


Discussion in MultiCharts

Updated
    1. trending_up 1,835 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

Custom breakeven/takeprofit/trailingstop

  #1 (permalink)
bondstrader
Dubai, UAE
 
Posts: 10 since Sep 2014
Thanks Given: 2
Thanks Received: 1

Is there anything wrong with the following code?
What Im trying to do is as follows.
1. Send a long order based on required conditions.
2. Set a breakeven stop if position moves up x number of pips.
3. Set a jump signal (sort of a big one time trailing stop) if position moves certain number of pips in profit.
4. Set a regular stop loss in case position goes into a loss.
5. Set a target profit.
Breakevenstop = 20 pips above entryprice
JumpLong = if price moves 40 pips above entryprice, and JumpLong Stop is set at 30 pips above entryprice at 1.1130
LSVal = 40 pips below entry
CloseLong = 100 pips above entry

So if i buy EUR/USD at 1.1100, and market moves to 1.1120, Breakeven stop is set at entryprice.(1.1100)
If market moves up to jump stop level at 1.1140, Jumplong stop is posted at 1.1130.
If market moves down 40 pips below, LSVal stop is triggered at 1.1060.
If market continues moving up, profit target is hit at 1.1200.

A few issues.
1. However, when I run a backtest on it, it triggers orders sporadically. At times it misses the jumpstop, and eventually goes on to hit the stoploss, even though the jump opportunity came first.
2. I want to use my own code instead of reserved functions (setstoploss, setbreakeven, etc), as I want to add more functionality to my stops. Seems like it this is that is causing the randomness of order triggers. What can i do/change to avoid that?

Apologies if any of this sounds confusing.

 
Code
if marketposition = 0 then begin

if condition1 and condition2 then Buy ("Open-L1") (Lots) contracts Next bar at BuyLimit Limit; //Buy order .

end;

if marketposition = 1 then begin

LBE = entryprice + (BreakevenVal * TickSize);
JumpLong = entryprice + (Jumpstep * TickSize);

if condition3 then begin
	Sell ("Stop-L1") currentcontracts Contracts next bar at LSVal Stop; //Long Stop
end;
if CurrentBid >= LBE then begin
	Sell ("BE-L1") CurrentContracts Contracts Next bar at Entryprice Stop; //BE Long
end;
if CurrentBid - Entryprice >= (JumpStart * TickSize) then begin
	Sell ("Jump-L1") Currentcontracts contracts next bar at JumpLong Stop;//Jump Long
end;
if condition4 then begin
	Sell ("Close-L1") currentcontracts Contracts next bar at CloseLong Limit;  //Long Target
end;
end;

end;

Reply With Quote




Last Updated on June 29, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts