NexusFi: Find Your Edge


Home Menu

 





Strategy help: Trying to have entry, set stop loss, and set target on the next bar


Discussion in EasyLanguage Programming

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




 
Search this Thread

Strategy help: Trying to have entry, set stop loss, and set target on the next bar

  #1 (permalink)
 turboscottomatic 
nyc
 
Experience: Intermediate
Platform: NT, MC
Posts: 4 since Dec 2009
Thanks Given: 0
Thanks Received: 0

Hi all,

I have some moderate Easy Language indicator programming ability. Most of the strategy entry/exit/position stuff is new to me. I hope you can help me. FYI, I have and use both MultiCharts and TS. I am trying to phase out of TS into MC, so that's where I am trying to execute this.

I am trying to code a strategy that sets a limit entry (on some Entry Condition) AND a fixed stop loss AND a fixed target on the next bar. I am trying to code a 'set and forget' kind of thing for EOD daily trading. I want all 3 (limit entry, stop, target) to all fire on the SAME BAR and to execute at specific prices. And I want the stop and target to persist as long as my entry is active (marketposition = 1 or -1).

The easy way to visualize this is like what happens during strategy trading on Ninja: as soon as your order is hit a stop and target are sent immediately. And they stick around until one of them is hit.

In general, I am using something like a Keltner Channel and, for a LONG trade, my setup condition resembles: if the channel is headed up and the bar closes above the midline , I want to set a limit order at the midline (below price), and a target at the upper channel, and a stoploss at the lower channel, to trigger at the NEXT bar, all three.

The idea is not revolutionary, a quick pullback in an uptrend triggers a limit order and sets a stop below and a target above. Reverse for shorts. BTW, there is a PDF all over the WWW describing this method as a Linda Bradford Raschke setup in an issue of Chartpoint. You can find it by googling "Kevin Ho Scalp Trading Methods." It is Pattern 5: The 5-Minute Standard Deviation Scalp in the PDF. I am trying to turn that into a end of day backtestable strategy.

I got some ideas from this thread, but I'm not succeeding:


Here is what is currently NOT working:

 
Code
//Entry conditions
LongEntCond = Avg> Avg[1] and close > Avg;
ShortEntCond = Avg< Avg[1] and close < Avg;

//LONG Entry, Stop, and Target
if MarketPosition = 0 and (LongEntCond) then begin
    Buy ("Entry LONG") next bar at Avg limit;
    SetStopLoss( Avg - LowerBand );
    SetProfitTarget( UpperBand - Avg );
end;

 //SHORT Entry, Stop, and Target
 if MarketPosition = 0 and (ShortEntCond) then begin
    SellShort ("Entry SHORT") next bar at Avg limit;
    SetStopLoss ( UpperBand - Avg );
    SetProfitTarget ( Avg - LowerBand );
end;
I also tried using code which enters next bar and is followed by stop and target next bar after that (next after next, if you get me ):

 
Code
//Long entry routines
if marketposition = 0 then begin
	if LongEntCond then 
	buy ("L-Ent") next bar at Avg limit;
end;

//Long exit routines
if marketposition = 1 then begin
	sell ("L-tgt") next bar at UpperBand stop;
	sell ("L-stp") next bar at LowerBand limit;
end;
This seemed to sort of work, but didn't in two ways: 1. The stop and target execution were at bar close instead of at specific prices, and 2. The entry bar did not have the stop and target attached until the following bar, meaning that trades entered and exited on the same bar were not shown. In a fast 1:1 RR 1xATR method like this, it happens often enough to matter. A single bar dipping down followed by a one ATR upthrust in an uptrend happens all the time

I don't know enough about Bar Magnifier to know if it is useful here. I don't think I can use intrabarordergeneration because I am using daily bars and would like to test this against years of data. I don't have years of minute data available to match it.

I am sure others beside myself would benefit from this. Daytrading wears me out. I would love to test and have faith in a good ole' EOD method that I set at 5 pm and walk away from. But have faith in it from solid testing and statistics. I hope to recreate reality in backtesting as faithfully as possible, including same day entries and exits.

I don't post here much but I read a lot and learn a lot. Thanks to all!

Scott

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
22 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 turboscottomatic 
nyc
 
Experience: Intermediate
Platform: NT, MC
Posts: 4 since Dec 2009
Thanks Given: 0
Thanks Received: 0


Never mind. Got it.

Setstoploss and setprofittarget cannot be inside a conditional statement. So this works fine:

 
Code
//Entry conditions
LongEntCond = Avg> Avg[1] and close > Avg;
ShortEntCond = Avg< Avg[1] and close < Avg;

//LONG Entry, Stop, and Target
if MarketPosition = 0 and (LongEntCond) then begin
    Buy ("Entry LONG") next bar at Avg limit;
end;

 //SHORT Entry, Stop, and Target
 if MarketPosition = 0 and (ShortEntCond) then begin
    SellShort ("Entry SHORT") next bar at Avg limit;
end;

SetStopLoss( UpperBand - Avg );
SetProfitTarget( UpperBand - Avg );

Started this thread Reply With Quote




Last Updated on January 22, 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