Simple Coding Help - No Promise.

Nehal_s143

Well-Known Member
hi

garyc1st sir & mastermind007 sir, please cool down, be friendly :)
this thread is giving lot of lesson to beginners like me, thanks for your support and knowledge and all posts till now and in future :)
 
Mastermind, and you could use Cross instead of greater-than sign and less-than sign. Well, multiple roads lead to Rome.

Yes, Gary both alternatives would identify the to same bar.

I like your first version better

Thanks for contributing!
 
Well, I don't need to look back many pages as there was no context mentioned in his post or picture but just a picture! It is not my job to search for context! And I have not looked closely at that picture. Why should I do that? But now I did so and have seen that hhv and llv are included in valuewhen( sig, hhv) so it is not needed to use ref here as it is not including current bar's high.
Gary,

Of what use is your knowledge and your ability, if you are unable to understand the context?
Of what use is your reading skills and scrolling ability, if you can't read the text'd image?
Of what use is your AFL creating skills, if you can't create AFL that has a little chance of making money?
Of what use is you calling yourself garyc1st when you yourself can't see?

Since you did not see, the ValueWhen phrase is present in the very image from which you decided to suggest solution of backward Ref. Yes!!! the very same image that you downloaded and then reposted again....

Nonsense. I'm allowed calling guys like him comedians since I have the knowledge and he doesn't have it and he wants to suck info from others like me for free and at the same time expects those ones who have the knowledge to do additional typing work.

BTW here is the solution. And I'm using picture mode also. My return favour.



PS: How long did it take you to find the solution?
Hurry, the picture will not stay for long.

Here is the proof that limiting the number of the entry signals actually works.
You are one heck of a person, Gary!!!!! Just to retain the right to denigrate someone, you type (cut-paste) his code, offer a solution with snide remarks.

Incidentally your solution may appear correct, but is actually wrong ...

Then, just to harass someone and prove some useless point, you use your superior (???) knowledge to again paste an image

I don't know how you've made money in your life but market seems to be the least likely of the places and your bitterness is pouring out by gallons!!!

Traderji site has no use of a person like you!!

Therefore, with whatever little right I have at TJ, I declare: GARYC1ST, YOU ARE FIRED!!!!

Those who agree with me can endorse this declaration by thanking this post!! Please do not post any more comments on this topic or requote me or Gary otherwise this thread snowball into something else

P.S. I feel that I owe some apology is Happy Singh and to TJ admins... So Praaji, Sirji ... maaf karna!!
 
Last edited:
Gary,

Of what use is your knowledge and your ability, if you are unable to understand the context?
Of what use is your reading skills and scrolling ability, if you can't read the text'd image?
Of what use is your AFL creating skills, if you can't create AFL that has a little chance of making money?
Of what use is you calling yourself garyc1st when you yourself can't see?

Since you did not see, the ValueWhen phrase is present in the very image from which you decided to suggest solution of backward Ref. Yes!!! the very same image that you downloaded and then reposted again....



You are one heck of a person, Gary!!!!! Just to retain the right to denigrate someone, you type (cut-paste) his code, offer a solution with snide remarks.

Incidentally your solution may appear correct, but is actually wrong ...

Then, just to harass someone and prove some useless point, you use your superior (???) knowledge to again paste an image

I don't know how you've made money in your life but market seems to be the least likely of the places and your bitterness is pouring out by gallons!!!

Traderji site has no use of a person like you!!

Therefore, with whatever little right I have at TJ, I declare: GARYC1ST, YOU ARE FIRED!!!!

Those who agree with me can endorse this declaration by thanking this post!! Please do not post any more comments on this topic or requote me or Gary otherwise this thread snowball into something else

P.S. I feel that I owe some apology is Happy Singh and to TJ admins... So Praaji, Sirji ... maaf karna!!
Have you entered insane mode? Big - bigger - stupid. Interesting! :)

I'll say it again it is not my job to look for context. It is not my job to look at images carefully. I read this hilarious forum in my leisure time because I'm allowing myself to read whenever I want to and I decide how careful and how seriously I want to look or reply or taking part in it. And in the same way a guy just posts an image the same way I can deny a careful look/reply to him or deny a correct answer, you tremendous comedian. It is not business here. It is a suckers place mainly.

I downloaded an image? No, I reposted an image to reply the first time to you. You know you just click a reply button, just in case you don't know. Reposting an image doesn't need a careful look at it. So to repeat it in case you still don't understand, it is not my job to carefully look at images or give a correct answer. I can decide myself to look more carefully or to give a correct answer whenever I want to because it is a suckers place where laziness rules. I can stop at whatever point I want to. Because in democracy (or here it is rather in democrazy) I'm allowed to be lazy too just like the majority is allowed to do so. I'm not the one who is desperate for getting info without doing anything himself. If you think that this is not true in regards to the very large majority of people here then you are even more laughable then I thought after your last post.

As for that particular case I've only decided to look more careful at it when you posted to my suggestion to him. Then I got more interested in it because it transformed into a challenge. Yes, I can do change my mind whenever I want to because I'm not a sucker, I'm a decision maker.

The first time I commented to your post about a guy who just posts an image with code and who was expecting to get help from others just by using his image. And I called him a comedian because he is part of majority of people here.

As for knowledge, what is your knowledge if you write redundant lengthy code lines of a first grader that can be written in ONE LINE! ONE LINE like pros do!!
As for Ref(), I have explained when it would be needed.

Just compare

Buy = High > HHV( High, 30 );
Sell = Low < LLV( Low, 30 );

with

Buy = High > Ref( HHV( High, 30 ), -1 );
Sell = Low < Ref( LLV( Low, 30 ), -1 );

and see what will happen. So actually it was a constructive reply to think about or to try because it doesn't have to be related to anything. Read again my first reply. It didn't mention anything about being a solution to that code. I posted that one because I stopped to look further at the image after seeing those line containing HHV and LLV. Why did I stop? Because I can and because I'm a decision maker!

What's writing code and solving solution got to do with chances making money? Well, at least I'm showing and proving that I can solve problems on my own so my chances of surviving anything are higher than the chances of the majority of people here who are just dependently sucking out others instead of using their own brain once in a life time.

"Incidentally your solution may appear correct, but is actually wrong ..."
Do you even know what you are talking about? As far as I can see the guy was just screaming for help and highlighting many signals in his image. Correct or wrong? So what was the sucker most probably looking for since he wasn't explicitly mentioning a problem but just highlighting something? What is the opposite of many signals? From my understanding he was looking for removing entry signals. That's what the code of my image is doing. It just uses the first occurring entry signal. Besides that I have shortened your first grade code to a more professional one. Whether the code makes sense in regards to using it for real-time trading is not my problem or whether it makes any sense at all is none of my business. It was challenge to remove signals because he was highlighting many signals. Nothing more nothing less.

I'm repeating it again to you. I can re-post or not re-post an image and can decide whatever to do with an image because I am in control of it. I'm holding the reins. What is my point? Maybe once one of those suckers will think about using his own brain more often than others at some point in time instead of continuously being dependent on others who are in a very small minority. If there would be even one sucker who would re-think then I would have won.

I'm fired from what? I'm my own boss because I have a brain that I am able to use whenever I need to. So your sentence doesn't make any sense at all.

BTW look at who thanked you - the number one sucker of every forum that exists in the whole wide Internet. FORD7K. The number one code sucker and code and software pirate of this forum and of many others. The one who has no respect for others work but just steals it without their allowance. You can be grateful to have such an idiot on your side of the fence. One idiot deserves another one. Ha ha ha ha! And I have such joy and fun to make fun of such suckers and criminals.

"Those who agree with me can endorse this declaration by thanking this post!!"

How pathetic is that. You know what? I once had a higher opinion of you before this post and especially before this sentence. But that part is just pathetic. Screaming for agreement like a little child. Boooh. Big fail! So not cool, you know. ;-)

PS: Yes, I'm one heck of a guy and I'm proud to be me and I'm so proud of a brain being that large like my one! And I'm so very proud of not being a sucker!
 
As for Ref(), I have explained when it would be needed.

Just compare

Buy = High > HHV( High, 30 );
Sell = Low < LLV( Low, 30 );

with

Buy = High > Ref( HHV( High, 30 ), -1 );
Sell = Low < Ref( LLV( Low, 30 ), -1 );

and see what will happen. So actually it was a constructive reply to think about or to try
Or just plot this and change lookback variable from 1 to 0.

Lookback = 1;
Plot( ValueWhen( H > Ref( HHV( H, 10 ), -Lookback ), H ), "HHV", colorRed, styleLine );

Then re-read AmiBroker's help file

SYNTAX hhv( ARRAY, periods )
RETURNS ARRAY
FUNCTION Calculates the highest value in the ARRAY over the preceding periods (periods includes the current day). HHV accepts periods parameter that can be constant as well as time-variant (array).
EXAMPLE The formula "hhv( close, 4)" returns the highest closing price over the preceding four periods; "hhv( high, 8)" returns the highest high price over the preceding eight periods.
to understand why there is no plot for the case of lookback = 0;
 
_SECTION_BEGIN("Tops-Bottoms-2-3's");
xx=BarIndex();x=xx;Lx=LastValue(x);
nbar=3;
fc=2;
frat=3;
t=H>Ref(HHV(H,frat),-1) AND Ref(HHV(H,frat),frat)<H;
PHighPrice0=ValueWhen(t,H);
b=L<Ref(LLV(L,frat),-1) AND Ref(LLV(L,frat),frat)>L;
PLowPrice0=ValueWhen(b,L);
p=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;
d=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;
pk=t OR p; tr=b OR d;

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
px3=ValueWhen(pk,x,3); tx3=ValueWhen(tr,x,3);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
ph3=ValueWhen(pk,H,3); tl3=ValueWhen(tr,L,3);

Disp2=ParamToggle("Display 2-3's Labels","Show|Hide",1);

Disp3=ParamToggle("Color Labels Behind 2-3's","Show|Hide",1);
if(Disp3){
PlotShapes(shapeSquare*tr,IIf(Lx-ValueWhen(tr,x)>nbar,colorLime,colorCustom1),0,L,-10);
PlotShapes(shapeSquare*pk,IIf(Lx-ValueWhen(pk,x)>nbar,ColorRGB(255,160,122),colorCustom1),0,H,10);}

dxhm=14; dxlm=10;dxh=3;dxl=2;dyhm=5;
dylm=3;dyh=5;dyl=15;hm=30;lm=30;
function GetVisibleBarCount()
{
lvb=Status("lastvisiblebar");
fvb=Status("firstvisiblebar");
return Min(lvb-fvb,BarCount-fvb);
}
function GfxConvertPixelsToBarX(Pixels)
{
lvb=Status("lastvisiblebar");
fvb=Status("firstvisiblebar");
pxchartleft=Status("pxchartleft");
pxchartwidth=Status("pxchartwidth");
fac=pxchartwidth/Pixels;
bar=(lvb-fvb)/fac;
return bar;
}
function GfxConvertPixelToValueY(Pixels)
{
local Miny,Maxy,pxchartbottom,pxchartheight;
Miny=Status("axisminy");
Maxy=Status("axismaxy");
pxchartbottom=Status("pxchartbottom");
pxchartheight=Status("pxchartheight");
fac=pxchartheight/Pixels;
Value=(Maxy-Miny)/fac;
return Value;}

if(Disp2)
{
ll=tr AND tl1<tl2; hl=tr AND tl1>tl2; hh=pk AND ph1>ph2;
lh=pk AND ph1<ph2; dt=pk AND ph1==ph2; db=tr AND tl1==tl2;

miny=Status("axisminy");
maxy=Status("axismaxy");
AllVisibleBars=GetVisibleBarCount();
fvb=Status("firstvisiblebar");
LowMargin=Miny+GfxConvertPixelToValueY(lm);
HighMargin=Maxy-GfxConvertPixelToValueY(hm);
dyllm=GfxConvertPixelToValueY(dylm);
dyhhm=GfxConvertPixelToValueY(dyhm);
dyll=GfxConvertPixelToValueY(dyl);
dyhh=GfxConvertPixelToValueY(dyh);
dxllm=GfxConvertPixelsToBarX(dxlm);
dxhhm=GfxConvertPixelsToBarX(dxhm);
dxll=GfxConvertPixelsToBarX(dxl);
dxhh=GfxConvertPixelsToBarX(dxh);

for(i=0;i<AllVisibleBars;i++)
{
if(ll[i+fvb] AND L[i+fvb]>LowMargin) PlotText("Buy",i+fvb+dxll,L[i+fvb]-dyll,colorBlack);
if(ll[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("Buy",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorBlack);
if(hl[i+fvb] AND L[i+fvb]>LowMargin) PlotText("Buy",i+fvb+dxll,L[i+fvb]-dyll,colorBlack);
if(hl[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("Buy",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorBlack);
if(db[i+fvb] AND L[i+fvb]>LowMargin) PlotText("Buy",i+fvb+dxll,L[i+fvb]-dyll,colorBlack);
if(db[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("Buy",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorBlack);
if(hh[i+fvb] AND H[i+fvb]<HighMargin) PlotText("Sell",i+fvb+dxhh,H[i+fvb]+dyhh,colorBlack);
if(hh[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("Sell",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorBlack);
if(lh[i+fvb] AND H[i+fvb]<HighMargin) PlotText("Sell",i+fvb+dxhh,H[i+fvb]+dyhh,colorBlack);
if(lh[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("Sell",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorBlack);
if(dt[i+fvb] AND H[i+fvb]<HighMargin) PlotText("Sell",i+fvb+dxhh,H[i+fvb]+dyhh,colorBlack);
if(dt[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("Sell",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorBlack);
}}

_SECTION_END();

_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

pls help me to plot the daily time signals in 5 min time frame
 
mehtaka

Code:
	md = IIf((Month()==9 OR Month()==4 OR Month()==6 OR Month()==11), 30, IIf(Month()==2, 28 + (Year()%4 == 0 AND Year()%100!=0), 31));
	expiry = ((md == Day()) AND (DayOfWeek() >= 1) AND (DayOfWeek() <= 5)) OR ((md - Day() <= 2) AND (DayOfWeek() == 5));
	PlotShapes(expiry * shapeDigit1, colorBlack);
The expiry variable identifies the last working day of a month (assuming Mon-Friday week). It does not factor in Holidays. Shape is only for verification purposes; Use this expiry variable to adjust your buy / sell / short / cover signals
 
pls help me to plot the daily timeframe signals in 5 min time frame

_SECTION_BEGIN("Tops-Bottoms-2-3's");
xx=BarIndex();x=xx;Lx=LastValue(x);
nbar=3;
fc=2;
frat=3;
t=H>Ref(HHV(H,frat),-1) AND Ref(HHV(H,frat),frat)<H;
PHighPrice0=ValueWhen(t,H);
b=L<Ref(LLV(L,frat),-1) AND Ref(LLV(L,frat),frat)>L;
PLowPrice0=ValueWhen(b,L);
p=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;
d=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;
pk=t OR p; tr=b OR d;

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
px3=ValueWhen(pk,x,3); tx3=ValueWhen(tr,x,3);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
ph3=ValueWhen(pk,H,3); tl3=ValueWhen(tr,L,3);

Disp2=ParamToggle("Display 2-3's Labels","Show|Hide",1);

Disp3=ParamToggle("Color Labels Behind 2-3's","Show|Hide",1);
if(Disp3){
PlotShapes(shapeSquare*tr,IIf(Lx-ValueWhen(tr,x)>nbar,colorLime,colorCustom1),0,L,-10);
PlotShapes(shapeSquare*pk,IIf(Lx-ValueWhen(pk,x)>nbar,ColorRGB(255,160,122),colorCu stom1),0,H,10);}

dxhm=14; dxlm=10;dxh=3;dxl=2;dyhm=5;
dylm=3;dyh=5;dyl=15;hm=30;lm=30;
function GetVisibleBarCount()
{
lvb=Status("lastvisiblebar");
fvb=Status("firstvisiblebar");
return Min(lvb-fvb,BarCount-fvb);
}
function GfxConvertPixelsToBarX(Pixels)
{
lvb=Status("lastvisiblebar");
fvb=Status("firstvisiblebar");
pxchartleft=Status("pxchartleft");
pxchartwidth=Status("pxchartwidth");
fac=pxchartwidth/Pixels;
bar=(lvb-fvb)/fac;
return bar;
}
function GfxConvertPixelToValueY(Pixels)
{
local Miny,Maxy,pxchartbottom,pxchartheight;
Miny=Status("axisminy");
Maxy=Status("axismaxy");
pxchartbottom=Status("pxchartbottom");
pxchartheight=Status("pxchartheight");
fac=pxchartheight/Pixels;
Value=(Maxy-Miny)/fac;
return Value;}

if(Disp2)
{
ll=tr AND tl1<tl2; hl=tr AND tl1>tl2; hh=pk AND ph1>ph2;
lh=pk AND ph1<ph2; dt=pk AND ph1==ph2; db=tr AND tl1==tl2;

miny=Status("axisminy");
maxy=Status("axismaxy");
AllVisibleBars=GetVisibleBarCount();
fvb=Status("firstvisiblebar");
LowMargin=Miny+GfxConvertPixelToValueY(lm);
HighMargin=Maxy-GfxConvertPixelToValueY(hm);
dyllm=GfxConvertPixelToValueY(dylm);
dyhhm=GfxConvertPixelToValueY(dyhm);
dyll=GfxConvertPixelToValueY(dyl);
dyhh=GfxConvertPixelToValueY(dyh);
dxllm=GfxConvertPixelsToBarX(dxlm);
dxhhm=GfxConvertPixelsToBarX(dxhm);
dxll=GfxConvertPixelsToBarX(dxl);
dxhh=GfxConvertPixelsToBarX(dxh);

for(i=0;i<AllVisibleBars;i++)
{
if(ll[i+fvb] AND L[i+fvb]>LowMargin) PlotText("Buy",i+fvb+dxll,L[i+fvb]-dyll,colorBlack);
if(ll[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("Buy",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorBlack);
if(hl[i+fvb] AND L[i+fvb]>LowMargin) PlotText("Buy",i+fvb+dxll,L[i+fvb]-dyll,colorBlack);
if(hl[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("Buy",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorBlack);
if(db[i+fvb] AND L[i+fvb]>LowMargin) PlotText("Buy",i+fvb+dxll,L[i+fvb]-dyll,colorBlack);
if(db[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("Buy",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorBlack);
if(hh[i+fvb] AND H[i+fvb]<HighMargin) PlotText("Sell",i+fvb+dxhh,H[i+fvb]+dyhh,colorBlack);
if(hh[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("Sell",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorBlack);
if(lh[i+fvb] AND H[i+fvb]<HighMargin) PlotText("Sell",i+fvb+dxhh,H[i+fvb]+dyhh,colorBlack);
if(lh[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("Sell",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorBlack);
if(dt[i+fvb] AND H[i+fvb]<HighMargin) PlotText("Sell",i+fvb+dxhh,H[i+fvb]+dyhh,colorBlack);
if(dt[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("Sell",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorBlack);
}}

_SECTION_END();

_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
 

Similar threads