Simple Coding Help - No Promise.

amitrandive

Well-Known Member
Amit ji ,

Kindly check the formula once... Pin bar are not selected properly.

My requirement

Bullish Pin bar (Close candle) should be outside bollinger band = Buy

Bearish Pin bar (Close candle) Should be Outside bolllinger band = Sell


Thanx you

Check this and let me know.


Code:
blpin = (((H-L)>6*(O-C)) AND ((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6));
brpin = (((H-L)>6*(O-C)) AND ((H-C)/(.001+H-L)>0.7) AND ((H-O)/(.001+H-L)>0.7));
top1=BBandTop(20,2);
bot1=BBandBot(20,2);
Buy=C<bot1 AND blpin;
Sell=C>top1 AND brpin;
Filter=Buy OR Sell;
AddColumn(IIf(Buy,BuyPrice,Null)," Buy Signal ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Sell,SellPrice,Null)," Sell Signal ",6.2,1.2,colorOrange);
 

Check this and let me know.


Code:
blpin = (((H-L)>6*(O-C)) AND ((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6));
brpin = (((H-L)>6*(O-C)) AND ((H-C)/(.001+H-L)>0.7) AND ((H-O)/(.001+H-L)>0.7));
top1=BBandTop(20,2);
bot1=BBandBot(20,2);
Buy=C<bot1 AND blpin;
Sell=C>top1 AND brpin;
Filter=Buy OR Sell;
AddColumn(IIf(Buy,BuyPrice,Null)," Buy Signal ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Sell,SellPrice,Null)," Sell Signal ",6.2,1.2,colorOrange);


Amit ji,

we came close to wt i need. But yet pin bars are not outside bollinger band. Few pin bar are coming in scan which are inside bollinger band.
 
Amit ji ,


one more exploration i need.


when we get huge gap up.. Candle opens outside bollinger band .. need to scan such candles = Upper bollinger band (UB).

When huge gap downs... Candle opens outside bollinger band .. Wish to explore such candles = Lower bollinger band (LB)

Kindly help for such exploration.. its really effective.

Picture given below


Thanx you in advance
 
Last edited:

amitrandive

Well-Known Member
Amit ji,

we came close to wt i need. But yet pin bars are not outside bollinger band. Few pin bar are coming in scan which are inside bollinger band.
Got the error.This will work correctly now.This is a rare pattern, on which time frame are you using this.I did not find many scrips on the Daily frame.

Code:
blpin = (((H-L)>6*(O-C)) AND ((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6));
brpin = (((H-L)>6*(O-C)) AND ((H-C)/(.001+H-L)>0.7) AND ((H-O)/(.001+H-L)>0.7));
top1=BBandTop(20,2);
bot1=BBandBot(20,2);
Buy=H<bot1 AND blpin;
Sell=L>top1 AND brpin;
Filter=Buy OR Sell;
AddColumn(IIf(Buy,BuyPrice,Null)," Buy Signal ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Sell,SellPrice,Null)," Sell Signal ",6.2,1.2,colorOrange);
 

amitrandive

Well-Known Member
Amit ji ,


one more exploration i need.


when we get huge gap up.. Candle opens outside bollinger band .. need to scan such candles = Upper bollinger band (UB).

When huge gap downs... Candle opens outside bollinger band .. Wish to explore such candles = Lower bollinger band (LB)

Kindly help for such exploration.. its really effective.

Picture given below


Thanx you in advance

Learning by experimenting :D
This should work


Code:
top1=BBandTop(20,2);
bot1=BBandBot(20,2);
// Gap Up
GU= L > Ref(C, -1) AND H>= Ref(H, -1);
BBtop1=L>top1;
// Gap down
GD= H < Ref(C, -1) AND L <= Ref(L, -1);;
BBbot1=H<bot1;
Buy=GD AND BBbot1;
Sell=GU AND L>top1;
Filter=Buy OR Sell;
AddTextColumn( FullName(), "Name",100, colorDefault,colorDefault,300);
AddTextColumn( WriteIf( Buy, "Buy", "Sell" ), "Signal", 50, colorDefault,colorDefault, 50 ); 
AddColumn(V, "Volume", 1.0, colorDefault,colorDefault, 100);
 
Got the error.This will work correctly now.This is a rare pattern, on which time frame are you using this.I did not find many scrips on the Daily frame.

Code:
blpin = (((H-L)>6*(O-C)) AND ((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6));
brpin = (((H-L)>6*(O-C)) AND ((H-C)/(.001+H-L)>0.7) AND ((H-O)/(.001+H-L)>0.7));
top1=BBandTop(20,2);
bot1=BBandBot(20,2);
Buy=H<bot1 AND blpin;
Sell=L>top1 AND brpin;
Filter=Buy OR Sell;
AddColumn(IIf(Buy,BuyPrice,Null)," Buy Signal ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Sell,SellPrice,Null)," Sell Signal ",6.2,1.2,colorOrange);

HTML:
blpin = (((H-L)>6*(O-C)) AND ((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6));
brpin = (((H-L)>6*(O-C)) AND ((H-C)/(.001+H-L)>0.7) AND ((H-O)/(.001+H-L)>0.7));
top1=BBandTop(20,2);
bot1=BBandBot(20,2);
Buy=C<bot1 AND blpin;
Sell=C>top1 AND brpin;
Filter=Buy OR Sell;
AddColumn(IIf(Buy,BuyPrice,Null)," Buy Signal ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Sell,SellPrice,Null)," Sell Signal ",6.2,1.2,colorOrange);

Above both formula giving exact same scripts
 
Amit ji ,


one more exploration i need.


when we get huge gap up.. Candle opens outside bollinger band .. need to scan such candles = Upper bollinger band (UB).

When huge gap downs... Candle opens outside bollinger band .. Wish to explore such candles = Lower bollinger band (LB)

Kindly help for such exploration.. its really effective.

Picture given below

Thanx you in advance

top1=BBandTop(20,2);
bot1=BBandBot(20,2);
// Gap Up
GU= L > Ref(C, -1) AND H>= Ref(H, -1);
BBtop1=L>top1;
// Gap down
GD= H < Ref(C, -1) AND L <= Ref(L, -1);;
BBbot1=H<bot1;
Buy=GD AND BBbot1;
Sell=GU AND L>top1;
Filter=Buy OR Sell;
AddTextColumn( FullName(), "Name",100, colorDefault,colorDefault,300);
AddTextColumn( WriteIf( Buy, "Buy", "Sell" ), "Signal", 50, colorDefault,colorDefault, 50 );
AddColumn(V, "Volume", 1.0, colorDefault,colorDefault, 100);




Amit ji...

Please watch the chart in post 3052...

My requirement is Candle should be fully outside bollinger band.. (Not touching bollinger band - As shown in picture in round circle)

Exploration u made.. Candles tail is outside but touching bollinger band..

Please check
 

amitrandive

Well-Known Member
HTML:
blpin = (((H-L)>6*(O-C)) AND ((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6));
brpin = (((H-L)>6*(O-C)) AND ((H-C)/(.001+H-L)>0.7) AND ((H-O)/(.001+H-L)>0.7));
top1=BBandTop(20,2);
bot1=BBandBot(20,2);
Buy=C<bot1 AND blpin;
Sell=C>top1 AND brpin;
Filter=Buy OR Sell;
AddColumn(IIf(Buy,BuyPrice,Null)," Buy Signal ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Sell,SellPrice,Null)," Sell Signal ",6.2,1.2,colorOrange);

Above both formula giving exact same scripts
Amit ji...

Please watch the chart in post 3052...

My requirement is Candle should be fully outside bollinger band.. (Not touching bollinger band - As shown in picture in round circle)

Exploration u made.. Candles tail is outside but touching bollinger band..

Please check

Need to investigate both issues.
Meanwhile would appreciate any help from expert on posts 3053 and 3054.
:D
 
Last edited:
Could anyone help me getting SHORT SELL and BUY TO COVER signals in my code where BUY and SELL are generated but short sell signal is not generated. So I cant test the startegy in Amibroker backtesting as it gives results only for Buy trades. Help appreaciated. Also please tell me how do I send the code. God Bless You . Regards
 

Similar threads