Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

nab999

Help Needed For Indicator

Recommended Posts

Hi,

 

I am running a show me on TS 8.6.

 

The idea is that it will plot a show me when both the fast and slow averages are pointing up, when on the previous bar, either the fast or slow average were not pointing up.

 

The problem I am having is that once a show me is plotted, further plots are made, which I do not want, I only want the plot when both averages are pointing up, when on the previous bar either one or the other were not pointing up, then i do not want any further plots until at some time in the future, the obove occurs again.

 

I attach a chart, with arrows showing where the plots should be, as the show me, which as you can see in not plotting correctly.

 

Below is the code that I have.

 

Many thanks for all your continued help guys.

 

inputs:

fastLength(5),

slowLength(10),

BEx(0.5);

 

Var:

longTrigger(false),

longTriggerValue(0),

fastValue(0),

slowValue(0);

 

Value1=LOW ;

 

fastValue = Average( Close, fastLength );

slowValue = Average( Close, slowLength );

 

if fastvalue<=fastvalue[1] or slowValue <= slowValue[1] then

longTrigger = false;

 

 

If FastValue>FastValue[1] and slowvalue>slowvalue[1]

and close>open then longTrigger = true;

 

longTriggerValue = High +( range * BEx );

 

if longTrigger=true then Plot1(Value1);

If longtrigger=true then Plot2(LongTriggerValue);

Screenshot.thumb.gif.e881eaff3ed846d5b651525946487939.gif

Share this post


Link to post
Share on other sites

if you wrap your indicator in Code Tag (the # icon at the top of the reply window),

you codes will be enclosed in a easy-to-read code window.

Edited by Tams

Share this post


Link to post
Share on other sites
...

The idea is that it will plot a show me when both the fast and slow averages are pointing up, when on the previous bar, either the fast or slow average were not pointing up.

....

 

 

my suggestion:

 

Write out your ideas:

ONE thought at a time,

ONE logic at a time,

ONE action at a time,

ONE LINE PER PHRASE,

ONE phrase per sentence

ONE LINE per sentence...

 

if you have more than one thought in the same sentence, you are cooked.

if you have more than one phrase in the same line, you are cooked.

 

write it as if you were writing the code,

write it as if the machine is reading it... one line at a time, one action at a time.

 

if you can do that... you will see your coding solution easily.

Edited by Tams

Share this post


Link to post
Share on other sites

Hi Tams, sorry about the code box, I hit the quote box my mistake.

 

I have put it down as you suggested, i.e. the code that almost works is shown....

 

The problem I have is that it is not producing the results that I want, as explained in my initial post. I am not a very good easy language coder at all, and can not get any further with it myself, hence my request for some help.

Share this post


Link to post
Share on other sites
...

I have put it down as you suggested....

 

 

but I don't see what you wrote...

can't help you if I don't see it.

 

writing out the thoughts line by line is a way to

line up your logic

 

computers are very stupid,

it can only do what you tell it to do.

 

your instruction has to be direct and complete

for the computer to do what you want to do

 

if the computer is not doing what you want to do,

there is only one explanation:

your logic is incomplete

 

i.e. you haven't got all the bases covered.

 

 

 

p.s. it is good that you have posted a chart,

you need to write some notes on the chart to

point out what is wrong with the picture.

You can also draw some lines and arrows and notes

to illustrate what you have in mind.

Edited by Tams

Share this post


Link to post
Share on other sites

Set longtrigger=false right at the start of your code or

 

where you have the if statement add else false.

 

If FastValue>FastValue[1] and slowvalue>slowvalue[1]

and close>open then longTrigger = true

else

longtrigger = false;

Share this post


Link to post
Share on other sites
The idea is that it will plot a show me when both the fast and slow averages are pointing up, when on the previous bar, either the fast or slow average were not pointing up.

 

Does this mean you want a slope calculation on the plots? So you want to know when some point A followed by point B is negative in slope and then point C is positive in slope for two separate averages?

 

As an example data set:

 

------------ Avg1 -------- Avg2

Time1 -- 12 ---------- 10

Time2 -- 10 ---------- 9

Time3 -- 11 ---------- 10

 

In the above, each average moves down from Time1 to Time2 then up from Time2 to Time3 but they do not cross in this example data set here.

 

I do this with crossing action, but not for slope change ... so curious exactly what you're asking, just to be clear :-)

Share this post


Link to post
Share on other sites

Hi MrTraderGuy

 

Yes, what I am looking for is a Bar A followed by Bar B Formation....

 

At Bar A either the fast or the slow average have a slope that is either down or level.

 

At Bar B the slope of both the fast and slow averages are up, so on this bar the show me plot would be made.

 

No further plots are made until a new bar A followed by a new bar B formation is made.

 

Many thanks.

Share this post


Link to post
Share on other sites

Did my suggestion not work? It should have done if the question was correctly expressed in your original post.

 

Once you trigger true nothing in your code ever resets back to false. Either always reset to false at the start of your code -or- have an else clause where you test your conditions. The former will just show the bar that transitions from false to true the latter will show all bars that meet the condition. Simple logic error.

 

Problem solved as far as I can see.

Share this post


Link to post
Share on other sites

At Bar A either the fast or the slow average have a slope that is either down or level.

 

At Bar B the slope of both the fast and slow averages are up, so on this bar the show me plot would be made.

 

No further plots are made until a new bar A followed by a new bar B formation is made.

 

A) OK, so the setup (assuming TS 8.6) is a symbol with at least three data series:

[1]Symbol, [2] Slow Stochs, [3] Fast Stochs.

--> Note: I do expect the data series to be in the right place; I don't error check on this since I write stuff for myself and keep all my setups correct by hand :-)

 

B) So you're looking for divergence between data series [2] & [3] then, from what I read above.

 

C) The main condition is that both lines in [2] are flat or down and both lines in [3] are up.

 

D) Crossing of the lines is not relevant here; just [2] both flat/down and [3] up at the same time.

 

E) The processing of the conditions does not occur intra-bar, only on closed bars.

 

Is this correct? I'm rebuilding some code now that was lost during a BlueScreen this morning, so since most of this is the same as what I have, I'll post what I have later and you can use it if you want or can change it to whatever you need.

 

MTG

Share this post


Link to post
Share on other sites
Did my suggestion not work? It should have done if the question was correctly expressed in your original post.

 

Once you trigger true nothing in your code ever resets back to false. Either always reset to false at the start of your code -or- have an else clause where you test your conditions. The former will just show the bar that transitions from false to true the latter will show all bars that meet the condition. Simple logic error.

 

 

that's why I insist on people writing out their thoughts,

instead of jumping into coding immediately.

 

 

Problem solved as far as I can see.

 

 

I really don't care if he solved the problem...

some people only want a quick fix. As far as I am concerned, the "problem" is not in the logic.

Share this post


Link to post
Share on other sites

Thats not what he said Mr T G, he simply wants a mark when two moving avergaes ( a fast and a slow) both turn up. Single data series, no stochs, no divergences, unless I mis read the original post and code.

 

this will probably do it though I have simply modified your original code so might not be the most elegant way of doing it.

 

inputs:
fastLength(5),
slowLength(10),
BEx(0.5);

Var:
longTrigger(false),
longTriggerValue(0),
fastValue(0),
slowValue(0);

longTrigger = false;
Value1=LOW ;

fastValue = Average( Close, fastLength );
slowValue = Average( Close, slowLength );

if fastvalue[1]<=fastvalue[2] or slowValue[1] <= slowValue[2] then {where previous MA's down?}
 If FastValue>FastValue[1] and slowvalue>slowvalue[1]               {if so check if current MA is up}
    and close>open then longTrigger = true;


if longTrigger=true then
begin
 longTriggerValue = High +( range * BEx );

 Plot1(Value1);
 Plot2(LongTriggerValue);
end;

 

Cant remember whether braces are EL comments or a MC extension might have to change those.

Share this post


Link to post
Share on other sites
that's why I insist on people writing out their thoughts,

instead of jumping into coding immediately.

 

I really don't care if he solved the problem...

some people only want a quick fix. As far as I am concerned, the "problem" is not in the logic.

 

Actually that was why I tried to help compared t0o many posters he did a reasonable job of describing what he was trying to do :D. He posted some code that he had taken a stab at, reasonably clearly described what he was trying to do and posted a chart with an illustration of how it looked and how it should look. Compared to many of the "please help" posts a zillion miles ahead ! :) I think (though I may be mistaken) there was enough information in the original post to provide a solution. Time will tell I guess!

 

Having said that your advice was spot on for him finding the solution for himself.

Share this post


Link to post
Share on other sites

I agree with you both, (BFish/Tams) ... it could be just a quick fix need, but I don't really like to try to do quick-fix as it always seems to effect other things and make other problems.

 

Start simple, test, expand, test, etc. is my motto :-)

 

Anyway, since I have a similar indicator, just offering to share/help as best I can; not necessarily fix anything existing ... just giving back what I can as I get help from time-to-time as well. I'm not claiming anyone, myself included, right or wrong; just providing options :-)

Share this post


Link to post
Share on other sites

the problem is...

most wishful thinkers write in mumble jumbles...

 

 

writing out their fantasy is easy,

but until people can write out their "wishes" one thought/one line at a time...

the codes will be mumble jumble too.

 

I have yet to be proven wrong on that.

 

;-)>

Edited by Tams

Share this post


Link to post
Share on other sites

Mr T G, You can often learn something new by how others approach problem. There was a great thread "plotting globex highs and lows" or something similar. What was good about it is that several methods to do it where presented, some from fairly novice coders. Anyway reading back my post sounds unduly critical that was not my intention, apologies.

Share this post


Link to post
Share on other sites
Actually that was why I tried to help compared t0o many posters he did a reasonable job of describing what he was trying to do :D. He posted some code that he had taken a stab at, reasonably clearly described what he was trying to do and posted a chart with an illustration of how it looked and how it should look. Compared to many of the "please help" posts a zillion miles ahead ! :) I think (though I may be mistaken) there was enough information in the original post to provide a solution. Time will tell I guess!

 

Having said that your advice was spot on for him finding the solution for himself.

 

 

I agree that he did a reasonable job of trying...

especially posting his work-in-progress. (I give credit to that... some people are too shy to post)

 

If he had written out his thoughts one line at a time in this format:

 

IF...

THEN...

ELSE...

 

he would have avoided the error.

 

 

 

 

p.s. I think he had solved the problem already...

This is a simple bug, you have given him the clue he needed. it is not that difficult to spot the fault once he thinks it through.

In an anonymous forum, some people just don't have the habit of acknowledging help.

Edited by Tams

Share this post


Link to post
Share on other sites

Besides the advice that Tams gave about writing out your rules in English in advance, I would also suggest that you always include some print statements for use during debugging. An example is shown below:

 

Print(ELDATETOSTRING(Date), " ", Time, " LongTrigger: ", LongTrigger, " LongTriggerValue: ", longtriggervalue, " Fastvalue: ", fastvalue, " Slowvalue: ", slowvalue, " A");

 

The idea is to print out the current values of important variables on each bar. These print out to the Easylanguage output bar, which can be automatically saved to a file upon exit. Each one shows the date and time of the bar plus the variables required. Note that I have also included a reference "A" at the end, because you might want to insert the same print statement at different points in your logic to see how the variables change as the code is processed. By using a different reference for each print statement you can see exactly which part of the code triggers any changes in values.

 

Normally this will highlight any problems with your logic. Logic/coding problems are IMHO the normal cause of funny results, rather than TS technical issues.

 

It can be useful also to have an input at the start of the statement, something like:

 

Inputs:

Print_On("N");

 

Then you can add a line before the print statement:

 

If Print_On = "Y" then print(message that needs to be printed);

 

This allows you to turn the printing on or off during run-time by changing the input.

 

Charlton

Share this post


Link to post
Share on other sites
Mr T G, You can often learn something new by how others approach problem. There was a great thread "plotting globex highs and lows" or something similar. What was good about it is that several methods to do it where presented, some from fairly novice coders. Anyway reading back my post sounds unduly critical that was not my intention, apologies.

 

No worries, I agree BFish, that's why I just provide options and take nothing personally :-) I've coded in other areas for years, and yet find myself in a new category every day! The only thing we know for sure is that we don't know everything!

 

Always happy to help where I can and learn everything along the way :-) OK, I'm back to work!

Share this post


Link to post
Share on other sites

Hi, and many thanks to you all for all your help with this so far.

 

Blowfish, I put the code, exactly as you posted into ts and ran it on GBPUSD 5 min data.

 

I attach 3 charts which are showing the problems I am having with this show me. ( Also plotted are the fast and slow moving averages ( the thick ones ) which change to green when both the slow and fast MAs are pointing up. )

 

I have market the charts with lines and put text at the places that the problems are ocurring, to make things easier to see, as previously suggested by Tams.

 

Once again, many thanks for all your help.

5aa70f6f72b5e_ScreenHunter_01Nov_2910_34.thumb.gif.7a6d78a9c94e308b9744f4cf3603c2e7.gif

5aa70f6f7ec76_ScreenHunter_02Nov_2910_35.thumb.gif.48b57c3b6006853d04fd7c206b89310f.gif

5aa70f6f8604f_ScreenHunter_03Nov_2910_37.thumb.gif.1754569163b4a34ecd134d0e13cccd2d.gif

Share this post


Link to post
Share on other sites

You did not say WHY this is plotting correctly.

What is your criteria that makes it "correct"?

What should the chart do if the criteria is not met ???

 

What about the "incorrect" plot?

What is your criteria it did not make that renders it "incorrect"?

What should the chart do if the criteria is not met ???

 

You might have described your codes in one post or anther,

but don't expect people to look for that section of code...

because that code is "wrong"... it is not producing the effect you want, how can people match that section of code to this picture????

I see lots of lines... do you know which line is which?

Do you know what variables you are evaluating against which?

I don't.

 

 

Can you see that your thoughts are not cohesively articulated

and the logic description are incomplete?

Computers are dumb. They can only do what you tell it to do.

If your logic is incomplete, so is the computer's action.

 

 

If you are looking a solution... this is the place you really have to make an effort to cover all the bases...

So far I only see you swimming around in shallow water...

 

 

15983d1259491611-help-needed-indicator-screenhunter_01-nov.-29-10.34.gif

Edited by Tams

Share this post


Link to post
Share on other sites

ThanX TAMS 2 write 18 lines 2 repeat it again & again

 

This is what I've leanred from TAMS

 

2 B clear

 

First in my head 4 my personnal work

 

Then 4 the others 2 receive the correct answer

 

But The road is hard...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Topics

  • Posts

    • Date: 22nd November 2024.   BTC flirts with $100K, Stocks higher, Eurozone PMI signals recession risk.   Asia & European Sessions:   Geopolitical risks are back in the spotlight on fears of escalation in the Ukraine-Russia after Russia reportedly used a new ICBM to retaliate against Ukraine’s use of US and UK made missiles to attack inside Russia. The markets continue to assess the election results as President-elect Trump fills in his cabinet choices, with the key Treasury Secretary spot still open. The Fed’s rate path continues to be debated with a -25 bp December cut seen as 50-50. Earnings season is coming to an end after mixed reports, though AI remains a major driver. Profit taking and rebalancing into year-end are adding to gyrations too. Wall Street rallied, led by the Dow’s 1.06% broadbased pop. The S&P500 advanced 0.53% and the NASDAQ inched up 0.03%. Asian stocks rose after  Nvidia’s rally. Nikkei added 1% to 38,415.32 after the Tokyo inflation data slowed to 2.3% in October from 2.5% in the prior month, reaching its lowest level since January. The rally was also supported by chip-related stocks tracked Nvidia. Overnight-indexed swaps indicate that it’s certain the Reserve Bank of New Zealand will cut its policy rate by 50 basis points on Nov. 27, with a 22% chance of a 75 basis points reduction. European stocks futures climbed even though German Q3 GDP growth revised down to 0.1% q/q from the 0.2% q/q reported initially. Cryptocurrency market has gained approximately $1 trillion since Trump’s victory in the Nov. 5 election. Recent announcement for the SEC boosted cryptos. Chair Gary Gensler will step down on January 20, the day Trump is set to be inaugurated. Gensler has pushed for more protections for crypto investors. MicroStrategy Inc.’s plans to accelerate purchases of the token, and the debut of options on US Bitcoin ETFs also support this rally. Trump’s transition team has begun discussions on the possibility of creating a new White House position focused on digital asset policy.     Financial Markets Performance: The US Dollar recovered overnight and closed at 107.00. Bitcoin currently at 99,300,  flirting with a run toward the 100,000 level. The EURUSD drifts below 1.05, the GBPUSD dips to June’s bottom at 1.2570, while USDJPY rebounded to 154.94. The AUDNZD spiked to 2-year highs amid speculation the RBNZ will cut the official cash rate by more than 50 bps next week. Oil surged 2.12% to $70.46. Gold spiked to 2,697 after escalation alerts between Russia and Ukraine. Heightened geopolitical tensions drove investors toward safe-haven assets. Gold has surged by 30% this year. Haven demand balanced out the pressure from a strong USD following mixed US labor data. Silver rose 0.9% to 31.38, while palladium increased by 0.9% to 1,040.85 per ounce. Platinum remained unchanged. Always trade with strict risk management. Your capital is the single most important aspect of your trading business.   Please note that times displayed based on local time zone and are from time of writing this report.   Click HERE to access the full HFM Economic calendar.   Want to learn to trade and analyse the markets? Join our webinars and get analysis and trading ideas combined with better understanding of how markets work. Click HERE to register for FREE!   Click HERE to READ more Market news. Andria Pichidi HFMarkets Disclaimer: This material is provided as a general marketing communication for information purposes only and does not constitute an independent investment research. Nothing in this communication contains, or should be considered as containing, an investment advice or an investment recommendation or a solicitation for the purpose of buying or selling of any financial instrument. All information provided is gathered from reputable sources and any information containing an indication of past performance is not a guarantee or reliable indicator of future performance. Users acknowledge that any investment in FX and CFDs products is characterized by a certain degree of uncertainty and that any investment of this nature involves a high level of risk for which the users are solely responsible and liable. We assume no liability for any loss arising from any investment made based on the information provided in this communication. This communication must not be reproduced or further distributed without our prior written permission.
    • A few trending stocks at support BAM MNKD RBBN at https://stockconsultant.com/?MNKD
    • BMBL Bumble stock watch, pull back to 7.94 support area with high trade quality at https://stockconsultant.com/?BMBL
    • LUMN Lumen Technologies stock watch, pull back to 7.43 support area with bullish indicators at https://stockconsultant.com/?LUMN
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.