NexusFi: Find Your Edge


Home Menu

 





Help! Struggling with a Keltner channel signal


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #1 (permalink)
 Zen Trader 
Asia
 
Experience: Beginner
Platform: InvestorRT, Ninjatrader
Broker: Zen-Fire
Trading: Bongos
Posts: 22 since Jan 2010
Thanks Given: 37
Thanks Received: 25

Hi, I''m new to Easy Language and need help to understand the following pre-built Keltner channel Buy signal in Multicharts, which unhelpfully has no notes to explain what's going on! So from what I can tell it looks for a channel breakout (price crosses above the upper band) and then sets a buy stop order on the next bar at high + 1 tick. But...

 
Code
[IntrabarOrderGeneration = false]
inputs:  Price( Close ), Length( 20 ), NumATRs( 1.5 ) ;
variables:  var0( 0 ), var1( 0 ), var2( 0 ), var3( false ), var4( 0 ) ;

var0 = AverageFC( Price, Length ) ;
var1 = NumATRs * AvgTrueRange( Length ) ;
var2 = var0 + var1 ;

condition1 = CurrentBar > 1 and Price crosses over var2 ;
if condition1 then                                                                    
begin
	var3 = true ;
	var4 = High ;
end 
else
begin
condition1 = var3 and ( Price < var0 or High >= var4 + 1 point ) ;
 if condition1 then
	var3 = false ;
end;	         	                  

if var3 then 
	Buy ( "KltChLE" ) next bar at var4 + 1 point stop ;

...what I don't understand is:

1) why the code doesn't simply use condition1 to initiate the Buy order i.e.

 
Code
condition1 = CurrentBar > 1 and Price crosses over var2 ;
if condition1 then 
	Buy ( "KltChLE" ) next bar at var4 + 1 point stop ;

2) what's going on in the "else" portion of the if else statement? It seems to be saying, if var3 is true, and either price is below the mid line (var0) or there is a new high, then var3 is false... very confused and I'm not sure why it is necessary.

3) why is "condition1" used twice to define different conditions. In terms of best practice should they not be condition1 and condition2?

4) why var4 is defined within condition1, not outside of it? Does it make any difference?

Really quite confused by this code and appreciate any help


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
Roland Garros Final Day: $3M on Zverev at 80.5% -- Leban …
Prediction Markets & Event Contracts
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
Warsh Rate Hike at 40%, Iran June 15 Expires Tonight at …
Prediction Markets & Event Contracts
June 15 Peace Odds Surge From 3.6% to 12.25% After Trump …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #3 (permalink)
 bchip 
Torino, Italy
 
Experience: Advanced
Platform: TradeStation
Trading: ES,YM,CL,GC
Posts: 132 since Sep 2017
Thanks Given: 160
Thanks Received: 117



Zen Trader View Post
Hi, I''m new to Easy Language and need help to understand the following pre-built Keltner channel Buy signal in Multicharts, which unhelpfully has no notes to explain what's going on! So from what I can tell it looks for a channel breakout (price crosses above the upper band) and then sets a buy stop order on the next bar at high + 1 tick. But...

I think the key to understanding this bit of code is that it saves certain values
at a point in time. I.e. it saves what the High is when the condition was last met
and then uses that later on.

Pseudo code would be

Get SMA + ATR (Keltner Top)

if price crosses over the Keltner then save condition true (var3) & save this high value (var4)
else
recheck everything ->
-> if in the past var3 was set to true, but now Close < SMA or High > than prev high when condition was met
then set var3 to false again

if var3 = true then buy at High + 1 point

//--------
I think theres some logic missing in the else part that's not right but I suspect what the person
was trying to do was something like -> a signal happens and then there's a pullback afterwards or
price keeps heading higher then do the following [but not finished coding]

HTH


Reply With Quote
Thanked by:




Last Updated on March 2, 2020


© 2026 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 - Downloads - Top
no new posts