Simple Coding Help - No Promise.

OR Solve this

Code:
#include <ncurses.h>/*****************************************************/
            int               m[256                   ] [         256   ],a
 ,b   ;;;   ;;;   WINDOW*w;   char*l=""   "\176qxl"   "q"   "q"   "k"   "w\
xm"   "x"   "t"         "j"         "v"         "u"         "n"         ,Q[
 ]=   "Z"   "pt!ftd`"   "qdc!`eu"   "dq!$c!nnwf"/**   ***   */"t\040\t";c(
int   u ,         int         v){                     v?m   [u]         [v-
 1]   |=2,m[u][v-1] &   48?W][v-1   ] &   15]]):0:0;u?m[u   -1][v]|=1   ,m[
 u-               1][   v]&         48?               W-1   ][v         ]&
15]   ]):0:0;v<   255   ?m[   u][v+1]|=8,m[u][v+1]&   48?   W][   v+1]&15]]
):0         :0;         u <               255   ?m[   u+1         ][v   ]|=
4,m[u+1][   v]&48?W+1][v]&15]]):0:0;W][   v]&   15]   ]);}cu(char*q){   return
 *q               ?cu   (q+         1)&         1?q   [0]               ++:
q[0   ]--   :1;   }d(   int   u ,   int/**/v,   int/**/x,   int   y){   int
Y=y   -v,   X=x         -u;   int         S,s   ;Y<         0?Y   =-Y   ,s,
s=-   1:(   s=1);X<0?X=-X,S   =-1  :(S=   1);   Y<<=   1;X<<=1;   if(X>Y){
int   f=Y               -(X   >>1   );;               while(u!=         x){
f>=   0?v+=s,f-=X:0;u   +=S   ;f+=   Y;m[u][v]|=32;mvwaddch(w,v   ,u,   m[u
 ][               v]&   64?   60:         46)         ;if         (m[   u][
v]&16){c(u,v);;   ;;;   ;;;   return;}}   }else{int   f=X   -(Y>>1);;   while
 (v   !=y         ){f   >=0         ?u   +=S,               f-=         Y:0
 ;v   +=s   ;f+=X;m[u][v]|=   32;mvwaddch(w,v   ,u,m[u][v]&64?60:46);if(m[u
 ][                     v]&         16)   {c(   u,v                     );
  ;   return;;;}}}}Z(   int/**/a,   int   b){   }e(   int/**/y,int/**/  x){
int               i ;         for         (i=         a;i               <=a
+S;i++)d(y,x,i,b),d(y,x,i,b+L);for(i=b;i<=b+L;i++)d(y,x,a,i),d(y,x,a+   S,i
 );                     ;;;         ;;;         ;;;               ;;;   ;
  mvwaddch(w,x,y,64);   ;;;   ;;;   ;;;   prefresh(   w,b,a,0,0   ,L-   1,S-1
);}             main(         int               V ,   char              *C[
  ]   ){FILE*f=   fopen(V==1?"arachnid.c"/**/   :C[   1],"r");int/**/x,y,c,
v=0         ;;;      initscr              ();               Z(Z         (raw
 ()   ,Z(   curs_set(0),Z(1   ,noecho()))),keypad(    stdscr,TRUE));w   =newpad
  (   300,  300               ) ;   for         (x=   255   ; x   >=0   ;x--
  )   for   (y=   255   ;y>=0;y--   )m[   x][   y]=   0;x=y=0;refresh( );while
  (   (c=                           fgetc (f)   )+1)                    {if(
0||c==10||  x==   256){x=0;y++;if(y==256  )break;;}   else{m[x][y]=(c   ==
'~'   ?64   : c   ==32              ?0:         16)   ;;x               ++;
      }}for(x=0   ;x<   256;x++)m   [x][0]=16   ,m[   x][   255]=16;for(y=0
;y<         256   ; y         ++)   m[0         ][y   ] =               16,
m[255][y]   =16   ;a=b=c=0;   x=y   =1;   do{v++;mvwaddch   (w,   y,x   ,m[
x][         y]&               32?   m[x                     ][y   ] &   16?
 0|   acs_map[l[m[x][y]&15]]:46 :   32);c==0163&&!(m[x][y+1]&16)?y++:   0;c
 ==   119         &&!         (m[                                       x][
 y-   1]&   16)   ?y--:0;;c   ==97  &&!(m[x-1][y]&16)?x--:0;c==100&&!(m[x+1
 ][   y]&   16)         ? x   ++:0              ;if(                    c==
 3-   1+1   ){endwin(   );;   return(0)   ;}x   -a<5?a>S-   5?a-=S-5:(a=0):
0;x               -a>         S-5?a<255   -S*         2?a               +=S
-5:(a=256-S):0;   y-b<5?b>L-5?b-=L-5:(b   =0)   :0;   y-b>L-5?b<255-L   *2?
b+=                                       L-5   :(b                     =256
-L)   :0;e(x,y);if(m[x][y]&64)break;}while((c=getch())!=-1);endwin();cu(Q);
printf(Q,v);}
 

toughard

Well-Known Member
That amateurish code by Minimind again. Yeah, learn how to do amateurish codes.

Pros do it like this
XBuy = Ref(Close, -5) < Ref(ema200, -5) AND Sum ( C > ema200, 5 ) == 5;
XSell = Ref(Close, -5) > Ref(ema200, -5) AND Sum ( C < ema200, 5 ) == 5;

Amateurs like Minime would use thousands of Refs and would sit hours in front of their PC just to achieve that.

:D

Talking about amateurs... Where is my lovely copy&paste thug ford7k ?

Sir since morning I am trying to get the buy indicator after the signal candle
 

toughard

Well-Known Member
nihal sir, master mind sir

Nihal sir's code is 99% great for me but only thing is to get the buy signal only if the close is above signal candle.

BuyX=Cross((EMA(Close,range1)),(EMA(Close,range2)) );
SellX=Cross((EMA(Close,range2)),(EMA(Close,range1) ));
Buy = H > Ref(H, -1) AND Ref(BuyX, -1);
Sell = L < Ref(L, -1) AND Ref(SellX, -1);
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

I found this code by anant sir on this site and also think that little sharp expertise is needed to achieve the goal:thumb:

toughard
 

toughard

Well-Known Member
hurrrrrrrrrrrrrrrrrrrrrryyyyyyyyyyyyyyyyyyyyyyyyyy

thanks nihal sir and thanks master mind sir for you time on this little guy.......

I have achieved it after my own full efforts with a big thanks to anant sir for his part of code on http://www.traderji.com/amibroker/42508-coding-help.html
#8

finally go the signal the way i wanted it.....

please correct for further improvement....

_SECTION_BEGIN( "Price" );
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", colorRose, styleCandle | styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("ema_crossover");
x = EMA(Close,11);
y = EMA(High,11);
z = EMA(Low,11);
Ph = Ref(High,-1);
PL = Ref(Low,-1);

Plot(EMA(Close,11),"",colorRed,styleLine);
Plot(EMA(Low,11),"",colorPaleGreen,styleLine);
Plot(EMA(High,11),"",colorDarkGreen,styleLine);

BuyX= C>O AND C>Y ; //AND C>ph;
SellX=C<O AND C<Z ; //AND C<PL;
Buy = H > Ph AND Ref(BuyX, -1);
Sell = L < PL AND Ref(SellX, -1);
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);



//Buy=ExRem(Buy,Sell);
//Short=ExRem(Short,Cover);
//Sell=ExRem(Sell,Buy);
//Cover=ExRem(Cover,Short);

PlotShapes(Buy* shapeUpArrow,colorBlue, 0,L, Offset=-45);
//PlotShapes(Short* shapeDownArrow,colorRed, 0,H, Offset=-45);

PlotShapes(Sell*shapeHollowDownArrow,colorPink,0,L ,-45);
//PlotShapes(Cover*shapeHollowUpArrow,colorSkyblue,0 ,H,-45);

/////////////////////////////////// Exploration ///////////////////////
Filter = Buy OR Sell;

/////////// General Columns ////////////////////////
AddTextColumn( FullName( ), "Name" );
AddColumn(C,"Close");
AddTextColumn( MarketID( 1 ), "Market name" );

//////////////// BUY/SELL SIGNALS ///////

AddColumn( IIf(Buy,1,IIf(Sell,-1,Null)) ,"Signal1",1.0,colorWhite,IIf(Buy,colorGreen,IIf(Sell,colorRed,colorWhite)));


//////////////////////////////////// Exploration over ////////////////////////////


thanks a ton to all three gentlemen here.

toughard:)
 

toughard

Well-Known Member
sir in this buy and sell are ok
is it correct for short and cover to complete it? please guide

_SECTION_BEGIN( "Price" );
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", colorRose, styleCandle | styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("ema_crossover");
x = EMA(Close,11);
y = EMA(High,11);
z = EMA(Low,11);
Ph = Ref(High,-1);
PL = Ref(Low,-1);

Plot(EMA(Close,11),"",colorRed,styleLine);
Plot(EMA(Low,11),"",colorPaleGreen,styleLine);
Plot(EMA(High,11),"",colorDarkGreen,styleLine);

BuyX= C>Y ; //AND C>ph;
SellX= C<Z ; //AND C<PL;
Buy = C>O AND H > Ph AND Ref(BuyX, -1);
Sell = C<O AND L < PL AND Ref(SellX, -1);
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
Short = Sell ;
Cover = Buy ;



Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);

PlotShapes(Buy* shapeUpArrow,colorBlue, 0,L, Offset=-45);
PlotShapes(Short* shapeDownArrow,colorRed, 0,H, Offset=-45);

PlotShapes(Sell*shapeHollowDownArrow,colorPink,0,L ,-45);
PlotShapes(Cover*shapeHollowUpArrow,colorSkyblue,0 ,H,-45);

/////////////////////////////////// Exploration ///////////////////////
Filter = Buy OR Sell;

/////////// General Columns ////////////////////////
AddTextColumn( FullName( ), "Name" );
AddColumn(C,"Close");
AddTextColumn( MarketID( 1 ), "Market name" );

//////////////// BUY/SELL SIGNALS ///////

AddColumn( IIf(Buy,1,IIf(Sell,-1,Null)) ,"Signal1",1.0,colorWhite,IIf(Buy,colorGreen,IIf(Sell,colorRed,colorWhite)));


//////////////////////////////////// Exploration over ////////////////////////////
 

Nehal_s143

Well-Known Member
sir in this buy and sell are ok
is it correct for short and cover to complete it? please guide

_SECTION_BEGIN( "Price" );
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", colorRose, styleCandle | styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("ema_crossover");
x = EMA(Close,11);
y = EMA(High,11);
z = EMA(Low,11);
Ph = Ref(High,-1);
PL = Ref(Low,-1);

Plot(EMA(Close,11),"",colorRed,styleLine);
Plot(EMA(Low,11),"",colorPaleGreen,styleLine);
Plot(EMA(High,11),"",colorDarkGreen,styleLine);

BuyX= C>Y ; //AND C>ph;
SellX= C<Z ; //AND C<PL;
Buy = C>O AND H > Ph AND Ref(BuyX, -1);
Sell = C<O AND L < PL AND Ref(SellX, -1);
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
Short = Sell ;
Cover = Buy ;



Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);

PlotShapes(Buy* shapeUpArrow,colorBlue, 0,L, Offset=-45);
PlotShapes(Short* shapeDownArrow,colorRed, 0,H, Offset=-45);

PlotShapes(Sell*shapeHollowDownArrow,colorPink,0,L ,-45);
PlotShapes(Cover*shapeHollowUpArrow,colorSkyblue,0 ,H,-45);

/////////////////////////////////// Exploration ///////////////////////
Filter = Buy OR Sell;

/////////// General Columns ////////////////////////
AddTextColumn( FullName( ), "Name" );
AddColumn(C,"Close");
AddTextColumn( MarketID( 1 ), "Market name" );

//////////////// BUY/SELL SIGNALS ///////

AddColumn( IIf(Buy,1,IIf(Sell,-1,Null)) ,"Signal1",1.0,colorWhite,IIf(Buy,colorGreen,IIf(Sell,colorRed,colorWhite)));


//////////////////////////////////// Exploration over ////////////////////////////
Short and cover is already coded in above afl
 

toughard

Well-Known Member
thanks nihal sir

i just wanted the node form you on its accuracy.

thanks
 

Similar threads