Simple Coding Help - No Promise.

I already mentioned the possible problem...see my post before yours
i saw your reply, but couldnt understand the technical terms..
It is a buy when 10 cross 20 on the upside , when 50 is already above 100.
It is a sell when 10 cross 20 on the downside, when 50 is already below 100.

So in the 2 scenario you have mentioned it wont lead to any buy/sell trigger.

Thanks.
 

pratapvb

Well-Known Member
i saw your reply, but couldnt understand the technical terms..
It is a buy when 10 cross 20 on the upside , when 50 is already above 100.
It is a sell when 10 cross 20 on the downside, when 50 is already below 100.

So in the 2 scenario you have mentioned it wont lead to any buy/sell trigger.

Thanks.
see the 1st 1/2 of that post

The buy and sell lines
Buy = Cross(LongMA, ShortMA) AND Lengtha>Lengthb;
Sell = Cross(ShortMA, LongMA) AND Lengtha<Lengthb;


need to be replaced with
Buy = Cross(LongMA, ShortMA) AND pricea>priceb;
Sell = Cross(ShortMA, LongMA) AND pricea<priceb;
 

Nehal_s143

Well-Known Member
Thanks nehal,

As i see it , it only shows shorting trades , is there a problem somewhere.

As suggested by Pratap Sir, use pricea > priceb and pricea < priceb this code

i.e instead of

Buy = Cross(LongMA, ShortMA) AND Lengtha>Lengthb;
Sell = Cross(ShortMA, LongMA) AND Lengtha<Lengthb;

use

Buy = Cross(LongMA, ShortMA) AND pricea>priceb;
Sell = Cross(ShortMA, LongMA) AND pricea<priceb;
 

amitrandive

Well-Known Member
Dear All

This is an Open=High and Open=Low Exploration.

Can anyone please modify the code , so that the high and low can be within any percentage range?

For example if the high is more than 0.1% of the open , this exploration will still catch that stock and viceversa.This percentage should be changeable.

Code:
Buy =  TimeFrameGetPrice("L",inDaily,0)==TimeFrameGetPrice("O",inDaily,0) ;

Sell =  TimeFrameGetPrice("H",inDaily,0)==TimeFrameGetPrice("O",inDaily,0) ;


Filter=Buy OR Sell;

AddColumn(IIf(Buy,BuyPrice,Null)," open=low ", 6.2,1.2,colorGreen);
AddColumn(IIf(Sell,SellPrice,Null)," open= high ",6.2,1.2,colorOrange);
 
Dear All

This is an Open=High and Open=Low Exploration.

Can anyone please modify the code , so that the high and low can be within any percentage range?

For example if the high is more than 0.1% of the open , this exploration will still catch that stock and viceversa.This percentage should be changeable.

Code:
Buy =  TimeFrameGetPrice("L",inDaily,0)==TimeFrameGetPrice("O",inDaily,0) ;

Sell =  TimeFrameGetPrice("H",inDaily,0)==TimeFrameGetPrice("O",inDaily,0) ;


Filter=Buy OR Sell;

AddColumn(IIf(Buy,BuyPrice,Null)," open=low ", 6.2,1.2,colorGreen);
AddColumn(IIf(Sell,SellPrice,Null)," open= high ",6.2,1.2,colorOrange);

Code:
EODOpen = TimeFrameGetPrice("O",inDaily,0);
EODLow  = TimeFrameGetPrice("L",inDaily,0);
EODHigh = TimeFrameGetPrice("H",inDaily,0);

percentage = 0.01 * Param("Percentage",5, 1, 10);

Buy  = Abs(EODOpen  - EODLow) <= percentage * EODOpen;
Sell = Abs(EODOpen - EODHigh) <= percentage * EODOpen;

Filter = Buy OR Sell;

AddColumn(IIf(Buy,BuyPrice,Null)  ," open=low "  ,6.2,1.2,colorGreen);
AddColumn(IIf(Sell,SellPrice,Null)," open= high ",6.2,1.2,colorOrange);
 

amitrandive

Well-Known Member
Code:
EODOpen = TimeFrameGetPrice("O",inDaily,0);
EODLow  = TimeFrameGetPrice("L",inDaily,0);
EODHigh = TimeFrameGetPrice("H",inDaily,0);

percentage = 0.01 * Param("Percentage",5, 1, 10);

Buy  = Abs(EODOpen  - EODLow) <= percentage * EODOpen;
Sell = Abs(EODOpen - EODHigh) <= percentage * EODOpen;

Filter = Buy OR Sell;

AddColumn(IIf(Buy,BuyPrice,Null)  ," open=low "  ,6.2,1.2,colorGreen);
AddColumn(IIf(Sell,SellPrice,Null)," open= high ",6.2,1.2,colorOrange);
mastermind007

Thanks for the code, will check in real time and let you know.
:clap::clap::clap:
 
candles price average

Dear Happy sing ji
I need afl for a candles price average (High+Low+Close) at specific time
For example:
In 10 min timeframe I want average price of candle which appeared at 3.00 PM every day , also with volume
Thanks in advance.
 
Hi,

I am not very proud of calling myself a techie after trying to get this for whole of yesterday. Any help is appreciated.

I am using this on intraday data. And set the range to 1 recent day

Objective: Want to run this at 10 am to find if the first half hour is a Full Green Candle or Full Black Candle.

Filter = DateNum() > 1140101;

_SECTION_BEGIN( "Open Drive1" );


TimeFrameSet( 2*in15Minute );

Lo = TimeFrameGetPrice( "L", 2*in15Minute, -1 );
Hi = TimeFrameGetPrice( "H", 2*in15Minute,-1 );
Ope = TimeFrameGetPrice( "0", 2*in15Minute,-1 );
Clo = TimeFrameGetPrice( "C", 2*in15Minute, -1 );


Buy = ( ( Clo > Ope ) AND ( ( Clo - Ope ) / ( .001 + Hi - Lo ) > .8 ) );

Sell = ( ( Ope > Clo ) AND ( ( Ope - Clo ) / ( .001 + Hi - Lo ) > .8 ) );

AddColumn( Ope, "Open" );
AddColumn( Clo, "Close");
AddColumn( Hi, "High");
AddColumn( lo, "Low");

TimeFrameRestore();

_SECTION_END();


The values which I am getting is all crap. For ex: For Apollo Tyres, following are values which it has printed. Looks like it is taking Daily Values

Open =107.85 (No idea where it came from)
Close =107.85 (30th Jan Close)
High= 108.3 (30th Jan High)
Low=104.5 (30th Jan Low)
 

mastermind007

Well-Known Member
How do I find at which price the crossover actually happened in amibroker?

Say I generate buy signal on open and psar crossover and sell signal when psar and open crossover..... How to get the price when the crossover actually happened? Say the last traded price at that moment and store in a variable to be shown on chart?

P.S. I have tried using GetRTData but it gives me an empty value. And I am bringing in feed from google.

Just quoting myself to bring the question in light. Anybody? Any help with this one?
Code:
CrossOver = Cross(ArrayOne, ArrayTwo);
ClosePriceAtCrossOver = ValueWhen(CrossOver, Close);
 
Last edited:

Similar threads