NexusFi: Find Your Edge


Home Menu

 





bool switch... simple..


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one bnichols with 17 posts (3 thanks)
    2. looks_two toddma with 16 posts (0 thanks)
    3. looks_3 ehlaban with 4 posts (2 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 10,381 views
    2. thumb_up 5 thanks given
    3. group 3 followers
    1. forum 37 posts
    2. attach_file 10 attachments




 
Search this Thread

bool switch... simple..

  #1 (permalink)
 
toddma's Avatar
 toddma 
vancouver canada
 
Experience: Intermediate
Platform: multicharts, ninjatrader
Trading: forex
Posts: 53 since Jul 2012
Thanks Given: 14
Thanks Received: 6

I'm having trouble with a simple bool type switch... can anyone see the problem with this code? Here is a piece of sample code -


variables: BoolExitLong(False);
....

//exit code

if marketposition[0] = 1 then begin

if close[0] < average(close,20)[0] then
BoolExitLong = True;

if BoolExitLong = True and close[0] > average(close,50)[0] then
sell ("boolexL") next bar at market;
BoolExitLong = False;

//some more code

end;

What I'm trying to achieve here is "if a certain low level is hit, then sell at next opportunity at a higher level". Everything else works, but this doesn't... when I do get it to work its just constantly stopping out long trades - so clearly not shutting off properly. But also not really working in the first place...

Thanks in advance.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
23 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #3 (permalink)
 
bnichols's Avatar
 bnichols 
Dartmouth NS
 
Experience: Intermediate
Platform: MC, MC.Net, NT, TWS
Broker: IB / IQFeed / Kids
Trading: Forex, stocks
Posts: 637 since Feb 2010
Thanks Given: 64
Thanks Received: 460


Hard to say at this point. The algorithm at least appears to be functional [at least according to a quick comparison of output of the following test indicator with close price in a 240 minute chart of spot EUR.USD (i.e., it appears to be generating a sell signal when close lies between the 20 and 50 SMAs and 20MA > 50MA)]

Assuming there are no errors in the rest of the code logically the go-long algorithm may be entering trades after 20 MA rises above 50 but while the close is still between them, in which case the trade would be immediately stopped out. In the chart below there are a few places this might occur (points where one might go long between the 20MA and 50MA when 20 > 50), but this does not appear to be the rule.

Code
 
Code
variables:

BoolExitLong(false),
l20Closes(0),
l50Closes(0)
;

l20Closes = average(close,20)[0];
if close[0] < l20Closes then 
BoolExitLong = True;

l50Closes = average(close,50)[0];
if BoolExitLong = True and close[0] > l50Closes  then 
Print(D," ",T," Close ",close:1:6," < average 20 closes = ",l20Closes:1:6," and > last 50 closes = ",l50Closes:1:6," sell (boolexL) next bar at market")
else
Print(D," ",T," Close ",close:1:6," average 20 closes = ",l20Closes:1:6," last 50 closes = ",l50Closes:1:6," no sell");

BoolExitLong = False;

Output
 
Code
1120614.00 1330.00 Close 1.259200 average 20 closes = 1.253040 last 50 closes = 1.252679 no sell
1120614.00 1700.00 Close 1.263400 average 20 closes = 1.253435 last 50 closes = 1.253001 no sell
1120614.00 2130.00 Close 1.262100 average 20 closes = 1.254033 last 50 closes = 1.253274 no sell
1120615.00  130.00 Close 1.263800 average 20 closes = 1.254808 last 50 closes = 1.253550 no sell
1120615.00  530.00 Close 1.263400 average 20 closes = 1.255563 last 50 closes = 1.253751 no sell
1120615.00  930.00 Close 1.261150 average 20 closes = 1.256137 last 50 closes = 1.253936 no sell
1120615.00 1330.00 Close 1.264150 average 20 closes = 1.256802 last 50 closes = 1.254354 no sell
1120615.00 1700.00 Close 1.264000 average 20 closes = 1.257560 last 50 closes = 1.254742 no sell
1120617.00 2130.00 Close 1.268600 average 20 closes = 1.258500 last 50 closes = 1.255231 no sell
1120618.00  130.00 Close 1.270600 average 20 closes = 1.259510 last 50 closes = 1.255737 no sell
1120618.00  530.00 Close 1.263950 average 20 closes = 1.260230 last 50 closes = 1.256095 no sell
1120618.00  930.00 Close 1.259150 < average 20 closes = 1.260710 and > last 50 closes = 1.256287 sell (boolexL) next bar at market
1120618.00 1330.00 Close 1.257200 < average 20 closes = 1.260825 and > last 50 closes = 1.256415 sell (boolexL) next bar at market
1120618.00 1700.00 Close 1.257600 < average 20 closes = 1.261050 and > last 50 closes = 1.256627 sell (boolexL) next bar at market
1120618.00 2130.00 Close 1.259800 < average 20 closes = 1.261058 and > last 50 closes = 1.256705 sell (boolexL) next bar at market
1120619.00  130.00 Close 1.260650 < average 20 closes = 1.261303 and > last 50 closes = 1.256755 sell (boolexL) next bar at market
1120619.00  530.00 Close 1.261100 < average 20 closes = 1.261553 and > last 50 closes = 1.256841 sell (boolexL) next bar at market
1120619.00  930.00 Close 1.264450 average 20 closes = 1.261840 last 50 closes = 1.256993 no sell
1120619.00 1330.00 Close 1.272200 average 20 closes = 1.262680 last 50 closes = 1.257272 no sell
1120619.00 1700.00 Close 1.268550 average 20 closes = 1.263253 last 50 closes = 1.257408 no sell
1120619.00 2130.00 Close 1.267200 average 20 closes = 1.263653 last 50 closes = 1.257538 no sell
1120620.00  130.00 Close 1.267650 average 20 closes = 1.263865 last 50 closes = 1.257769 no sell
1120620.00  530.00 Close 1.270300 average 20 closes = 1.264275 last 50 closes = 1.258117 no sell
1120620.00  930.00 Close 1.269850 average 20 closes = 1.264578 last 50 closes = 1.258463 no sell
1120620.00 1330.00 Close 1.270750 average 20 closes = 1.264945 last 50 closes = 1.258941 no sell
1120620.00 1700.00 Close 1.270800 average 20 closes = 1.265428 last 50 closes = 1.259465 no sell
1120620.00 2130.00 Close 1.266750 average 20 closes = 1.265558 last 50 closes = 1.259801 no sell
1120621.00  130.00 Close 1.267500 average 20 closes = 1.265733 last 50 closes = 1.260113 no sell
1120621.00  530.00 Close 1.268500 average 20 closes = 1.265728 last 50 closes = 1.260201 no sell
1120621.00  930.00 Close 1.265150 < average 20 closes = 1.265455 and > last 50 closes = 1.260221 sell (boolexL) next bar at market
1120621.00 1330.00 Close 1.256250 average 20 closes = 1.265070 last 50 closes = 1.260147 no sell
1120621.00 1700.00 Close 1.254200 average 20 closes = 1.264823 last 50 closes = 1.260121 no sell
1120621.00 2130.00 Close 1.256300 average 20 closes = 1.264778 last 50 closes = 1.260244 no sell
1120622.00  130.00 Close 1.255550 average 20 closes = 1.264675 last 50 closes = 1.260389 no sell
1120622.00  530.00 Close 1.254700 average 20 closes = 1.264420 last 50 closes = 1.260517 no sell
1120622.00  930.00 Close 1.257650 average 20 closes = 1.264270 last 50 closes = 1.260677 no sell
1120622.00 1330.00 Close 1.256450 average 20 closes = 1.264038 last 50 closes = 1.260789 no sell
1120622.00 1700.00 Close 1.257100 average 20 closes = 1.263670 last 50 closes = 1.260954 no sell
1120624.00 2130.00 Close 1.253000 average 20 closes = 1.262710 last 50 closes = 1.261018 no sell
1120625.00  130.00 Close 1.253050 average 20 closes = 1.261935 last 50 closes = 1.261071 no sell
1120625.00  530.00 Close 1.248950 average 20 closes = 1.261023 last 50 closes = 1.261059 no sell
1120625.00  930.00 Close 1.249100 average 20 closes = 1.260095 last 50 closes = 1.261050 no sell
1120625.00 1330.00 Close 1.250050 average 20 closes = 1.259083 last 50 closes = 1.260953 no sell
1120625.00 1700.00 Close 1.250450 average 20 closes = 1.258113 last 50 closes = 1.260900 no sell
1120625.00 2130.00 Close 1.252100 average 20 closes = 1.257180 last 50 closes = 1.260749 no sell
1120626.00  130.00 Close 1.250000 average 20 closes = 1.256140 last 50 closes = 1.260634 no sell
1120626.00  530.00 Close 1.248600 average 20 closes = 1.255233 last 50 closes = 1.260484 no sell
1120626.00  930.00 Close 1.247850 average 20 closes = 1.254250 last 50 closes = 1.260267 no sell
1120626.00 1330.00 Close 1.248500 average 20 closes = 1.253250 last 50 closes = 1.260129 no sell
1120626.00 1700.00 Close 1.249200 average 20 closes = 1.252453 last 50 closes = 1.259971 no sell
1120626.00 2130.00 Close 1.248500 average 20 closes = 1.252065 last 50 closes = 1.259757 no sell
1120627.00  130.00 Close 1.250250 average 20 closes = 1.251868 last 50 closes = 1.259494 no sell
1120627.00  530.00 Close 1.248900 average 20 closes = 1.251498 last 50 closes = 1.259230 no sell
1120627.00  930.00 Close 1.247850 average 20 closes = 1.251113 last 50 closes = 1.258911 no sell
1120627.00 1330.00 Close 1.247500 average 20 closes = 1.250753 last 50 closes = 1.258593 no sell
1120627.00 1700.00 Close 1.246950 average 20 closes = 1.250218 last 50 closes = 1.258309 no sell
1120627.00 2130.00 Close 1.249150 average 20 closes = 1.249853 last 50 closes = 1.258009 no sell
1120628.00  130.00 Close 1.251900 average 20 closes = 1.249592 last 50 closes = 1.257767 no sell
1120628.00  530.00 Close 1.243400 average 20 closes = 1.249113 last 50 closes = 1.257263 no sell
1120628.00  930.00 Close 1.243550 average 20 closes = 1.248638 last 50 closes = 1.256722 no sell
1120628.00 1330.00 Close 1.242600 average 20 closes = 1.248320 last 50 closes = 1.256295 no sell
1120628.00 1700.00 Close 1.244400 average 20 closes = 1.248085 last 50 closes = 1.256000 no sell
1120628.00 2130.00 Close 1.244950 average 20 closes = 1.247830 last 50 closes = 1.255755 no sell
1120629.00  130.00 Close 1.257900 average 20 closes = 1.248202 last 50 closes = 1.255761 no sell
1120629.00  530.00 Close 1.257250 average 20 closes = 1.248460 last 50 closes = 1.255710 no sell
1120629.00  930.00 Close 1.268050 average 20 closes = 1.249362 last 50 closes = 1.255858 no sell
1120629.00 1330.00 Close 1.266300 average 20 closes = 1.250248 last 50 closes = 1.255962 no sell
1120629.00 1700.00 Close 1.266850 average 20 closes = 1.251198 last 50 closes = 1.256010 no sell
1120701.00 2130.00 Close 1.263500 average 20 closes = 1.251948 last 50 closes = 1.255836 no sell
1120702.00  130.00 Close 1.262450 average 20 closes = 1.252610 last 50 closes = 1.255714 no sell
1120702.00  530.00 Close 1.264650 average 20 closes = 1.253417 last 50 closes = 1.255663 no sell
1120702.00  930.00 Close 1.260100 average 20 closes = 1.253910 last 50 closes = 1.255512 no sell
1120702.00 1330.00 Close 1.258550 average 20 closes = 1.254393 last 50 closes = 1.255277 no sell
1120702.00 1700.00 Close 1.257900 average 20 closes = 1.254895 last 50 closes = 1.255038 no sell
1120702.00 2130.00 Close 1.258300 average 20 closes = 1.255435 last 50 closes = 1.254789 no sell
1120703.00  130.00 Close 1.259650 average 20 closes = 1.256070 last 50 closes = 1.254566 no sell
1120703.00  530.00 Close 1.258700 average 20 closes = 1.256547 last 50 closes = 1.254405 no sell
1120703.00  930.00 Close 1.256700 < average 20 closes = 1.256787 and > last 50 closes = 1.254189 sell (boolexL) next bar at market
1120703.00 1330.00 Close 1.260750 average 20 closes = 1.257655 last 50 closes = 1.254034 no sell
1120703.00 1700.00 Close 1.260850 average 20 closes = 1.258520 last 50 closes = 1.253948 no sell
1120703.00 2130.00 Close 1.259250 < average 20 closes = 1.259352 and > last 50 closes = 1.254008 sell (boolexL) next bar at market
1120704.00  130.00 Close 1.259250 < average 20 closes = 1.260095 and > last 50 closes = 1.254109 sell (boolexL) next bar at market
1120704.00  530.00 Close 1.258500 < average 20 closes = 1.260773 and > last 50 closes = 1.254153 sell (boolexL) next bar at market
1120704.00  930.00 Close 1.256050 < average 20 closes = 1.260680 and > last 50 closes = 1.254163 sell (boolexL) next bar at market
1120704.00 1330.00 Close 1.253650 average 20 closes = 1.260500 last 50 closes = 1.254142 no sell
1120704.00 1700.00 Close 1.252800 average 20 closes = 1.259738 last 50 closes = 1.254045 no sell
1120704.00 2130.00 Close 1.253650 average 20 closes = 1.259105 last 50 closes = 1.253989 no sell
1120705.00  130.00 Close 1.252350 average 20 closes = 1.258380 last 50 closes = 1.253894 no sell
1120705.00  530.00 Close 1.250650 average 20 closes = 1.257738 last 50 closes = 1.253847 no sell
1120705.00  930.00 Close 1.238350 average 20 closes = 1.256533 last 50 closes = 1.253553 no sell
...

Chart:

Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 
toddma's Avatar
 toddma 
vancouver canada
 
Experience: Intermediate
Platform: multicharts, ninjatrader
Trading: forex
Posts: 53 since Jul 2012
Thanks Given: 14
Thanks Received: 6

Hi bnichols,
I really appreciate the help. That was terrific - however, I'm still stuck on why it won't work for me.

how can I be seeing output like this…

1121107.00 557.00Bool was TRUE and EXIT level reached
1121107.00 557.00Turning Bool OFF
1121107.00 618.00Bool was TRUE and EXIT level reached
1121107.00 618.00Turning Bool OFF
1121106.00 1957.00Initial Bool ON
1121106.00 1957.00Turning Bool OFF
1121107.00 824.00Initial Bool ON
1121107.00 824.00Turning Bool OFF


with the following code blocks:

if marketposition(0) = 1 then begin

if close[0] < KeltnerChannelLower(close,Kexitlen,KeltWidex)[0] then begin
Print(D," ",T,"Initial Bool ON");
BoolExitLong = 1;
end;


if BoolExitLong = 1 then begin
if close[0] > KeltnerChannelLower(close,Keltlen,keltwid)[0] then
Print(D," ",T,"Bool was TRUE and EXIT level reached");
sell ("bool was true exit") next bar at market;
Print(D," ",T,"Turning Bool OFF");
BoolExitLong = 0;
end;
...
end;


How is it running through that last block of code and acting on the last part but not the middle part? Doesn't it only execute the two actions (and two print statements) if the first two were true? How is it only executing one of the actions?

Referring to this part of the output:
1121106.00 1957.00Initial Bool ON
1121106.00 1957.00Turning Bool OFF
1121107.00 824.00Initial Bool ON
1121107.00 824.00Turning Bool OFF

Started this thread Reply With Quote
  #5 (permalink)
 
toddma's Avatar
 toddma 
vancouver canada
 
Experience: Intermediate
Platform: multicharts, ninjatrader
Trading: forex
Posts: 53 since Jul 2012
Thanks Given: 14
Thanks Received: 6

Here is an image of whats happening as well - it appears to be closing the position on the "Bool was true exit level reached" exit - so selling at market right there, however it's not fulfilling the the second requirement of that block of code:

Close must be greater than KeltnerChannelLower
"if close[0] > KeltnerChannelLower(close,20,1.5)[0] then"

As you can see its closing below the Keltner Channel Lower, its only supposed to close when it retraces back up to the kelt band. The KeltnerChannelLower function normally works so that shouldn't be the issue...

Am i missing something... ?

Attached Thumbnails
Click image for larger version

Name:	strange.jpg
Views:	221
Size:	102.5 KB
ID:	96668  
Started this thread Reply With Quote
  #6 (permalink)
 
bnichols's Avatar
 bnichols 
Dartmouth NS
 
Experience: Intermediate
Platform: MC, MC.Net, NT, TWS
Broker: IB / IQFeed / Kids
Trading: Forex, stocks
Posts: 637 since Feb 2010
Thanks Given: 64
Thanks Received: 460


toddma View Post
Here is an image of whats happening as well - it appears to be closing the position on the "Bool was true exit level reached" exit - so selling at market right there, however it's not fulfilling the the second requirement of that block of code:

Close must be greater than KeltnerChannelLower
"if close[0] > KeltnerChannelLower(close,20,1.5)[0] then"

As you can see its closing below the Keltner Channel Lower, its only supposed to close when it retraces back up to the kelt band. The KeltnerChannelLower function normally works so that shouldn't be the issue...

Am i missing something... ?

While I don't see any issues with the output versus the code snippet in post #4 (i.e., it appears to be doing exactly what it's told to do), the comment in post #5 (" it's not fulfilling the the second requirement of that block of code: Close must be greater than KeltnerChannelLower") suggests that you might be missing a begin/end block.

Right now the code will exit the position as soon as price drops below the lower Keltner boundary because the lines

 
Code
if close[0] > KeltnerChannelLower(close,Keltlen,keltwid)[0] then
Print(D," ",T,"Bool was TRUE and EXIT level reached");
simply prints out some text if the test is true, rather than controlling the exit.

You may intend the following:

 
Code
if BoolExitLong = 1 then begin
if close[0] > KeltnerChannelLower(close,Keltlen,keltwid)[0] then begin
Print(D," ",T,"Bool was TRUE and EXIT level reached");
sell ("bool was true exit") next bar at market;
Print(D," ",T,"Turning Bool OFF"); 
BoolExitLong = 0;
end;
end;

Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
 ehlaban 
Netherlands
 
Experience: Advanced
Platform: Ensign, Multicharts
Trading: SP500
Posts: 91 since Nov 2009
Thanks Given: 66
Thanks Received: 57

You seem to want to do 2 things when if BoolExitLong=True AND etc ...

Combine them in a begin end statement so they belong to that If statement
otherwise the BoolExitLong will always reset to False.
e.g.

 
Code
if BoolExitLong = True and close[0] > average(close,50)[0] then 
begin
	sell ("boolexL") next bar at market;
	BoolExitLong = False;
end;



toddma View Post
I'm having trouble with a simple bool type switch... can anyone see the problem with this code? Here is a piece of sample code -


variables: BoolExitLong(False);
....

//exit code

if marketposition[0] = 1 then begin

if close[0] < average(close,20)[0] then
BoolExitLong = True;

if BoolExitLong = True and close[0] > average(close,50)[0] then
sell ("boolexL") next bar at market;
BoolExitLong = False;

//some more code

end;

What I'm trying to achieve here is "if a certain low level is hit, then sell at next opportunity at a higher level". Everything else works, but this doesn't... when I do get it to work its just constantly stopping out long trades - so clearly not shutting off properly. But also not really working in the first place...

Thanks in advance.


Reply With Quote
  #8 (permalink)
 
bnichols's Avatar
 bnichols 
Dartmouth NS
 
Experience: Intermediate
Platform: MC, MC.Net, NT, TWS
Broker: IB / IQFeed / Kids
Trading: Forex, stocks
Posts: 637 since Feb 2010
Thanks Given: 64
Thanks Received: 460

BTW, I wrote a signal to test the exit policy you describe and it appears to have a fairly robust expectancy, which means while it might be improved it may make money as is once optimized for your instrument, more money with more investment, so good luck with it

Edited to add: Which is a warning it will probably lose money trading micro lots with realistic slippage and commission

Visit my NexusFi Trade Journal Reply With Quote
  #9 (permalink)
 
toddma's Avatar
 toddma 
vancouver canada
 
Experience: Intermediate
Platform: multicharts, ninjatrader
Trading: forex
Posts: 53 since Jul 2012
Thanks Given: 14
Thanks Received: 6

Hi Bnichols and Ehlaban, thank you very much for your help. Much appreciated!
I tried both of these suggestions:

 
Code
if BoolExitLong = 1 then begin
if close[0] > KeltnerChannelLower(close,Keltlen,keltwid)[0] then begin
Print(D," ",T,"Bool was TRUE and EXIT level reached");
sell ("bool was true exit") next bar at market;
Print(D," ",T,"Turning Bool OFF"); 
BoolExitLong = 0;
end;
end;

 
Code
if BoolExitLong = True and close[0] > average(close,50)[0] then 
begin
	sell ("boolexL") next bar at market;
	BoolExitLong = False;
end;
However, I was still getting a million improper exits >> as compared to what I was trying to achieve. So I started to think that it might be something else that's causing the issue.

I decided to start over with this section of code so that it is very simple and all parts of the code can be seen. I am only looking at the long side of the code to make this even simpler.

So I'll try to explain again what I am trying to do:

The entry is not important here. The exit is what I am trying to get right. The idea is that once the price closes below a certain level then an exit signal is generated (the bool turning to TRUE, no trades taking place). This means that the price is lower than the KeltnerChannel (in this case - could be a bollinger band etc) - now we're looking for a retracement to get out of the long position. I have the retracement level required set as an 18 period moving average which should always be in between the keltners.

So the bool can only be turned on when we're in a long position and when we're below the lower keltner and it will always exit once we retrace up to the moving average. It should not continue holding beyond that level...
I also have the bool being turned off after any other type of exit so that the bool is only True just before an exit takes place.

I have it acting fairly well now (as I had intended) However, I still can't account why it will only exit half of the time when "it is supposed to" - according to my intent.

Here is my current simple code (all of it):

 
Code
[IntrabarOrderGeneration = True]

inputs: Num1(40), Num2(60);
variables: CloseTrade(false);


// Just a long target
if positionprofit > 4000 then begin
sell ("target") next bar at market;
CloseTrade = False;
end;

// Long signal (basic)
if Average(close,Num1)[0] > Average(close,Num2)[0] then begin
buy ("long") next bar at market;
CloseTrade = False;
end;

// Turns ON CloseTrade bool
if marketposition = 1 then begin
if close[0] <= keltnerchannellower(close,25,2.5)[0] then begin
CloseTrade = True;
end;
end;


// Just another check to make sure we're in a long position, if not CloseTrade OFF
If marketposition = 0 or marketposition = -1 then begin
CloseTrade = False;
end;

// The CloseTrade EXIT
if marketposition = 1 and CloseTrade = True and close[0] > Average(close,18)[0] then begin
sell ("CloseTrade") next bar at market;
CloseTrade = False;
end;

This issue remaining is shown below - As you can see the code has us in a long trade coming into the section shown - then price drops below the keltnerchannel lower bound around 18:45 which should have turned on the bool exit (CloseTrade = True) - it should have then been looking for price to close above the 18 period moving average. It moves above the average but nothing happens. Same thing further along at 7/11/2012 7:00-11:00 and then moves back above and through the moving average - but no exit once it gets to that level. And then for some reason the CloseTrade trade happens later on after another move below the lower keltner....

Any thoughts here? I'm really stuck...
Thanks again for all of the help.

Attached Thumbnails
Click image for larger version

Name:	problem.gif
Views:	229
Size:	16.5 KB
ID:	96847  
Started this thread Reply With Quote
  #10 (permalink)
 
bnichols's Avatar
 bnichols 
Dartmouth NS
 
Experience: Intermediate
Platform: MC, MC.Net, NT, TWS
Broker: IB / IQFeed / Kids
Trading: Forex, stocks
Posts: 637 since Feb 2010
Thanks Given: 64
Thanks Received: 460


It may be time to revisit our assumptions, since my implementation of your code works 100% as expected with Multicharts

First, are you using MC or TS?

Second, I'm assuming my homebrew implementation of keltnerchannellower in the following code snippet

 
Code
KeltnerChannelMid = AverageFC(Close,Keltlen);
KeltnerChannelLower = KeltnerChannelMid  - keltwid * AvgTrueRange(Keltlen);
KeltnerChannelUpper = KeltnerChannelMid  + keltwid * AvgTrueRange(Keltlen);

(where Keltlen = 25 and keltwid = 2.5 in this case)
is essentially the same as the implementation you are using. Can you confirm what you are using for the keltnerchannellower() function ?

Finally, is the Keltner Channel you display on the chart using the same parameter values as the strategy?

Visit my NexusFi Trade Journal Reply With Quote




Last Updated on December 12, 2012


© 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