False signal stochastic

#1
Hello,
I had posted this question before but as I got no suitable reply I am posting it again with some changes.The false bar stochastic gives a bar above or below the stochastic line in the overbought and oversold zones which instructs us to ignore the overbought or oversold signals and continue with the short or long position.
The False Bar Stochastic for Advanced Get can be duplicated in Amibroker thus

_SECTION_BEGIN("Stochastic_45-4-2_833");

ColorX=colorBlack;
//ColorX=colorWhite;

SetChartBkColor(ParamColor("Panel color ",ColorX));

periods = Param( "Periods", 45, 1, 200, 1 );
K1smooth = Param( "%K1 avg", 4, 1, 200, 1 );
//Plot( StochK( periods , K1smooth), _DEFAULT_NAME(), colorCustom3, styleNoLabel | styleThick | styleDots);


periods = Param( "Periods", 45, 1, 200, 1 );
K1smooth = Param( "%K1 avg", 4, 1, 200, 1 );
D1smooth = Param( "%D1 avg", 2, 1, 200, 1 );
//Plot( StochD( periods , K1smooth, D1Smooth ), _DEFAULT_NAME(), colorCustom3, styleNoLabel | styleThick | styleDots);



A = StochK( periods , K1smooth);
B = StochD( periods , K1smooth, D1Smooth );


Plot (20, "", colorTan, styleNoLabel);
Plot (50, "", colorLavender, styleNoLabel);
Plot (80, "", colorTan, styleNoLabel);

PlotOHLC( 100, 100 , 95 , 95 , "", IIf(A>80,colorAqua,ColorX), styleCloud | styleNoLabel);
PlotOHLC( 5, 5 , 0 , 0 , "", IIf(A<20,colorAqua,ColorX), styleCloud | styleNoLabel);

periods = Param( "Periods", 8, 1, 200, 1 );
K1smooth = Param( "%K1 avg", 3, 1, 200, 1 );



periods = Param( "Periods", 8, 1, 200, 1 );
K2smooth = Param( "%K1 avg", 3, 1, 200, 1 );
D2smooth = Param( "%D1 avg", 3, 1, 200, 1 );

M = StochK( periods , K2smooth);
N = StochD( periods , K2smooth, D2Smooth );

ColorK=IIf(A>B,colorBrightGreen,colorRed);

Plot( M,"StoK", ColorK, styleNoLabel|styleThick);
Plot( N,"StoD", colorDarkYellow, styleNoLabel|styleDashed);



//PlotOHLC( 0, A , B , B , "Cloud", IIf(A > B ,colorAqua,colorRed), styleCloud | styleNoLabel);


_SECTION_END();

What I want is an exploration to return the first instance of a false bar appearance in a security
 

mastermind007

Well-Known Member
#2
your question is incomplete.

first instance of false bar [counting from where]? How do you call a given instance first or not first? I mean what makes you reset the counter back to zero.
 
#3
Hello,
I had posted this question before but as I got no suitable reply I am posting it again with some changes.The false bar stochastic gives a bar above or below the stochastic line in the overbought and oversold zones which instructs us to ignore the overbought or oversold signals and continue with the short or long position.
The False Bar Stochastic for Advanced Get can be duplicated in Amibroker thus

_SECTION_BEGIN("Stochastic_45-4-2_833");

ColorX=colorBlack;
//ColorX=colorWhite;

SetChartBkColor(ParamColor("Panel color ",ColorX));

periods = Param( "Periods", 45, 1, 200, 1 );
K1smooth = Param( "%K1 avg", 4, 1, 200, 1 );
//Plot( StochK( periods , K1smooth), _DEFAULT_NAME(), colorCustom3, styleNoLabel | styleThick | styleDots);


periods = Param( "Periods", 45, 1, 200, 1 );
K1smooth = Param( "%K1 avg", 4, 1, 200, 1 );
D1smooth = Param( "%D1 avg", 2, 1, 200, 1 );
//Plot( StochD( periods , K1smooth, D1Smooth ), _DEFAULT_NAME(), colorCustom3, styleNoLabel | styleThick | styleDots);



A = StochK( periods , K1smooth);
B = StochD( periods , K1smooth, D1Smooth );


Plot (20, "", colorTan, styleNoLabel);
Plot (50, "", colorLavender, styleNoLabel);
Plot (80, "", colorTan, styleNoLabel);

PlotOHLC( 100, 100 , 95 , 95 , "", IIf(A>80,colorAqua,ColorX), styleCloud | styleNoLabel);
PlotOHLC( 5, 5 , 0 , 0 , "", IIf(A<20,colorAqua,ColorX), styleCloud | styleNoLabel);

periods = Param( "Periods", 8, 1, 200, 1 );
K1smooth = Param( "%K1 avg", 3, 1, 200, 1 );



periods = Param( "Periods", 8, 1, 200, 1 );
K2smooth = Param( "%K1 avg", 3, 1, 200, 1 );
D2smooth = Param( "%D1 avg", 3, 1, 200, 1 );

M = StochK( periods , K2smooth);
N = StochD( periods , K2smooth, D2Smooth );

ColorK=IIf(A>B,colorBrightGreen,colorRed);

Plot( M,"StoK", ColorK, styleNoLabel|styleThick);
Plot( N,"StoD", colorDarkYellow, styleNoLabel|styleDashed);



//PlotOHLC( 0, A , B , B , "Cloud", IIf(A > B ,colorAqua,colorRed), styleCloud | styleNoLabel);


_SECTION_END();

What I want is an exploration to return the first instance of a false bar appearance in a security
@gorachand : Sir, if you post such queries in https://www.traderji.com/community/threads/simple-coding-help-no-promise.90119/ this thread, it will help you since many who can help will be visiting this thread and also people who are looking for such afls will be able to find at one place. I don't understand what you mean by false bar stochastic, but whatever little I can make out is you want to know the symbols/scrips for whom the conditions K>80 or K<20 are valid or the cross occurred first and such scrips names should appear in exploration then please add the below given code to your afl at the end. Hope it helps. Thnx.


Code:
_SECTION_BEGIN("Exploration for Stochastic K Smooth");

lastorallsignals = ParamToggle("All Signals/Last Signal","Last|All",0);
whatinstance = ParamToggle("All Instance/First Instance","All|First",0);
filterstouse = ParamList("What Filters?","Both|K>80|K<20",0);


KCross80 = Cross(A,80);
KCross20 = Cross(20,A);
KAbove80 = A>80;
KBelow20 = A<20;
Both = KAbove80 OR KBelow20;
BothCross = KCross80 OR KCross20;

if(lastorallsignals==0 AND whatinstance==0)
{if(filterstouse == "Both")
{Filter=Status("LastBarinRange") AND Both;}
if(filterstouse == "K>80")
{Filter=Status("LastBarinRange") AND KAbove80;}
if(filterstouse == "K<20")
{Filter=Status("LastBarinRange") AND KBelow20;}
}

if(lastorallsignals==0 AND whatinstance==1)
{if(filterstouse == "Both")
{Filter=Status("LastBarinRange") AND BothCross;}
if(filterstouse == "K>80")
{Filter=Status("LastBarinRange") AND KCross80;}
if(filterstouse == "K<20")
{Filter=Status("LastBarinRange") AND KCross20;}
}

if(lastorallsignals==1 AND whatinstance ==0)
{if(filterstouse == "Both")
{Filter = Both;}
if(filterstouse == "K>80")
{Filter=KAbove80;}
if(filterstouse == "K<20")
{Filter= KBelow20;}
}

if(lastorallsignals==1 AND whatinstance ==1)
{if(filterstouse == "Both")
{Filter = BothCross;}
if(filterstouse == "K>80")
{Filter=KCross80;}
if(filterstouse == "K<20")
{Filter= KCross20;}
}

AddTextColumn( Interval(2), "Set Interval", 1 );
AddColumn(IIf(whatinstance==0,ValueWhen(KAbove80,C),IIf(whatinstance==1,ValueWhen(KCross80,C),0)), "K > 80     ",1.2);
AddColumn(IIf(whatinstance==0,ValueWhen(KBelow20,C),IIf(whatinstance==1,ValueWhen(KCross20,C),0)), "K < 20     ",1.2);
SetSortColumns( -2,1);

_SECTION_END();
 
#4
Hello,
Thank you for your reply.Sorry for the delay in replying.
In your code --I am getting an error that you have not initialised the variable "a".
Could you please solve this problem?

Also

I will explain what I mean by false bar stochastic. Supposing for a buy signal the stochastic drops below 20.This is an indication for prices to stop going lower and turn up.But no-- in some instances the price keeps on going lower disregarding the oversold signal.This is where the bar starts forming below the chart.So if I short my position when the bar begins to form and exit when it has stopped forming--- I have a tidy profit.
Ditto for the oversold sell signal.
This is what is called a false bar stochastic.
I want an exploration that returns the bar where the false bar starts forming either above or below the chart.
I hope I have explained myself.
Expecting the corrected code from you---
Regards,
Dr.Chatterjee
Calcutta
 
#5
Hello,
Thank you for your reply.Sorry for the delay in replying.
In your code --I am getting an error that you have not initialised the variable "a".
Could you please solve this problem?

Also

I will explain what I mean by false bar stochastic. Supposing for a buy signal the stochastic drops below 20.This is an indication for prices to stop going lower and turn up.But no-- in some instances the price keeps on going lower disregarding the oversold signal.This is where the bar starts forming below the chart.So if I short my position when the bar begins to form and exit when it has stopped forming--- I have a tidy profit.
Ditto for the oversold sell signal.
This is what is called a false bar stochastic.
I want an exploration that returns the bar where the false bar starts forming either above or below the chart.
I hope I have explained myself.
Expecting the corrected code from you---
Regards,
Dr.Chatterjee
Calcutta
@gorachand :
1.Have you done as instructed? (to put the "Exploration for Stochastic K Smooth" afl after your afl?). The variable "A" is not defined by me but your afl, so I need not do any thing. If you put my provided afl before yours you will get "4 error(s) - Error 29. Variable 'a' used without having been initialized". It is working perfectly at my end without any errors. Hence, please read instruction before shooting questions.
then please add the below given code to your afl at the end.
2.Thank you for your explanations on false bar stochastic. Was I right in interpreting that the thick line (the K-Smooth line - lime/ red) when above 80 or below 20 such "Aqua color" appear above or below the K-Smooth line? If yes, then the exploration is correct.

3.There are exploration options to choose from the "parameters in exploration window";
(a) "All Signals/Last Signal" -
1 - "All" - if you want all such signal from start of your time line.
2 - "Last" - displays only the last signals.

(b) "All Instance/First Instance"
1 - "All" - displays the time this K-Smooth line was above 80 or below 20.
2 - "First" - displays the first instance when the K-Smooth line crossed above 80 or below 20.

(c) "What Filters?" -
1 - "Both" - will pick signals of K-Smooth line above 80 and below 20.
2 - "K>80" - will pick signals only of K-Smooth line above 80.
3 - "K<20" - will pick signals only of K-Smooth line below 20.

Hope it helps. Thnx.
 
#6
Hello,
As you predicted-- copying the code below my afl gives no errors.
But how do you incorporate selected parameters into the exploration?
I mean it is easy to change the parameters on a displayed chart/ indicator window-- by rt clicking and going to " parameters" -- but how does one do that for an exploration?
Thanking you
Regards,
Dr.Chatterjee
 
#7
Hello,
As you predicted-- copying the code below my afl gives no errors.
But how do you incorporate selected parameters into the exploration?
I mean it is easy to change the parameters on a displayed chart/ indicator window-- by rt clicking and going to " parameters" -- but how does one do that for an exploration?
Thanking you
Regards,
Dr.Chatterjee
@gorachand :
1. I am no astrologer to "predict". It is only logical when you refer something from the original code then the new code has to be below that code since all codes are executed in sequence (top to bottom). Hence, this was instructed to you in first place when the code was posted. When you make a mistake, it is good to admit rather than beat around the bushes.
2. If the given code is fulfilling your requirement then there is a button called "Like" and there is word called "thanks", which you may either press or write. So I know that it worked for your requirement and you are satisfied!.
3. Please read the manual if you have not done the exploration before; this will tell you where to find "parameter window in exploration" and how to do exploration on the total universe of your stocks.
Thnx.
 
Last edited:
#8
@gorachand :
1. I am no astrologer to "predict". It is only logical when you refer something from the original code then the new code has to be below that code since all codes are executed in sequence (top to bottom). Hence, this was instructed to you in first place when the code was posted. When you make a mistake, it is good to admit rather than beat around the bushes.
2. If the given code is fulfilling your requirement then there is a button called "Like" and there is word called "thanks", which you may either press or write. So I know that it worked for your requirement and you are satisfied!.
3. Please read the manual if you have not done the exploration before; this will tell you where to find "parameter window in exploration" and how to do exploration on the total universe of your stocks.
Thnx.
Thank you for the code
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?