General Topics
Markets
Technical Topics
Brokerage Firms
Company Specific
Community Lounge
Site Support

# Amibroker

Discussion in 'Trading Software' started by wajo111, Mar 1, 2019.

1. ### wajo111

Hello everyone,

I am simply trying to create a BUY signal when the current bar CLOSES 50% or below from the previous bar.

I thought maybe averaging out the previous bar might work but I'm so lost. hoping someone can help please.

Buy = Ref ((h - l)/ L ,-1)*100;

2. ### Metamega

https://forum.amibroker.com/

You’ll find quicker help there however your question is a bit confusing to me. 50 percent of what? The close? The previous bars range?

Also “buy” will accept Boolean statement so true/false ( 1 or O).

On my phone here so this is just pseudo code, you’d want something like

3. ### mushinseeker

yes.. that Buy resolves to a scalar not a boolean. If IBM hi/lo is 50,49... then your statement is
I assume you wanna do something like moving avg. so you need to create a cus indicator then do something like
buy =( ma_10day )> ref(close,-1) this resolves to a 0 or 1.Ami is an amazing prod BUT has a steep learning curve.

4. ### wajo111

Hello, thank-you for the insight. But it still won't work sorry.
I tried buy = C < Ref((H - L)/2, -1) ;

I uploaded image showing the problem. Thank-you for helping.

File size:
141.3 KB
Views:
17
5. ### Metamega

Sure theirs a prettier way to do this but try

C<= ref(((H-L)/2)+L,-1).

This will give you the value at halfway through the previous bar. Your code gives you half the bars value.

6. ### mushinseeker

wajo.. this wont work.. bec in my pseudoexample that equation resolves to \$2.4 and if IBM is 50 then your equation is buy= 50 < \$2.04.

7. ### themickey

My experience, you are probably best to break your formulas down to several lines rather than place them in one line, then add a descriptor at the end so it jogs your memory later on.
First, what is bar height.
Second, 50% of bar height